@@ -2348,41 +2348,29 @@ where
23482348
23492349#[ cfg( test) ]
23502350mod tests {
2351- use std:: sync:: LazyLock ;
2352-
2353- use alloy:: network:: { TransactionBuilder , TransactionBuilder7702 } ;
2354- use alloy:: rpc:: types:: Authorization ;
2355- use alloy:: signers:: k256:: ecdsa:: SigningKey ;
2356- use alloy:: signers:: local:: PrivateKeySigner ;
2357- use alloy:: signers:: SignerSync ;
2358- use alloy:: { consensus:: constants:: ETH_TO_WEI , rpc:: types:: TransactionRequest } ;
2359-
2360- use revm:: context:: transaction:: AuthorizationTr ;
2361- use revm:: database:: InMemoryDB ;
2362- use revm:: inspector:: NoOpInspector ;
2363- use revm:: primitives:: bytes;
2364-
2365- use crate :: test_utils:: { test_trevm_with_funds, LOG_BYTECODE } ;
2366- use crate :: { EvmNeedsCfg , TrevmBuilder } ;
2367- use crate :: { NoopBlock , NoopCfg } ;
2368-
2351+ use alloy:: {
2352+ network:: { TransactionBuilder , TransactionBuilder7702 } ,
2353+ rpc:: types:: { Authorization , TransactionRequest } ,
2354+ signers:: SignerSync ,
2355+ consensus:: constants:: ETH_TO_WEI ,
2356+ } ;
2357+ use revm:: {
2358+ context:: transaction:: AuthorizationTr ,
2359+ database:: InMemoryDB ,
2360+ primitives:: bytes,
2361+ } ;
2362+ use crate :: {
2363+ test_utils:: { test_trevm_with_funds, ALICE , BOB , LOG_BYTECODE } ,
2364+ TrevmBuilder , NoopBlock , NoopCfg ,
2365+ } ;
23692366 use super :: * ;
23702367
2371- static ALICE : LazyLock < PrivateKeySigner > =
2372- LazyLock :: new ( || PrivateKeySigner :: from ( SigningKey :: from_slice ( & [ 0x11 ; 32 ] ) . unwrap ( ) ) ) ;
2373- static BOB : LazyLock < PrivateKeySigner > =
2374- LazyLock :: new ( || PrivateKeySigner :: from ( SigningKey :: from_slice ( & [ 0x22 ; 32 ] ) . unwrap ( ) ) ) ;
2375-
2376- fn trevm_with_funds ( ) -> EvmNeedsCfg < InMemoryDB , NoOpInspector > {
2377- test_trevm_with_funds ( & [
2378- ( ALICE . address ( ) , U256 :: from ( ETH_TO_WEI ) ) ,
2379- ( BOB . address ( ) , U256 :: from ( ETH_TO_WEI ) ) ,
2380- ] )
2381- }
2382-
23832368 #[ test]
23842369 fn test_estimate_gas_simple_transfer ( ) {
2385- let trevm = trevm_with_funds ( ) ;
2370+ let trevm = test_trevm_with_funds ( & [
2371+ ( ALICE . address ( ) , U256 :: from ( ETH_TO_WEI ) ) ,
2372+ ( BOB . address ( ) , U256 :: from ( ETH_TO_WEI ) ) ,
2373+ ] ) ;
23862374
23872375 let tx = TransactionRequest :: default ( )
23882376 . from ( ALICE . address ( ) )
@@ -2394,7 +2382,7 @@ mod tests {
23942382
23952383 assert ! ( estimation. is_success( ) ) ;
23962384 // The gas used should correspond to a simple transfer.
2397- assert ! ( estimation. gas_used( ) == 21000 ) ;
2385+ assert_eq ! ( estimation. gas_used( ) , 21000 ) ;
23982386 }
23992387
24002388 #[ test]
@@ -2418,7 +2406,7 @@ mod tests {
24182406 } ;
24192407 let signature = BOB . sign_hash_sync ( & authorization. signature_hash ( ) ) . unwrap ( ) ;
24202408 let signed_authorization = authorization. into_signed ( signature) ;
2421- assert ! ( signed_authorization. authority( ) . unwrap( ) == BOB . address( ) ) ;
2409+ assert_eq ! ( signed_authorization. authority( ) . unwrap( ) , BOB . address( ) ) ;
24222410
24232411 let tx = TransactionRequest :: default ( )
24242412 . from ( ALICE . address ( ) )
@@ -2429,19 +2417,14 @@ mod tests {
24292417 let ( estimation, trevm) =
24302418 trevm. fill_cfg ( & NoopCfg ) . fill_block ( & NoopBlock ) . fill_tx ( & tx) . estimate_gas ( ) . unwrap ( ) ;
24312419
2432- dbg ! ( & estimation) ;
24332420 assert ! ( estimation. is_success( ) ) ;
24342421
24352422 let tx = tx. with_gas_limit ( estimation. limit ( ) ) ;
24362423
2437- let mut output = trevm. clear_tx ( ) . fill_tx ( & tx) . run ( ) . unwrap ( ) . accept ( ) ;
2438-
2439- let bob_code = output. 1 . read_code ( BOB . address ( ) ) ;
2440- dbg ! ( & bob_code) ;
2424+ let output = trevm. clear_tx ( ) . fill_tx ( & tx) . run ( ) . unwrap ( ) . accept ( ) ;
24412425
2442- dbg ! ( & output. 0 ) ;
24432426 assert ! ( output. 0 . is_success( ) ) ;
2444- assert ! ( output. 0 . logs( ) . len( ) == 1 ) ;
2427+ assert_eq ! ( output. 0 . logs( ) . len( ) , 1 ) ;
24452428 }
24462429}
24472430
0 commit comments