mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: blob e2e test (#7823)
This commit is contained in:
@ -1,13 +1,15 @@
|
||||
use crate::utils::{advance_chain, setup};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
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 (mut nodes, _tasks, wallet) = setup(2).await?;
|
||||
let wallet = Arc::new(Mutex::new(wallet));
|
||||
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();
|
||||
@ -15,13 +17,24 @@ async fn can_sync() -> eyre::Result<()> {
|
||||
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, wallet.clone()).await?;
|
||||
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]).await?;
|
||||
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(())
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
use reth::{rpc::types::engine::PayloadAttributes, tasks::TaskManager};
|
||||
use reth::{primitives::Bytes, rpc::types::engine::PayloadAttributes, tasks::TaskManager};
|
||||
use reth_e2e_test_utils::{wallet::Wallet, NodeHelperType};
|
||||
use reth_node_optimism::{OptimismBuiltPayload, OptimismNode, OptimismPayloadBuilderAttributes};
|
||||
use reth_payload_builder::EthPayloadBuilderAttributes;
|
||||
use reth_primitives::{Address, ChainSpecBuilder, Genesis, B256, BASE_MAINNET};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
use std::{future::Future, pin::Pin, sync::Arc};
|
||||
|
||||
/// Optimism Node Helper type
|
||||
pub(crate) type OpNode = NodeHelperType<OptimismNode>;
|
||||
@ -28,17 +27,9 @@ pub(crate) async fn setup(num_nodes: usize) -> eyre::Result<(Vec<OpNode>, TaskMa
|
||||
pub(crate) async fn advance_chain(
|
||||
length: usize,
|
||||
node: &mut OpNode,
|
||||
wallet: Arc<Mutex<Wallet>>,
|
||||
tx_generator: impl Fn(u64) -> Pin<Box<dyn Future<Output = Bytes>>>,
|
||||
) -> eyre::Result<Vec<(OptimismBuiltPayload, OptimismPayloadBuilderAttributes)>> {
|
||||
node.advance(
|
||||
length as u64,
|
||||
|| {
|
||||
let wallet = wallet.clone();
|
||||
Box::pin(async move { wallet.lock().await.optimism_l1_block_info_tx().await })
|
||||
},
|
||||
optimism_payload_attributes,
|
||||
)
|
||||
.await
|
||||
node.advance(length as u64, tx_generator, optimism_payload_attributes).await
|
||||
}
|
||||
|
||||
/// Helper function to create a new eth payload attributes
|
||||
|
||||
Reference in New Issue
Block a user