Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.

Commit 2359b6a

Browse files
committed
Print container logs for external nodes
1 parent 9dcad4e commit 2359b6a

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

crates/op-rbuilder/src/tests/framework/external.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,40 @@ impl ExternalNode {
237237
);
238238

239239
if result.status != PayloadStatusEnum::Valid {
240+
// print out container logs
241+
match self
242+
.docker
243+
.attach_container(
244+
&self.container_id,
245+
Some(AttachContainerOptions::<String> {
246+
stdout: Some(true),
247+
stderr: Some(true),
248+
stream: Some(true),
249+
logs: Some(true),
250+
..Default::default()
251+
}),
252+
)
253+
.await
254+
{
255+
Ok(stream) => {
256+
let mut attach_stream = stream;
257+
debug!("Container logs for {}:", self.container_id);
258+
while let Some(Ok(output)) = attach_stream.output.next().await {
259+
use testcontainers::bollard::container::LogOutput;
260+
match output {
261+
LogOutput::StdOut { message } | LogOutput::StdErr { message } => {
262+
let message = String::from_utf8_lossy(&message);
263+
debug!("{}", message.trim_end());
264+
}
265+
LogOutput::StdIn { .. } | LogOutput::Console { .. } => {}
266+
}
267+
}
268+
}
269+
Err(e) => {
270+
warn!("Failed to attach to container {}: {}", self.container_id, e);
271+
}
272+
};
273+
240274
return Err(eyre::eyre!(
241275
"Failed to validate block {new_block_hash} with external validation node."
242276
));

0 commit comments

Comments
 (0)