Skip to content

Commit

Permalink
tests(ethexe): append initial ethexe-cli integration testing (#4064)
Browse files Browse the repository at this point in the history
  • Loading branch information
grishasobol authored Jul 18, 2024
1 parent e1f61f9 commit f4dd3f0
Show file tree
Hide file tree
Showing 10 changed files with 465 additions and 20 deletions.
37 changes: 37 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions ethexe/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,21 @@ tempfile.workspace = true
futures-timer.workspace = true

static_init = "1.0.3"

#[dev-dependencies]
alloy = { workspace = true, features = [
"consensus",
"eips",
"node-bindings",
"provider-http",
"provider-ws",
"provider-anvil-api",
"pubsub",
"rpc-client",
"rpc-types-eth",
"rpc-types-beacon",
"signer-local",
] }
demo-ping = { workspace = true, features = ["debug"] }
ntest = "0.9.3"
gear-utils.workspace = true
3 changes: 3 additions & 0 deletions ethexe/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ mod metrics;
mod params;
mod service;

#[cfg(test)]
mod tests;

use crate::{args::Args, config::Config, service::Service};
use anyhow::Context;
use clap::Parser;
Expand Down
43 changes: 35 additions & 8 deletions ethexe/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,34 @@ impl Service {
})
}

#[cfg(test)]
#[allow(clippy::too_many_arguments)]
pub(crate) fn new_from_parts(
db: Database,
network: ethexe_network::NetworkWorker,
observer: ethexe_observer::Observer,
query: ethexe_observer::Query,
processor: ethexe_processor::Processor,
signer: ethexe_signer::Signer,
sequencer: Option<ethexe_sequencer::Sequencer>,
validator: Option<ethexe_validator::Validator>,
metrics_service: Option<MetricsService>,
rpc: ethexe_rpc::RpcService,
) -> Self {
Self {
db,
network,
observer,
query,
processor,
signer,
sequencer,
validator,
metrics_service,
rpc,
}
}

// TODO: remove this function.
// This is a temporary solution to download absent codes from already processed blocks.
async fn process_upload_codes(
Expand Down Expand Up @@ -294,6 +322,12 @@ impl Service {

let commitments = match observer_event {
ethexe_observer::Event::Block(block_data) => {
log::info!(
"📦 receive a new block {}, hash {}, parent hash {}",
block_data.block_number,
block_data.block_hash,
block_data.parent_hash
);
let commitments =
Self::process_block_event(db, query, processor, block_data).await?;
commitments.into_iter().map(Commitment::Block).collect()
Expand Down Expand Up @@ -378,8 +412,6 @@ impl Service {
break;
};

let is_block_event = matches!(observer_event, ethexe_observer::Event::Block(_));

let commitments = Self::process_observer_event(
&db,
&mut query,
Expand Down Expand Up @@ -408,12 +440,7 @@ impl Service {
}
}

if is_block_event {
// After 3 seconds of block event:
// - if validator, clean commitments
// - if sequencer, send commitments transactions
delay = Some(tokio::time::sleep(std::time::Duration::from_secs(3)));
}
delay = Some(tokio::time::sleep(std::time::Duration::from_secs(3)));
}
message = gossip_stream.next() => {
if let Some(message) = message {
Expand Down
Loading

0 comments on commit f4dd3f0

Please sign in to comment.