1- use signet_constants:: test_utils:: * ;
2- use trevm:: revm:: {
3- context:: CfgEnv , database:: in_memory_db:: InMemoryDB , primitives:: hardfork:: SpecId ,
4- state:: Bytecode ,
1+ use crate :: {
2+ contracts:: {
3+ counter:: { COUNTER_BYTECODE , COUNTER_TEST_ADDRESS } ,
4+ reverts:: { REVERT_BYTECODE , REVERT_TEST_ADDRESS } ,
5+ system:: { RU_ORDERS_BYTECODE , RU_PASSAGE_BYTECODE } ,
6+ token:: {
7+ MINTER , MINTER_SLOT , NAME_SLOT , SYMBOL_SLOT , TOKEN_BYTECODE , WBTC_NAME , WBTC_SYMBOL ,
8+ WETH_NAME , WETH_SYMBOL ,
9+ } ,
10+ } ,
11+ users:: TEST_USERS ,
512} ;
6-
7- use crate :: contracts :: {
8- counter :: { COUNTER_BYTECODE , COUNTER_TEST_ADDRESS } ,
9- system :: { RU_ORDERS_BYTECODE , RU_PASSAGE_BYTECODE } ,
10- token :: {
11- MINTER , MINTER_SLOT , NAME_SLOT , SYMBOL_SLOT , TOKEN_BYTECODE , WBTC_NAME , WBTC_SYMBOL ,
12- WETH_NAME , WETH_SYMBOL ,
13+ use alloy :: { consensus :: constants :: ETH_TO_WEI , primitives :: U256 } ;
14+ use signet_constants :: test_utils :: * ;
15+ use trevm :: {
16+ helpers :: Ctx ,
17+ revm :: {
18+ context :: CfgEnv , database :: in_memory_db :: InMemoryDB , inspector :: NoOpInspector ,
19+ primitives :: hardfork :: SpecId , state :: Bytecode , Inspector ,
1320 } ,
1421} ;
1522
16- /// Create a new Signet EVM with an in-memory database for testing. Deploy
17- /// system contracts and pre-deployed tokens.
23+ /// Create a new Signet EVM with an in-memory database for testing.
24+ ///
25+ /// Performs initial setup to
26+ /// - Deploy [`RU_ORDERS`] and and [`RU_PASSAGE`] system contracts
27+ /// - Deploy a [`COUNTER`] contract for testing at [`COUNTER_TEST_ADDRESS`].
28+ /// - Deploy Token contracts for WBTC and WETH with their respective bytecodes
29+ /// and storage.
30+ /// - Deploy a `Revert` contract for testing at [`REVERT_TEST_ADDRESS`].
31+ /// - Fund the [`TEST_USERS`] with 1000 ETH each.
32+ ///
33+ /// [`COUNTER`]: crate::contracts::counter::Counter
1834pub fn test_signet_evm ( ) -> signet_evm:: EvmNeedsBlock < InMemoryDB > {
19- let mut evm = signet_evm:: signet_evm ( InMemoryDB :: default ( ) , TEST_SYS ) . fill_cfg ( & TestCfg ) ;
35+ test_signet_evm_with_inspector ( NoOpInspector )
36+ }
37+
38+ /// Create a new Signet EVM with an in-memory database for testing.
39+ ///
40+ /// Performs initial setup to
41+ /// - Deploy [`RU_ORDERS`] and and [`RU_PASSAGE`] system contracts
42+ /// - Deploy a [`COUNTER`] contract for testing at [`COUNTER_TEST_ADDRESS`].
43+ /// - Deploy Token contracts for WBTC and WETH with their respective bytecodes
44+ /// and storage.
45+ /// - Deploy a `Revert` contract for testing at [`REVERT_TEST_ADDRESS`].
46+ /// - Fund the [`TEST_USERS`] with 1000 ETH each.
47+ ///
48+ /// [`COUNTER`]: crate::contracts::counter::Counter
49+ pub fn test_signet_evm_with_inspector < I > ( inspector : I ) -> signet_evm:: EvmNeedsBlock < InMemoryDB , I >
50+ where
51+ I : Inspector < Ctx < InMemoryDB > > ,
52+ {
53+ let mut evm = signet_evm:: signet_evm_with_inspector ( InMemoryDB :: default ( ) , inspector, TEST_SYS )
54+ . fill_cfg ( & TestCfg ) ;
2055
2156 // Set the bytecode for system contracts
2257 evm. set_bytecode_unchecked ( TEST_SYS . ru_orders ( ) , Bytecode :: new_legacy ( RU_ORDERS_BYTECODE ) ) ;
@@ -37,6 +72,14 @@ pub fn test_signet_evm() -> signet_evm::EvmNeedsBlock<InMemoryDB> {
3772 // Set the bytecode for the Counter contract
3873 evm. set_bytecode_unchecked ( COUNTER_TEST_ADDRESS , Bytecode :: new_legacy ( COUNTER_BYTECODE ) ) ;
3974
75+ // Set the bytecode for the Revert contract
76+ evm. set_bytecode_unchecked ( REVERT_TEST_ADDRESS , Bytecode :: new_legacy ( REVERT_BYTECODE ) ) ;
77+
78+ // increment the balance for each test signer
79+ TEST_USERS . iter ( ) . copied ( ) . for_each ( |user| {
80+ evm. set_balance_unchecked ( user, U256 :: from ( 1000 * ETH_TO_WEI ) ) ;
81+ } ) ;
82+
4083 evm
4184}
4285
0 commit comments