mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
42 lines
1.3 KiB
Rust
42 lines
1.3 KiB
Rust
use crate::utils::{advance_chain, setup};
|
|
use reth::primitives::BASE_MAINNET;
|
|
use reth_e2e_test_utils::{transaction::TransactionTestContext, wallet::Wallet};
|
|
use reth_primitives::ChainId;
|
|
|
|
#[tokio::test]
|
|
async fn can_sync() -> eyre::Result<()> {
|
|
reth_tracing::init_test_tracing();
|
|
|
|
let chain_id: ChainId = BASE_MAINNET.chain.into();
|
|
|
|
let (mut nodes, _tasks, _wallet) = setup(2).await?;
|
|
|
|
let second_node = nodes.pop().unwrap();
|
|
let mut first_node = nodes.pop().unwrap();
|
|
|
|
let tip: usize = 300;
|
|
let tip_index: usize = tip - 1;
|
|
|
|
let wallet = Wallet::default();
|
|
|
|
// On first node, create a chain up to block number 300a
|
|
let canonical_payload_chain = advance_chain(tip, &mut first_node, |nonce: u64| {
|
|
let wallet = wallet.inner.clone();
|
|
Box::pin(async move {
|
|
TransactionTestContext::optimism_l1_block_info_tx(chain_id, wallet, nonce).await
|
|
})
|
|
})
|
|
.await?;
|
|
let canonical_chain =
|
|
canonical_payload_chain.iter().map(|p| p.0.block().hash()).collect::<Vec<_>>();
|
|
|
|
// On second node, sync up to block number 300a
|
|
second_node
|
|
.engine_api
|
|
.update_forkchoice(canonical_chain[tip_index], canonical_chain[tip_index])
|
|
.await?;
|
|
second_node.wait_block(tip as u64, canonical_chain[tip_index], true).await?;
|
|
|
|
Ok(())
|
|
}
|