Skip to content

Commit

Permalink
Merge branch 'main' into ceyhun/clementine_support
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyhunsen committed Oct 14, 2024
2 parents 7162243 + d3b6daf commit 95195c8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ bollard = { version = "0.17.1" }
futures = "0.3"
hex = { version = "0.4.3", default-features = false, features = ["serde"] }
jsonrpsee = { version = "0.24.2", features = ["http-client", "ws-client"] }
log-panics = { version = "2", features = ["with-backtrace"] }
rand = "0.8"
serde = { version = "1.0.192", default-features = false, features = ["alloc", "derive"] }
serde_json = { version = "1.0", default-features = false }
tempfile = "3.8"
tokio = { version = "1.39", features = ["full"] }
toml = "0.8.0"
tracing = { version = "0.1.40", default-features = false }
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json", "fmt"] }

# Citrea dependencies
sov-ledger-rpc = { git = "https://github.com/chainwayxyz/citrea", rev = "82bf52d", default-features = false, features = ["client"] }
Expand Down
4 changes: 2 additions & 2 deletions src/batch_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::time::SystemTime;

use anyhow::bail;
use tokio::time::{sleep, Duration};
use tracing::debug;
use tracing::trace;

use super::{config::FullBatchProverConfig, Result};
use crate::node::Node;
Expand All @@ -14,7 +14,7 @@ impl BatchProver {
let start = SystemTime::now();
let timeout = timeout.unwrap_or(Duration::from_secs(600));
loop {
debug!("Waiting for batch prover height {}", height);
trace!("Waiting for batch prover height {}", height);
let latest_block = self.client.ledger_get_last_scanned_l1_height().await?;

if latest_block >= height {
Expand Down
32 changes: 31 additions & 1 deletion src/framework.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use std::{future::Future, sync::Arc};
use std::{
future::Future,
sync::{Arc, Once},
};

use bitcoincore_rpc::RpcApi;
use tracing::{debug, info};
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};

use super::{
bitcoin::BitcoinNodeCluster, config::TestConfig, docker::DockerEnv, full_node::FullNode,
Expand Down Expand Up @@ -55,6 +59,8 @@ async fn create_optional<T>(pred: bool, f: impl Future<Output = Result<T>>) -> R

impl TestFramework {
pub async fn new(config: TestConfig) -> Result<Self> {
setup_logging();

anyhow::ensure!(
config.test_case.n_nodes > 0,
"At least one bitcoin node has to be running"
Expand Down Expand Up @@ -231,3 +237,27 @@ impl TestFramework {
Ok(())
}
}

static INIT: Once = Once::new();

fn setup_logging() {
INIT.call_once(|| {
let env_filter = EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("citrea_e2e=info"))
.unwrap();

if std::env::var("JSON_LOGS").is_ok() {
let _ = tracing_subscriber::registry()
.with(fmt::layer().json())
.with(env_filter)
.try_init();
} else {
let _ = tracing_subscriber::registry()
.with(fmt::layer())
.with(env_filter)
.try_init();
}

log_panics::init();
});
}

0 comments on commit 95195c8

Please sign in to comment.