Skip to content

Commit 70e71ed

Browse files
committed
just fix
1 parent 4221788 commit 70e71ed

File tree

5 files changed

+73
-54
lines changed

5 files changed

+73
-54
lines changed

crates/flashblocks-rpc/src/tests/rpc.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
#[cfg(test)]
22
mod tests {
3-
use crate::rpc::{EthApiExt, EthApiOverrideServer};
4-
use crate::state::FlashblocksState;
5-
use crate::subscription::{Flashblock, FlashblocksReceiver, Metadata};
6-
use crate::tests::{BLOCK_INFO_TXN, BLOCK_INFO_TXN_HASH};
3+
use std::{str::FromStr, sync::Arc};
4+
75
use alloy_consensus::Receipt;
86
use alloy_eips::BlockNumberOrTag;
9-
use alloy_primitives::map::HashMap;
10-
use alloy_primitives::{Address, B256, Bytes, LogData, TxHash, U256, address, b256, bytes};
7+
use alloy_primitives::{
8+
Address, B256, Bytes, LogData, TxHash, U256, address, b256, bytes, map::HashMap,
9+
};
1110
use alloy_provider::Provider;
1211
use alloy_rpc_client::RpcClient;
1312
use alloy_rpc_types::simulate::{SimBlock, SimulatePayload};
1413
use alloy_rpc_types_engine::PayloadId;
15-
use alloy_rpc_types_eth::TransactionInput;
16-
use alloy_rpc_types_eth::error::EthRpcErrorCode;
14+
use alloy_rpc_types_eth::{TransactionInput, error::EthRpcErrorCode};
1715
use base_reth_test_utils::harness::TestHarness;
1816
use eyre::Result;
1917
use once_cell::sync::OnceCell;
@@ -24,11 +22,16 @@ mod tests {
2422
use reth_optimism_primitives::OpReceipt;
2523
use reth_rpc_eth_api::RpcReceipt;
2624
use rollup_boost::{ExecutionPayloadBaseV1, ExecutionPayloadFlashblockDeltaV1};
27-
use std::str::FromStr;
28-
use std::sync::Arc;
2925
use tokio::sync::{mpsc, oneshot};
3026
use tokio_stream::StreamExt;
3127

28+
use crate::{
29+
rpc::{EthApiExt, EthApiOverrideServer},
30+
state::FlashblocksState,
31+
subscription::{Flashblock, FlashblocksReceiver, Metadata},
32+
tests::{BLOCK_INFO_TXN, BLOCK_INFO_TXN_HASH},
33+
};
34+
3235
pub struct TestSetup {
3336
sender: mpsc::Sender<(Flashblock, oneshot::Sender<()>)>,
3437
harness: TestHarness,

crates/flashblocks-rpc/src/tests/state.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
#[cfg(test)]
22
mod tests {
3-
use crate::rpc::{FlashblocksAPI, PendingBlocksAPI};
4-
use crate::state::FlashblocksState;
5-
use crate::subscription::{Flashblock, FlashblocksReceiver, Metadata};
6-
use crate::tests::{BLOCK_INFO_TXN, BLOCK_INFO_TXN_HASH};
3+
use std::time::Duration;
4+
75
use alloy_consensus::{Receipt, Transaction};
86
use alloy_eips::{BlockHashOrNumber, Encodable2718};
9-
use alloy_primitives::map::foldhash::HashMap;
10-
use alloy_primitives::{Address, B256, BlockNumber, Bytes, U256, hex};
7+
use alloy_primitives::{Address, B256, BlockNumber, Bytes, U256, hex, map::foldhash::HashMap};
118
use alloy_rpc_types_engine::PayloadId;
12-
use base_reth_test_utils::accounts::TestAccounts;
13-
use base_reth_test_utils::harness::TestHarness as BaseHarness;
14-
use base_reth_test_utils::node::{LocalNodeProvider, default_launcher};
9+
use base_reth_test_utils::{
10+
accounts::TestAccounts,
11+
harness::TestHarness as BaseHarness,
12+
node::{LocalNodeProvider, default_launcher},
13+
};
1514
use op_alloy_consensus::OpDepositReceipt;
1615
use op_alloy_network::BlockResponse;
17-
use reth::chainspec::EthChainSpec;
18-
use reth::providers::{AccountReader, BlockNumReader, BlockReader};
19-
use reth::transaction_pool::test_utils::TransactionBuilder;
16+
use reth::{
17+
chainspec::EthChainSpec,
18+
providers::{AccountReader, BlockNumReader, BlockReader},
19+
transaction_pool::test_utils::TransactionBuilder,
20+
};
2021
use reth_optimism_primitives::{OpBlock, OpReceipt, OpTransactionSigned};
2122
use reth_primitives_traits::{Account, Block as BlockT, RecoveredBlock};
2223
use reth_provider::{ChainSpecProvider, StateProviderFactory};
2324
use rollup_boost::{ExecutionPayloadBaseV1, ExecutionPayloadFlashblockDeltaV1};
24-
use std::time::Duration;
2525
use tokio::time::sleep;
26+
27+
use crate::{
28+
rpc::{FlashblocksAPI, PendingBlocksAPI},
29+
state::FlashblocksState,
30+
subscription::{Flashblock, FlashblocksReceiver, Metadata},
31+
tests::{BLOCK_INFO_TXN, BLOCK_INFO_TXN_HASH},
32+
};
2633
// The amount of time to wait (in milliseconds) after sending a new flashblock or canonical block
2734
// so it can be processed by the state processor
2835
const SLEEP_TIME: u64 = 10;

crates/test-utils/src/engine.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
//! This module provides a typed, type-safe Engine API client based on
44
//! reth's OpEngineApiClient trait instead of raw string-based RPC calls.
55
6+
use std::{marker::PhantomData, time::Duration};
7+
68
use alloy_eips::eip7685::Requests;
79
use alloy_primitives::B256;
810
use alloy_rpc_types_engine::{ForkchoiceUpdated, PayloadId, PayloadStatus};
911
use eyre::Result;
1012
use jsonrpsee::core::client::SubscriptionClientT;
1113
use op_alloy_rpc_types_engine::OpExecutionPayloadV4;
12-
use reth::api::{EngineTypes, PayloadTypes};
13-
use reth::rpc::types::engine::ForkchoiceState;
14+
use reth::{
15+
api::{EngineTypes, PayloadTypes},
16+
rpc::types::engine::ForkchoiceState,
17+
};
1418
use reth_optimism_node::OpEngineTypes;
1519
use reth_optimism_rpc::OpEngineApiClient;
1620
use reth_rpc_layer::{AuthClientLayer, JwtSecret};
1721
use reth_tracing::tracing::debug;
18-
use std::marker::PhantomData;
19-
use std::time::Duration;
2022
use url::Url;
2123

2224
/// Default JWT secret for testing

crates/test-utils/src/harness.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Unified test harness combining node, engine API, and flashblocks functionality
22
3-
use crate::accounts::TestAccounts;
4-
use crate::engine::{EngineApi, IpcEngine};
5-
use crate::node::{LocalFlashblocksState, LocalNode, LocalNodeProvider, OpAddOns, OpBuilder};
3+
use std::{sync::Arc, time::Duration};
4+
65
use alloy_eips::{BlockHashOrNumber, eip7685::Requests};
76
use alloy_primitives::{B256, Bytes, bytes};
87
use alloy_provider::{Provider, RootProvider};
@@ -13,16 +12,22 @@ use eyre::{Result, eyre};
1312
use futures_util::Future;
1413
use op_alloy_network::Optimism;
1514
use op_alloy_rpc_types_engine::OpPayloadAttributes;
16-
use reth::builder::NodeHandle;
17-
use reth::providers::{BlockNumReader, BlockReader};
15+
use reth::{
16+
builder::NodeHandle,
17+
providers::{BlockNumReader, BlockReader},
18+
};
1819
use reth_e2e_test_utils::Adapter;
1920
use reth_optimism_node::OpNode;
2021
use reth_optimism_primitives::OpBlock;
2122
use reth_primitives_traits::{Block as BlockT, RecoveredBlock};
22-
use std::sync::Arc;
23-
use std::time::Duration;
2423
use tokio::time::sleep;
2524

25+
use crate::{
26+
accounts::TestAccounts,
27+
engine::{EngineApi, IpcEngine},
28+
node::{LocalFlashblocksState, LocalNode, LocalNodeProvider, OpAddOns, OpBuilder},
29+
};
30+
2631
const BLOCK_TIME_SECONDS: u64 = 2;
2732
const GAS_LIMIT: u64 = 200_000_000;
2833
const NODE_STARTUP_DELAY_MS: u64 = 500;
@@ -179,12 +184,12 @@ impl TestHarness {
179184

180185
#[cfg(test)]
181186
mod tests {
182-
use crate::node::default_launcher;
183-
184-
use super::*;
185187
use alloy_primitives::U256;
186188
use alloy_provider::Provider;
187189

190+
use super::*;
191+
use crate::node::default_launcher;
192+
188193
#[tokio::test]
189194
async fn test_harness_setup() -> Result<()> {
190195
reth_tracing::init_test_tracing();

crates/test-utils/src/node.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
//! Local node setup with Base Sepolia chainspec
22
3-
use crate::engine::EngineApi;
3+
use std::{any::Any, net::SocketAddr, sync::Arc};
4+
45
use alloy_genesis::Genesis;
56
use alloy_provider::RootProvider;
67
use alloy_rpc_client::RpcClient;
7-
use base_reth_flashblocks_rpc::rpc::{EthApiExt, EthApiOverrideServer};
8-
use base_reth_flashblocks_rpc::state::FlashblocksState;
9-
use base_reth_flashblocks_rpc::subscription::{Flashblock, FlashblocksReceiver};
8+
use base_reth_flashblocks_rpc::{
9+
rpc::{EthApiExt, EthApiOverrideServer},
10+
state::FlashblocksState,
11+
subscription::{Flashblock, FlashblocksReceiver},
12+
};
1013
use eyre::Result;
1114
use futures_util::Future;
1215
use once_cell::sync::OnceCell;
1316
use op_alloy_network::Optimism;
14-
use reth::api::{FullNodeTypesAdapter, NodeTypesWithDBAdapter};
15-
use reth::args::{DiscoveryArgs, NetworkArgs, RpcServerArgs};
16-
use reth::builder::{
17-
Node, NodeBuilder, NodeBuilderWithComponents, NodeConfig, NodeHandle, WithLaunchContext,
17+
use reth::{
18+
api::{FullNodeTypesAdapter, NodeTypesWithDBAdapter},
19+
args::{DiscoveryArgs, NetworkArgs, RpcServerArgs},
20+
builder::{
21+
Node, NodeBuilder, NodeBuilderWithComponents, NodeConfig, NodeHandle, WithLaunchContext,
22+
},
23+
core::exit::NodeExitFuture,
24+
tasks::TaskManager,
1825
};
19-
use reth::core::exit::NodeExitFuture;
20-
use reth::tasks::TaskManager;
2126
use reth_db::{
2227
ClientVersion, DatabaseEnv, init_db,
2328
mdbx::DatabaseArguments,
@@ -30,16 +35,13 @@ use reth_node_core::{
3035
dirs::{DataDirPath, MaybePlatformPath},
3136
};
3237
use reth_optimism_chainspec::OpChainSpec;
33-
use reth_optimism_node::OpNode;
34-
use reth_optimism_node::args::RollupArgs;
35-
use reth_provider::CanonStateSubscriptions;
36-
use reth_provider::providers::BlockchainProvider;
37-
use std::any::Any;
38-
use std::net::SocketAddr;
39-
use std::sync::Arc;
38+
use reth_optimism_node::{OpNode, args::RollupArgs};
39+
use reth_provider::{CanonStateSubscriptions, providers::BlockchainProvider};
4040
use tokio::sync::{mpsc, oneshot};
4141
use tokio_stream::StreamExt;
4242

43+
use crate::engine::EngineApi;
44+
4345
pub const BASE_CHAIN_ID: u64 = 84532;
4446

4547
pub type LocalNodeProvider = BlockchainProvider<NodeTypesWithDBAdapter<OpNode, TmpDB>>;

0 commit comments

Comments
 (0)