@@ -14,13 +14,16 @@ use serial_test::serial;
1414use signet_db:: { DbSignetEvent , SignetEvents } ;
1515use signet_node_tests:: {
1616 HostBlockSpec , SignetTestContext ,
17- aliases:: { Counter , TestCounterInstance } ,
1817 constants:: { DEFAULT_REWARD_ADDRESS , TEST_CONSTANTS } ,
1918 run_test,
19+ types:: { Counter , TestCounterInstance } ,
2020 utils:: { adjust_usd_decimals, adjust_usd_decimals_u256} ,
2121} ;
2222use signet_test_utils:: { chain:: USDC_RECORD , contracts:: counter:: COUNTER_BYTECODE } ;
23- use signet_types:: constants:: { HostPermitted , RollupPermitted } ;
23+ use signet_types:: {
24+ constants:: { HostPermitted , RollupPermitted } ,
25+ unalias_address,
26+ } ;
2427use signet_zenith:: { MINTER_ADDRESS , Passage , Transactor , mintCall} ;
2528
2629alloy:: sol! {
@@ -207,31 +210,44 @@ async fn test_transact() {
207210 run_test ( |ctx| async move {
208211 // set up user
209212 let user = ctx. addresses [ 0 ] ;
213+
214+ // Getting a little cute here. We ensure that the ALIASED version is
215+ // one of the standard test addresses, so we don't have to set up any
216+ // extra accounts.
217+ let aliased = ctx. addresses [ 1 ] ;
218+ let host_contract = unalias_address ( aliased) ;
219+
220+ // Indicate to the block processor that this address should be aliased
221+ ctx. set_should_alias ( host_contract, true ) ;
222+
210223 let mut user_nonce = ctx. track_nonce ( user, Some ( "user" ) ) ;
211224 let mut user_bal = ctx. track_balance ( user, Some ( "user" ) ) ;
212225
226+ let mut aliased_nonce = ctx. track_nonce ( aliased, Some ( "aliased" ) ) ;
227+ let mut aliased_bal = ctx. track_balance ( aliased, Some ( "aliased" ) ) ;
228+
213229 // Deploy a contract to interact with
214- let deployer = ctx. addresses [ 1 ] ;
230+ let deployer = ctx. addresses [ 2 ] ;
215231
216232 // Assert that the counter is zero
217233 let contract = ctx. deploy_counter ( deployer) . await ;
218234 let contract_addr = * contract. address ( ) ;
219235 assert_eq ! ( contract. count( ) . call( ) . await . unwrap( ) , U256 :: ZERO ) ;
220236
221237 // Transact that calls the context and increments it.
222- let block = HostBlockSpec :: new ( ctx. constants ( ) ) . simple_transact (
223- user,
224- contract_addr,
225- Counter :: incrementCall:: SELECTOR ,
226- 0 ,
227- ) ;
238+ let block = HostBlockSpec :: new ( ctx. constants ( ) )
239+ . simple_transact ( user, contract_addr, Counter :: incrementCall:: SELECTOR , 0 )
240+ . simple_transact ( host_contract, contract_addr, Counter :: incrementCall:: SELECTOR , 0 ) ;
228241
229242 ctx. process_block ( block) . await . unwrap ( ) ;
230243
231244 user_nonce. assert_incremented ( ) ;
232245 user_bal. assert_decrease ( ) ;
233246
234- assert_eq ! ( contract. count( ) . call( ) . await . unwrap( ) , U256 :: from( 1 ) ) ;
247+ aliased_nonce. assert_incremented ( ) ;
248+ aliased_bal. assert_decrease ( ) ;
249+
250+ assert_eq ! ( contract. count( ) . call( ) . await . unwrap( ) , U256 :: from( 2 ) ) ;
235251
236252 // check the RPC response
237253 let block = ctx
@@ -258,6 +274,20 @@ async fn test_transact() {
258274 assert_eq ! ( transact_tx. to( ) . unwrap( ) , contract_addr) ;
259275 assert_eq ! ( transact_tx. value( ) , U256 :: ZERO ) ;
260276 assert_eq ! ( transact_tx. input( ) , & Bytes :: from( Counter :: incrementCall:: SELECTOR ) ) ;
277+
278+ let aliased_transact_tx = & txns[ 1 ] ;
279+ assert_eq ! ( aliased_transact_tx. from( ) , aliased) ;
280+ assert_eq ! ( aliased_transact_tx. to( ) . unwrap( ) , contract_addr) ;
281+ assert_eq ! ( aliased_transact_tx. value( ) , U256 :: ZERO ) ;
282+ assert_eq ! ( aliased_transact_tx. input( ) , & Bytes :: from( Counter :: incrementCall:: SELECTOR ) ) ;
283+
284+ let aliased_tx_hash = aliased_transact_tx. tx_hash ( ) ;
285+ let aliased_transact_tx =
286+ ctx. alloy_provider . get_transaction_by_hash ( aliased_tx_hash) . await . unwrap ( ) . unwrap ( ) ;
287+ assert_eq ! ( aliased_transact_tx. from( ) , aliased) ;
288+ assert_eq ! ( aliased_transact_tx. to( ) . unwrap( ) , contract_addr) ;
289+ assert_eq ! ( aliased_transact_tx. value( ) , U256 :: ZERO ) ;
290+ assert_eq ! ( aliased_transact_tx. input( ) , & Bytes :: from( Counter :: incrementCall:: SELECTOR ) ) ;
261291 } )
262292 . await ;
263293}
0 commit comments