Skip to content

Commit

Permalink
Modify integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranbt committed Feb 11, 2025
1 parent 61dd3ff commit f13a6bb
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/scripts/benchmark-results.*
/test/
/integration_logs
genesis.json

# editors
.code
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/op-rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ alloy-network.workspace = true
# op
op-alloy-consensus.workspace = true
op-alloy-rpc-types-engine.workspace = true
op-alloy-network.workspace = true

revm.workspace = true

Expand Down
32 changes: 27 additions & 5 deletions crates/op-rbuilder/src/integration/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ mod tests {
op_rbuilder::OpRbuilderConfig, op_reth::OpRethConfig, IntegrationFramework,
};
use crate::tester::{BlockGenerator, EngineApi};
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_types_eth::BlockTransactionsKind;
use op_alloy_network::Optimism;
use std::path::PathBuf;
use uuid::Uuid;

const BUILDER_PRIVATE_KEY: &str =
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d";

#[tokio::test]
async fn integration_test_chain_produces_blocks() {
async fn integration_test_chain_produces_blocks() -> eyre::Result<()> {
// This is a simple test using the integration framework to test that the chain
// produces blocks.
let mut framework = IntegrationFramework::new().unwrap();
Expand All @@ -28,6 +31,7 @@ mod tests {
.data_dir(builder_data_dir)
.auth_rpc_port(1234)
.network_port(1235)
.http_port(1238)
.with_builder_private_key(BUILDER_PRIVATE_KEY);

// create the validation reth node
Expand All @@ -49,16 +53,34 @@ mod tests {
let validation_api = EngineApi::new("http://localhost:1236").unwrap();

let mut generator = BlockGenerator::new(&engine_api, Some(&validation_api), false, 1);
generator.init().await.unwrap();
generator.init().await?;

let provider = ProviderBuilder::new()
.network::<Optimism>()
.on_http("http://localhost:1238".parse()?);

for _ in 0..10 {
generator.generate_block().await.unwrap();
let block_hash = generator.generate_block().await?;

// query the block and the transactions inside the block
let block = provider
.get_block_by_hash(block_hash, BlockTransactionsKind::Hashes)
.await?
.expect("block");

for hash in block.transactions.hashes() {
let _ = provider
.get_transaction_receipt(hash)
.await?
.expect("receipt");
}
}

// there must be a line logging the monitoring transaction
op_rbuilder
.find_log_line("Committed block built by builder")
.await
.unwrap();
.await?;

Ok(())
}
}
5 changes: 5 additions & 0 deletions crates/op-rbuilder/src/integration/op_rbuilder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ impl OpRbuilderConfig {
self
}

pub fn http_port(mut self, port: u16) -> Self {
self.http_port = Some(port);
self
}

pub fn with_builder_private_key(mut self, private_key: &str) -> Self {
self.builder_private_key = Some(private_key.to_string());
self
Expand Down

0 comments on commit f13a6bb

Please sign in to comment.