Skip to content

Commit

Permalink
Improve logs in rbuilder integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranbt committed Feb 25, 2025
1 parent 4881443 commit e42a54f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
9 changes: 6 additions & 3 deletions crates/rbuilder/src/integration/playground.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn open_log_file(path: PathBuf) -> io::Result<File> {
}

impl Playground {
pub fn new(cfg_path: &PathBuf) -> Result<Self, PlaygroundError> {
pub fn new(name: &str, cfg_path: &PathBuf) -> Result<Self, PlaygroundError> {
// load the binary from the cargo_dir
let mut bin_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
bin_path.push("../../target/debug/rbuilder");
Expand All @@ -51,12 +51,15 @@ impl Playground {

let format = format_description::parse("[year]_[month]_[day]_[hour]_[minute]_[second]")
.map_err(|_| PlaygroundError::SetupError)?;
let name = dt
let format_str = dt
.format(&format)
.map_err(|_| PlaygroundError::SetupError)?;

let mut log_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
log_path.push(format!("../../integration_logs/{}.log", name));
log_path.push(format!(
"../../integration_logs/{}_{}.log",
format_str, name,
));

let log = open_log_file(log_path.clone()).map_err(|_| PlaygroundError::SetupError)?;
let stdout = log.try_clone().map_err(|_| PlaygroundError::SetupError)?;
Expand Down
5 changes: 3 additions & 2 deletions crates/rbuilder/src/integration/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mod tests {
.join("../../crates/rbuilder/src/integration/test_data/config-playground.toml");

// This test sends a transaction ONLY to the builder and waits for the block to be built with it.
let srv = Playground::new(&config_path).unwrap();
let srv = Playground::new("test_simple_example", &config_path).unwrap();
srv.wait_for_next_slot().await.unwrap();

// Send transaction using the helper function
Expand Down Expand Up @@ -117,7 +117,8 @@ mod tests {
);
let blocklist_server = BlocklistHttpServer::new(1934, Some(BLOCKLIST_LEN_2.to_string()));
tokio::time::sleep(Duration::from_millis(100)).await; //puaj
let mut srv = Playground::new(&config_path).unwrap();
let mut srv =
Playground::new("test_builder_closes_on_old_blocklist", &config_path).unwrap();
srv.wait_for_next_slot().await.unwrap();
blocklist_server.set_answer(None);
let timeout_secs = 5 /*blocklist_url_max_age_secs in cfg */ +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ log_level = "info,rbuilder=debug"
coinbase_secret_key = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
blocklist_url_max_age_secs = 5
watchdog_timeout_sec = 15
blocklist = "http://127.0.0.1:1934"
blocklist = "http://127.0.0.1:1934"
root_hash_use_sparse_trie = true
root_hash_compare_sparse_trie = false
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ live_builders = ["mgp-ordering"]
enabled_relays = ["playground"]
log_level = "info,rbuilder=debug"
coinbase_secret_key = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
blocklist_file_path = "./src/integration/test_data/blocklist.json"
blocklist_file_path = "./src/integration/test_data/blocklist.json"
root_hash_use_sparse_trie = true
root_hash_compare_sparse_trie = false

0 comments on commit e42a54f

Please sign in to comment.