11use crate :: {
22 HostBlockSpec , NotificationSpec , NotificationWithSidecars , RuBlockSpec ,
3- convert:: ToRethPrimitive ,
3+ convert:: to_host_notification ,
44 types:: { CtxProvider , Log , TestCounterInstance , TestErc20Instance , TestLogInstance } ,
55} ;
66use alloy:: {
@@ -14,36 +14,79 @@ use alloy::{
1414 } ,
1515 rpc:: types:: eth:: { TransactionReceipt , TransactionRequest } ,
1616} ;
17- use reth:: transaction_pool:: { TransactionOrigin , TransactionPool , test_utils:: MockTransaction } ;
18- use reth_exex_test_utils:: { Adapter , TestExExHandle } ;
19- use reth_node_api:: FullNodeComponents ;
17+ use reth:: {
18+ api:: FullNodeComponents ,
19+ transaction_pool:: { TransactionOrigin , TransactionPool , test_utils:: MockTransaction } ,
20+ } ;
21+ use reth_exex_test_utils:: Adapter ;
2022use signet_cold:: { ColdStorageReadHandle , mem:: MemColdBackend } ;
2123use signet_hot:: {
2224 db:: { HotDbRead , UnsafeDbWrite } ,
2325 mem:: MemKv ,
2426} ;
2527use signet_node:: { NodeStatus , SignetNodeBuilder } ;
2628use signet_node_config:: test_utils:: test_config;
29+ use signet_node_types:: { HostNotification , HostNotifier } ;
30+ use signet_rpc:: { ServeConfig , StorageRpcConfig } ;
2731use signet_storage:: { CancellationToken , HistoryRead , HistoryWrite , HotKv , UnifiedStorage } ;
2832use signet_storage_types:: { Account , BlockNumberList , DbSignetEvent , RecoveredTx , SealedHeader } ;
29- use signet_test_utils:: contracts:: counter:: COUNTER_DEPLOY_CODE ;
33+ use signet_test_utils:: { chain :: Chain , contracts:: counter:: COUNTER_DEPLOY_CODE } ;
3034use signet_types:: constants:: { HostPermitted , RollupPermitted , SignetSystemConstants } ;
3135use signet_zenith:: { HostOrders :: OrdersInstance , RollupPassage :: RollupPassageInstance } ;
3236use std:: sync:: {
3337 Arc , Mutex ,
3438 atomic:: { AtomicU64 , Ordering } ,
3539} ;
36- use tokio:: { sync:: watch, task:: JoinHandle } ;
40+ use tokio:: sync:: { mpsc, watch} ;
41+ use tokio:: task:: JoinHandle ;
3742use tracing:: instrument;
3843
44+ /// A channel-backed [`HostNotifier`] for integration tests.
45+ ///
46+ /// Receives [`HostNotification`]s from the test harness and yields them
47+ /// to the signet node's main loop.
48+ pub struct TestHostNotifier {
49+ receiver : mpsc:: UnboundedReceiver < HostNotification < Chain > > ,
50+ }
51+
52+ impl TestHostNotifier {
53+ /// Create a new test notifier from a receiver.
54+ pub const fn new ( receiver : mpsc:: UnboundedReceiver < HostNotification < Chain > > ) -> Self {
55+ Self { receiver }
56+ }
57+ }
58+
59+ impl core:: fmt:: Debug for TestHostNotifier {
60+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
61+ f. debug_struct ( "TestHostNotifier" ) . finish_non_exhaustive ( )
62+ }
63+ }
64+
65+ impl HostNotifier for TestHostNotifier {
66+ type Chain = Chain ;
67+ type Error = core:: convert:: Infallible ;
68+
69+ async fn next_notification (
70+ & mut self ,
71+ ) -> Option < Result < HostNotification < Self :: Chain > , Self :: Error > > {
72+ self . receiver . recv ( ) . await . map ( Ok )
73+ }
74+
75+ fn set_head ( & mut self , _block_number : u64 ) { }
76+
77+ fn set_backfill_thresholds ( & mut self , _max_blocks : Option < u64 > ) { }
78+
79+ fn send_finished_height ( & self , _block_number : u64 ) -> Result < ( ) , Self :: Error > {
80+ Ok ( ( ) )
81+ }
82+ }
83+
3984/// Signet Node test context
4085///
4186/// This contains the following:
4287///
43- /// - Reth/ExEx context info
44- /// - The test exex handle, which is used to send notifications to the signet
45- /// instance.
46- /// - The components for the Signet Node instance
88+ /// - A channel sender for host notifications
89+ /// - The reth test components (for pool access)
4790/// - A receiver for the node status (latest block processed)
4891/// - Unified storage backed by in-memory hot and cold storage
4992/// - An alloy provider connected to the Signet Node RPC,
@@ -52,10 +95,10 @@ use tracing::instrument;
5295/// - A set of addresses for testing, each of which has a pre-existing balance
5396/// on the Signet Node chain.
5497pub struct SignetTestContext {
55- /// The test exex handle
56- pub handle : TestExExHandle ,
98+ /// The notification sender for the test host notifier.
99+ pub sender : mpsc :: UnboundedSender < HostNotification < Chain > > ,
57100
58- /// The components for the Signet Node instance
101+ /// The reth test components ( for pool access).
59102 pub components : Adapter ,
60103
61104 /// The Signet Node status receiver
@@ -101,7 +144,7 @@ impl SignetTestContext {
101144 #[ instrument]
102145 pub async fn new ( ) -> ( Self , JoinHandle < eyre:: Result < ( ) > > ) {
103146 let cfg = test_config ( ) ;
104- let ( ctx, handle ) = reth_exex_test_utils:: test_exex_context ( ) . await . unwrap ( ) ;
147+ let ( ctx, _handle ) = reth_exex_test_utils:: test_exex_context ( ) . await . unwrap ( ) ;
105148 let components = ctx. components . clone ( ) ;
106149
107150 // set up Signet Node storage
@@ -148,10 +191,36 @@ impl SignetTestContext {
148191
149192 let alias_oracle: Arc < Mutex < HashSet < Address > > > = Arc :: new ( Mutex :: new ( HashSet :: default ( ) ) ) ;
150193
194+ // Create the test host notifier channel
195+ let ( sender, receiver) = mpsc:: unbounded_channel ( ) ;
196+ let notifier = TestHostNotifier { receiver } ;
197+
198+ // Build the blob cacher from the reth test pool
199+ let blob_cacher = signet_blobber:: BlobFetcher :: builder ( )
200+ . with_config ( cfg. block_extractor ( ) )
201+ . unwrap ( )
202+ . with_pool ( components. pool ( ) . clone ( ) )
203+ . with_client ( reqwest:: Client :: new ( ) )
204+ . build_cache ( )
205+ . unwrap ( )
206+ . spawn ( ) ;
207+
208+ // Build ServeConfig from the test config's IPC endpoint
209+ let serve_config = ServeConfig {
210+ http : vec ! [ ] ,
211+ http_cors : None ,
212+ ws : vec ! [ ] ,
213+ ws_cors : None ,
214+ ipc : cfg. ipc_endpoint ( ) . map ( ToOwned :: to_owned) ,
215+ } ;
216+
151217 let ( node, mut node_status) = SignetNodeBuilder :: new ( cfg. clone ( ) )
152- . with_ctx ( ctx )
218+ . with_notifier ( notifier )
153219 . with_storage ( Arc :: clone ( & storage) )
154220 . with_alias_oracle ( Arc :: clone ( & alias_oracle) )
221+ . with_blob_cacher ( blob_cacher)
222+ . with_serve_config ( serve_config)
223+ . with_rpc_config ( StorageRpcConfig :: default ( ) )
155224 . build ( )
156225 . await
157226 . unwrap ( ) ;
@@ -179,7 +248,7 @@ impl SignetTestContext {
179248 . unwrap ( ) ;
180249
181250 let this = Self {
182- handle ,
251+ sender ,
183252 components,
184253 node_status,
185254 storage,
@@ -284,7 +353,8 @@ impl SignetTestContext {
284353 assert ! ( pool. get_blob( tx_hash) . unwrap( ) . is_some( ) , "Missing blob we just inserted" ) ;
285354 }
286355
287- self . handle . notifications_tx . send ( notification. notification . to_reth ( ) ) . await . unwrap ( ) ;
356+ let host_notification = to_host_notification ( & notification. notification ) ;
357+ self . sender . send ( host_notification) . unwrap ( ) ;
288358 }
289359
290360 /// Send a notification to the Signet Node instance and wait for it to be
0 commit comments