1- //! Unified test harness combining node and engine helpers, plus an optional flashblocks adapter.
1+ //! Unified test harness combining node and engine helpers, plus optional flashblocks adapter.
22
3- use std:: { ops :: Deref , sync :: Arc , time:: Duration } ;
3+ use std:: time:: Duration ;
44
55use alloy_eips:: { BlockHashOrNumber , eip7685:: Requests } ;
66use alloy_primitives:: { B64 , B256 , Bytes , bytes} ;
77use alloy_provider:: { Provider , RootProvider } ;
88use alloy_rpc_types:: BlockNumberOrTag ;
99use alloy_rpc_types_engine:: PayloadAttributes ;
10- use base_reth_flashblocks_rpc:: subscription:: Flashblock ;
1110use eyre:: { Result , eyre} ;
1211use futures_util:: Future ;
1312use op_alloy_network:: Optimism ;
@@ -25,10 +24,7 @@ use tokio::time::sleep;
2524use crate :: {
2625 accounts:: TestAccounts ,
2726 engine:: { EngineApi , IpcEngine } ,
28- node:: {
29- FlashblocksLocalNode , FlashblocksParts , LocalFlashblocksState , LocalNode ,
30- LocalNodeProvider , OpAddOns , OpBuilder , default_launcher,
31- } ,
27+ node:: { LocalNode , LocalNodeProvider , OpAddOns , OpBuilder , default_launcher} ,
3228 tracing:: init_silenced_tracing,
3329} ;
3430
@@ -62,7 +58,7 @@ impl TestHarness {
6258 Self :: from_node ( node) . await
6359 }
6460
65- async fn from_node ( node : LocalNode ) -> Result < Self > {
61+ pub ( crate ) async fn from_node ( node : LocalNode ) -> Result < Self > {
6662 let engine = node. engine_api ( ) ?;
6763 let accounts = TestAccounts :: new ( ) ;
6864
@@ -185,79 +181,6 @@ impl TestHarness {
185181 }
186182}
187183
188- pub struct FlashblocksHarness {
189- inner : TestHarness ,
190- parts : FlashblocksParts ,
191- }
192-
193- impl FlashblocksHarness {
194- pub async fn new ( ) -> Result < Self > {
195- Self :: with_launcher ( default_launcher) . await
196- }
197-
198- /// Same as `new` but canonical block processing is left to the test, which is useful when
199- /// reproducing races or reorg scenarios that require deterministic sequencing.
200- pub async fn manual_canonical ( ) -> Result < Self > {
201- Self :: manual_canonical_with_launcher ( default_launcher) . await
202- }
203-
204- pub async fn with_launcher < L , LRet > ( launcher : L ) -> Result < Self >
205- where
206- L : FnOnce ( OpBuilder ) -> LRet ,
207- LRet : Future < Output = eyre:: Result < NodeHandle < Adapter < OpNode > , OpAddOns > > > ,
208- {
209- init_silenced_tracing ( ) ;
210- let flash_node = FlashblocksLocalNode :: with_launcher ( launcher) . await ?;
211- Self :: from_flashblocks_node ( flash_node) . await
212- }
213-
214- pub async fn manual_canonical_with_launcher < L , LRet > ( launcher : L ) -> Result < Self >
215- where
216- L : FnOnce ( OpBuilder ) -> LRet ,
217- LRet : Future < Output = eyre:: Result < NodeHandle < Adapter < OpNode > , OpAddOns > > > ,
218- {
219- init_silenced_tracing ( ) ;
220- let flash_node = FlashblocksLocalNode :: with_manual_canonical_launcher ( launcher) . await ?;
221- Self :: from_flashblocks_node ( flash_node) . await
222- }
223-
224- pub fn flashblocks_state ( & self ) -> Arc < LocalFlashblocksState > {
225- self . parts . state ( )
226- }
227-
228- pub async fn send_flashblock ( & self , flashblock : Flashblock ) -> Result < ( ) > {
229- self . parts . send ( flashblock) . await
230- }
231-
232- pub async fn send_flashblocks < I > ( & self , flashblocks : I ) -> Result < ( ) >
233- where
234- I : IntoIterator < Item = Flashblock > ,
235- {
236- for flashblock in flashblocks {
237- self . send_flashblock ( flashblock) . await ?;
238- }
239- Ok ( ( ) )
240- }
241-
242- pub fn into_inner ( self ) -> TestHarness {
243- self . inner
244- }
245-
246- async fn from_flashblocks_node ( flash_node : FlashblocksLocalNode ) -> Result < Self > {
247- let ( node, parts) = flash_node. into_parts ( ) ;
248- let inner = TestHarness :: from_node ( node) . await ?;
249- Ok ( Self { inner, parts } )
250- }
251- }
252-
253- impl Deref for FlashblocksHarness {
254- type Target = TestHarness ;
255-
256- fn deref ( & self ) -> & Self :: Target {
257- & self . inner
258- }
259- }
260-
261184#[ cfg( test) ]
262185mod tests {
263186 use alloy_primitives:: U256 ;
0 commit comments