|
1 | 1 | use signet_constants::test_utils::*; |
2 | 2 | use trevm::revm::{ |
3 | 3 | context::CfgEnv, database::in_memory_db::InMemoryDB, primitives::hardfork::SpecId, |
| 4 | + state::Bytecode, |
4 | 5 | }; |
5 | 6 |
|
6 | | -/// Create a new Signet EVM with an in-memory database for testing. |
| 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 | + }, |
| 14 | +}; |
| 15 | + |
| 16 | +/// Create a new Signet EVM with an in-memory database for testing. Deploy |
| 17 | +/// system contracts and pre-deployed tokens. |
7 | 18 | pub fn test_signet_evm() -> signet_evm::EvmNeedsBlock<InMemoryDB> { |
8 | | - signet_evm::signet_evm(InMemoryDB::default(), TEST_SYS).fill_cfg(&TestCfg) |
| 19 | + let mut evm = signet_evm::signet_evm(InMemoryDB::default(), TEST_SYS).fill_cfg(&TestCfg); |
| 20 | + |
| 21 | + // Set the bytecode for system contracts |
| 22 | + evm.set_bytecode_unchecked(TEST_SYS.ru_orders(), Bytecode::new_legacy(RU_ORDERS_BYTECODE)); |
| 23 | + evm.set_bytecode_unchecked(TEST_SYS.ru_passage(), Bytecode::new_legacy(RU_PASSAGE_BYTECODE)); |
| 24 | + |
| 25 | + // Set WBTC bytecode and storage |
| 26 | + evm.set_bytecode_unchecked(RU_WBTC, Bytecode::new_legacy(TOKEN_BYTECODE)); |
| 27 | + evm.set_storage_unchecked(RU_WBTC, NAME_SLOT, WBTC_NAME); |
| 28 | + evm.set_storage_unchecked(RU_WBTC, SYMBOL_SLOT, WBTC_SYMBOL); |
| 29 | + evm.set_storage_unchecked(RU_WBTC, MINTER_SLOT, MINTER); |
| 30 | + |
| 31 | + // Set WETH bytecode and storage |
| 32 | + evm.set_bytecode_unchecked(RU_WETH, Bytecode::new_legacy(TOKEN_BYTECODE)); |
| 33 | + evm.set_storage_unchecked(RU_WETH, NAME_SLOT, WETH_NAME); |
| 34 | + evm.set_storage_unchecked(RU_WETH, SYMBOL_SLOT, WETH_SYMBOL); |
| 35 | + evm.set_storage_unchecked(RU_WETH, MINTER_SLOT, MINTER); |
| 36 | + |
| 37 | + // Set the bytecode for the Counter contract |
| 38 | + evm.set_bytecode_unchecked(COUNTER_TEST_ADDRESS, Bytecode::new_legacy(COUNTER_BYTECODE)); |
| 39 | + |
| 40 | + evm |
9 | 41 | } |
10 | 42 |
|
11 | 43 | /// Test configuration for the Signet EVM. |
|
0 commit comments