Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit cd35d7b

Browse files
authored
testool: upgrade testool/tests (#511)
* Update `testool/tests` to latest `develop` branch. * Add `Shanghai` network. * Set to `Ref::Any` if missing fields of `expected["indexes"]`. * Skip test files failed to parse from json or yaml. * Sync fixes (init code gas in begin TX and some test cases) from upstream PR-1424 (running all test cases with `shanghai` feature). * Fix wrong stack operations of `PUSH0`. * Fix `testool` dependency issue. * Update `max_copy_rows` from `55000` to `65472` in `testool`. * Fix to network `Shanghai` if shanghai feature is enabled. * Comment out copy-circuit-test. * Return as invalid opcodes for `TLOAD` and `TSTORE`. * Revert "Comment out copy-circuit-test." This reverts commit 48859e1. * Revert "Update `max_copy_rows` from `55000` to `65472` in `testool`." This reverts commit afcdbbb.
1 parent e8aecb6 commit cd35d7b

File tree

15 files changed

+178
-42
lines changed

15 files changed

+178
-42
lines changed

bus-mapping/src/evm/opcodes.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ mod mload;
4949
mod mstore;
5050
mod number;
5151
mod origin;
52+
mod push0;
5253
mod return_revert;
5354
mod returndatacopy;
5455
mod returndatasize;
@@ -110,6 +111,7 @@ use logs::Log;
110111
use mload::Mload;
111112
use mstore::Mstore;
112113
use origin::Origin;
114+
use push0::Push0;
113115
use return_revert::ReturnRevert;
114116
use returndatacopy::Returndatacopy;
115117
use returndatasize::Returndatasize;
@@ -158,7 +160,7 @@ fn fn_gen_associated_ops(opcode_id: &OpcodeId) -> FnGenAssociatedOps {
158160
}
159161

160162
match opcode_id {
161-
OpcodeId::PUSH0 => StackOnlyOpcode::<0, 0>::gen_associated_ops,
163+
OpcodeId::PUSH0 => Push0::gen_associated_ops,
162164
OpcodeId::STOP => Stop::gen_associated_ops,
163165
OpcodeId::ADD => StackOnlyOpcode::<2, 1>::gen_associated_ops,
164166
OpcodeId::MUL => StackOnlyOpcode::<2, 1>::gen_associated_ops,
@@ -527,13 +529,24 @@ pub fn gen_begin_tx_ops(
527529
)?;
528530
}
529531

532+
// Calculate gas cost of init code only for EIP-3860 of Shanghai.
533+
#[cfg(feature = "shanghai")]
534+
let init_code_gas_cost = if state.tx.is_create() {
535+
(state.tx.input.len() as u64 + 31) / 32 * eth_types::evm_types::INIT_CODE_WORD_GAS
536+
} else {
537+
0
538+
};
539+
#[cfg(not(feature = "shanghai"))]
540+
let init_code_gas_cost = 0;
541+
530542
// Calculate intrinsic gas cost
531543
let call_data_gas_cost = tx_data_gas_cost(&state.tx.input);
532544
let intrinsic_gas_cost = if state.tx.is_create() {
533545
GasCost::CREATION_TX.as_u64()
534546
} else {
535547
GasCost::TX.as_u64()
536-
} + call_data_gas_cost;
548+
} + call_data_gas_cost
549+
+ init_code_gas_cost;
537550
exec_step.gas_cost = GasCost(intrinsic_gas_cost);
538551

539552
// Get code_hash of callee

bus-mapping/src/evm/opcodes/extcodesize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ mod extcodesize_tests {
100100
geth_types::{Account, GethData},
101101
Bytecode, U256,
102102
};
103-
use mock::{TestContext, MOCK_1_ETH, MOCK_ACCOUNTS, MOCK_CODES};
103+
use mock::{TestContext, MOCK_1_ETH, MOCK_ACCOUNTS, MOCK_CODES, MOCK_COINBASE};
104104
use pretty_assertions::assert_eq;
105105

106106
#[test]
@@ -154,7 +154,7 @@ mod extcodesize_tests {
154154
|mut txs, accs| {
155155
txs[0].to(accs[0].address).from(accs[2].address);
156156
},
157-
|block, _tx| block.number(0xcafeu64),
157+
|block, _tx| block.author(*MOCK_COINBASE).number(0xcafeu64),
158158
)
159159
.unwrap()
160160
.into();

bus-mapping/src/evm/opcodes/push0.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use super::Opcode;
2+
use crate::{
3+
circuit_input_builder::{CircuitInputStateRef, ExecStep},
4+
Error,
5+
};
6+
use eth_types::{GethExecStep, U256};
7+
8+
#[derive(Clone, Copy, Debug)]
9+
pub(crate) struct Push0;
10+
11+
impl Opcode for Push0 {
12+
fn gen_associated_ops(
13+
state: &mut CircuitInputStateRef,
14+
geth_steps: &[GethExecStep],
15+
) -> Result<Vec<ExecStep>, Error> {
16+
let geth_step = &geth_steps[0];
17+
let mut exec_step = state.new_step(geth_step)?;
18+
19+
state.stack_write(
20+
&mut exec_step,
21+
geth_steps[1].stack.last_filled(),
22+
U256::zero(),
23+
)?;
24+
25+
Ok(vec![exec_step])
26+
}
27+
}

eth-types/src/evm_types.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,20 @@ mod gas_create {
8686

8787
/// Maximum init code size to permit in a creation transaction and create instructions.
8888
pub const MAX_INIT_CODE_SIZE: u64 = 2 * super::MAX_CODE_SIZE;
89-
/// Gas per init code word of CREATE when creating a contract.
90-
pub const CREATE_GAS_PER_CODE_WORD: u64 = 2;
91-
/// Gas per init code word of CREATE2 when creating a contract.
92-
pub const CREATE2_GAS_PER_CODE_WORD: u64 =
93-
CREATE_GAS_PER_CODE_WORD + super::GasCost::COPY_SHA3.0;
89+
/// Once per word of the init code when creating a contract.
90+
pub const INIT_CODE_WORD_GAS: u64 = 2;
91+
/// Gas per code word for CREATE.
92+
pub const CREATE_GAS_PER_CODE_WORD: u64 = INIT_CODE_WORD_GAS;
93+
/// Gas per code word for CREATE2.
94+
pub const CREATE2_GAS_PER_CODE_WORD: u64 = INIT_CODE_WORD_GAS + super::GasCost::COPY_SHA3.0;
9495
}
9596
#[cfg(not(feature = "shanghai"))]
9697
mod gas_create {
9798
/// Maximum init code size (0x1FFFFFFFE0) if not EIP-3860.
9899
pub use super::MAX_EXPANDED_MEMORY_ADDRESS as MAX_INIT_CODE_SIZE;
99-
/// Gas per init code word of CREATE if not EIP-3860.
100+
/// Gas per code word for CREATE if not EIP-3860.
100101
pub const CREATE_GAS_PER_CODE_WORD: u64 = 0;
101-
/// Gas per init code word of CREATE2 if not EIP-3860.
102+
/// Gas per code word for CREATE2 if not EIP-3860.
102103
pub const CREATE2_GAS_PER_CODE_WORD: u64 = super::GasCost::COPY_SHA3.0;
103104
}
104105
pub use gas_create::*;

eth-types/src/evm_types/opcode_ids.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,8 @@ impl FromStr for OpcodeId {
12301230
"SELFDESTRUCT" => OpcodeId::SELFDESTRUCT,
12311231
"CHAINID" => OpcodeId::CHAINID,
12321232
"BASEFEE" => OpcodeId::BASEFEE,
1233+
"TLOAD" => OpcodeId::INVALID(0xb3),
1234+
"TSTORE" => OpcodeId::INVALID(0xb4),
12331235
_ => {
12341236
// Parse an invalid opcode value as reported by geth
12351237
lazy_static! {

testool/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ ctor = "0.1.22"
4141
default = ["ignore-test-docker", "skip-self-destruct"]
4242
ignore-test-docker = []
4343
skip-self-destruct = []
44-
shanghai = ["eth-types/shanghai"]
44+
shanghai = ["bus-mapping/shanghai", "eth-types/shanghai", "mock/shanghai", "zkevm-circuits/shanghai"]

testool/Config.toml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ paths = [
184184
"EIP1559",
185185
"EIP2930",
186186
"stPreCompiledContracts",
187-
"stZeroKnowledge"
187+
"stZeroKnowledge"
188188
]
189189

190190
[[skip_paths]]
@@ -219,14 +219,36 @@ paths = [
219219
desc = "bad json"
220220
paths = [
221221
"Opcodes_TransactionInitFiller",
222-
"static_CallContractToCreateContractAndCallItOOGFiller.json",
222+
"static_CallContractToCreateContractAndCallItOOGFiller.json",
223223
"dummyFiller.json",
224224
"codesizeOOGInvalidSizeFiller.json",
225225
"codesizeValidFiller.json",
226226
"create2callPrecompilesFiller.json",
227227
"callToNonExistentFiller.json",
228228
"tackDepthLimitSECFiller.json",
229-
"ValueOverflowFiller" # weird 0x:biginteger 0x...
229+
"ValueOverflowFiller", # weird 0x:biginteger 0x...
230+
"result_mergeEnvConvertionFiller.json" # missing `currentDifficulty`
231+
]
232+
233+
[[skip_paths]]
234+
desc = "wrong //comment"
235+
paths = [
236+
"CREATE_EContract_ThenCALLToNonExistentAccFiller.json",
237+
"CREATE_EmptyContractFiller.json",
238+
"CreateAndGasInsideCreateFiller.json",
239+
"StoreGasOnCreateFiller.json",
240+
"static_CREATE_EmptyContractAndCallIt_0weiFiller.json",
241+
"static_CREATE_EmptyContractWithStorageAndCallIt_0weiFiller.json"
242+
]
243+
244+
[[skip_paths]]
245+
desc = "bad yml"
246+
paths = [
247+
"CreateAddressWarmAfterFailFiller.yml", # Odd number
248+
"HighGasPriceFiller.yml", # Wrong network EIP158
249+
"doubleSelfdestructTestFiller.yml", # character is not in the range 0-9
250+
"eoaEmptyFiller.yml", # cannot parse to address Integer(49374)
251+
"touchAndGoFiller.yml" # Wrong network EIP150
230252
]
231253

232254
[[skip_paths]]

testool/codehash.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,3 +2896,37 @@ c4bf5ad3a96e11d4a794acd75d486639b5cf225f871db8d20d56123b23f526d4=600060006000600
28962896
d8a56c290ee5169eb894f0fa07066821d23f5f3d40b071d6e0d6c7afb282fe37=5a6000556000600060006000600073c94f5374fce5edbc8e2a8697c15331677e6ebf0b61ea60f2600155600160645500
28972897
abd7afc4a0b5580e7dc271b92f328b8e6996a971d6cf6612cb392fa447f2709f=5a6000556000600060006000600073c94f5374fce5edbc8e2a8697c15331677e6ebf0b61ea60f1600155600160645500
28982898
9555f80f23ad28f27a451dcf714ba3ca9508c507d16c2f5c74f9e9d991b51ec2=5a600055600060006000600073c94f5374fce5edbc8e2a8697c15331677e6ebf0b61ea60f4600155600160645500
2899+
681a49d6032393d3f7b5f66cad1e2c029ac72708b3c84e3ce94174d99d7fbc06=600435606481610100811460295761020081146033576103008114603d576104008114604757604e565b601b82019150604e565b601b82019150604e565b601882019150604e565b6018820191505b50600060006000600060008686f16000555050
2900+
e5c6a102b383b20ce844126abb7d0bf51fea53914c23ff516cd9e6cb2188e0cb=4160006000600060006000856000f15050
2901+
c65e9a13daad46d0fb23c588c7ecb5ee3a807bf026711736ca0638314fc2c49c=4160006000600060006000856000f25050
2902+
304e4e2c9002c9663b1f664e3501f04a6b8aab9fb8e0d251afe05408c897daab=416000600060006000846000f45050
2903+
bdbc1d342b1d78c86d9db1b2908f7f01f274e5e44bb72405e510bf331ca42215=416000600060006000846000fa5050
2904+
f9a198ad793eac53f4b61e27bc123cd9747944ba3b658a345ee0fdc341816cfe=416000600060006000600435600081146100555760018114610068576002811461007f576003811461009257600481146100a557600581146100c557600681146100e557600781146101035760006000fd61011d565b600f94505a9350853b91505a925061011d565b601394505a9350600060006000883c5a925061011d565b600f94505a9350853f91505a925061011d565b600f94505a9350853191505a925061011d565b602194505a9350600060006000600060008a612710f191505a925061011d565b602194505a9350600060006000600060008a612710f291505a925061011d565b601e94505a9350600060006000600089612710f491505a925061011d565b601e94505a9350600060006000600089612710fa91505a92505b5083828403036000558060005260206000f35050505050
2905+
20e0c8522d1ee40a0d9dec99efc5a681e5f80940425015ae9ad90a740a9d6f0e=6000600060006000600060003560601c620186a0f16000556001600155
2906+
d3fc50b752fe68e25ea648ef935fd4163c77b7d6c027dc50915a20d989424529=6000600060006000610600620186a0fa600055600160015560016000601f3e600051600255
2907+
625c7b72397db0ffa1e8435286765d34a367dfaf0c486d0ad3cd57e59f19e20f=60003560005260006000366000600073c94f5374fce5edbc8e2a8697c15331677e6ebf0b62989680f180600055600160015550
2908+
f0c8600835d1911fdce3f30d919a430be6d79f9cf8e0b58dbc1aeeaec0240ca4=7f600a80600080396000f3000000000000000000000000000000000000000000006000526000355a63deadbeef8260006000f55a8203600a5580600055505050
2909+
2c2982f5372d0bb97d234f16210ecdf8e6ff9275eb34d60af05dab73a6193ba8=7f600a80600080396000f3000000000000000000000000000000000000000000006000526000355a8160006000f05a8203600a5580600055505050
2910+
4a90717be1f980c85df639b05b68eddbf5b145580e6be46571ec240e9c011aa9=60006000600060006000620e49716000f150
2911+
0c1f1c2b53e6b6a0c7732ff85e9be54e3f4421012fe9364c43268a3aefa5e714=6000600060006000600073c94f5374fce5edbc8e2a8697c15331677e6ebf0b61ea60f1506d64600c6000556000526005601bf360005230ff00
2912+
c6e6289d3df9eee3cd49859604c2fd45c6d1adaf41ae4012a3a40bf33375d3cf=600435803b8060006000843c60008160006000f56000811415601d57fe5b505050
2913+
80b052c61922130b07920f828df50ca6e85735f47eb794ac1aab2ce3549d3b6e=6000600155
2914+
c78f04d5c2fe4b0b5de799a5b363c9b1a4e1ac325105ef0a7f074ff3dc37ee20=600435600060006002600360046005600a600c600d600e600f63dead60a78a5563dead60a7895563dead60a7885563dead60a7875563dead60a7865563dead60a7845563dead60a7835563dead60a7825563dead60a7815573d4e7ae083132925a4927c1f5816238ba17b82a0060008d600081146100f157600a8114610120576001811461016e57600b811461019d57600281146101ce57600c81146101fd576003811461024b576004811461027c57600581146102ae57600d81146102e057600e81146103125760068114610345576010811461037457600781146103a557601181146103d45760006000fd610402565b73d4e7ae083132925a4927c1f5816238ba17b82a65915060059d508d6104746000398d60006000f08d55610402565b7343255ee039968e0254887fc8c7172736983d878c915060059d507f60006000fd00000000000000000000000000000000000000000000000000000060005260008e60006000f58d55610402565b73d4e7ae083132925a4927c1f5816238ba17b82a65915060069d508d6104796000398d60006000f08d55610402565b73014001fdbede82315f4b8c2a7d45e980a8a4a12e915060069d508d61047f60003960008e60006000f58d55610402565b73d4e7ae083132925a4927c1f5816238ba17b82a65915060069d508d6104856000398d60006000f08d55610402565b73a13d43586820e5d97a3fd1960625d537c86dc4e7915060069d507ffe60106000f3000000000000000000000000000000000000000000000000000060005260008e60006000f58d55610402565b73a5a6a95fd9554f15ab6986a57519092be209512591506000600060006000600063c0de1006617000f18d55610402565b73a5a6a95fd9554f15ab6986a57519092be209512591506000600060006000600063c0de100662010000f18d55610402565b73b2050fc27ab6d6d42dc0ce6f7c0bf9481a4c3fc391506000600060006000600063c0deffff62010000f18d55610402565b73d70df326038a3c7ca8fac785a99162bfe75ccc469150600060006000600060006420c0de1006617000f18d55610402565b73d70df326038a3c7ca8fac785a99162bfe75ccc469150600060006000600060006420c0de100662010000f18d55610402565b73d4e7ae083132925a4927c1f5816238ba17b82a659150600a9d508d61048b6000398d60006000f08d55610402565b73562d97e3e4d6d3c6e791ea64bb73d820871aa2199150600a9d508d61049560003960008e60006000f58d55610402565b73d4e7ae083132925a4927c1f5816238ba17b82a65915060059d508d61049f6000398d60006000f08d55610402565b73f7fef4b66b1570a057d7d5cec5c58846befa5b5c915060059d508d6104a4600039615a178e60006000f58d555b505a8655600060006000600034856000f18b555a86540386555a8555600060006000600034856000f18a555a85540385555a8455600060006000600034866000f189555a84540384555a8355600060006000600034866000f188555a8354038355005050505050505050505050505050fe60006000fd6160016000f36160016000f3fe60106000f360ef60005360106000f360ef60005360106000f360016000f360016000f3
2915+
d41a5cb154439a603969d9388d522b67da0cd0cd489ed7d4612d816d6766ed0d=60066013600039600660006000f060005500fe6160006000f3
2916+
b6b8245a2b6a60ddd42fd3a50292cf759e511be8ef3bb4ffbaeb561fc26c3cff=600660156000396000600660006000f560005500fe6160006000f3
2917+
49a95bbf08e5d52b851318801d2303ce5d9e3478d1198b283575f034611422eb=60056013600039600560006000f060005500fe60206000f3
2918+
aafbf83c0f3710c167ebc33f27dceb2eb9d28abb1fb05c21e34b1f9e2233c6d8=600160005560016001556000600155620c0de1600f7f6001600055600060005560016000f3000000000000000000000000000000000060005260008160006000f550600160018201f35050
2919+
451c55c3eba6157da3ed475ff5c85c21b0bbed3ff08121e3e5e2d815dba5714d=600160005560016001556000600155620c0de1600f7f6001600055600060005560016000f3000000000000000000000000000000000060005260008160006000f550600160018201f35050
2920+
d2ade8c7069746243223af9eff36a334c9efc8fdd8d168858e7f987bd9074a05=60016000f3
2921+
2cc96cc353bd5672896c538ca7208099ed70b5b8f8f335428a751f655298a7ad=5a60015560043560243560443561c0de3b806000600061c0de3c826001820353816101005260008460f0811460395760f581146047576055565b61012060006000f091506055565b615a1761012060006000f591505b50806000555a60015403600155803f6002555050505050
2922+
7b6065bf0a39a0029168a47a75e335f270df1f36d3db2736e7d3d6b53ff44a36=5a6000356020600060006000600061010086f150815a106000556020600060006000600061010086f250815a10600155602060006020600061010085f450815a10600255602060006020600061010085fa50815a106003555050
2923+
3f5c413fc75d017c094476ccfe60240068d906fad96ec1552be536191129fd68=600160010160005500
2924+
e5c786ec740075936fbc7e1ee84d9ab75a38278663c27f7416374f5ded41a231=30ff00
2925+
fb4ae68eea4f15519fed2576f8457cce76fdb99ee4d9dfb5dcefb1703b811667=6061600053601060015360006002536060600353600060045360f3600553600660006000f050
2926+
c05ff5547d1cf7574622c35ebac92bb5aaaa7f48801cc882c3ee169afb498de6=6000600035126000600135128160005581600155816002558160035581600455816005558160065581600755816008558160095581600a5581600b5581600c5581600d5581600e5581600f5560008115605857617eea90505b6000821415606657617ee090505b6000600060006000600061c0de86f150505050
2927+
9fbaa879e71f83700a2ef45abdc3e546888dbb59c374cb1f683d6d58e4b96b35=32ff
2928+
0f27e05ea187e05f8d1414fea9d1cef952045895fa0ea1b9afcb067663c27238=32806000558031603155803b603b55803f603f55600181013f61013f5561bad13f61bad15561bad23f61bad25561bad33f61bad35561bad43f61bad4555a6000600060006000600435865af1505a810360f1555a90506000600060006000600061dead5af1505a810360ff555050
2929+
e8a7a68124e629036058991fac713b358337fe7412d37c3d9b89a331520d18b9=348060011c60006000600060008461dead62011170f181830360006000600060008461dead62011170f15050505050
2930+
7ebea5551401edbb59e83be5648bb70b08dec05208045272c020d206acf1a6c1=600054600181016000558062e4970101ff50
2931+
5a96de1b93928214fa164ae3487c73e2ac678feb29cd5bdbf107342152d30f1f=60003560f81c61ffff60003560e81c166000821415601957005b60ff82141560245780ff5b6000600060006000600086865af11415603d5760006000fd5b5050
2932+
c34ba972d8ae90026ee747e3e40f100666a67dbecaf1ea05faeb474b619bcb2e=600060ff600053601060015360006002536000600060036000600061dead5af19050806000556110003160015561dead3160025560003560f81c806001811461006c5760028114610082576003811461009857600481146100b357600581146100d35760006000fd6100ef565b6000600060036003600261dead5af192506100ef565b6000600060036000600261dead5af192506100ef565b60016002536000600060036000600261dead5af192506100ef565b600160005360016002536000600060036000600061dead5af192506100ef565b600160005360016002536000600060036000600261dead5af192505b50816010556110003160115561dead31601255611001316013555050

testool/src/statetest/json.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct AccountPre {
5555

5656
#[derive(Debug, Clone, Deserialize)]
5757
struct Expect {
58-
indexes: Indexes,
58+
indexes: Option<Indexes>,
5959
network: Vec<String>,
6060
result: HashMap<String, AccountPost>,
6161
}
@@ -144,9 +144,21 @@ impl<'a> JsonStateTestBuilder<'a> {
144144

145145
let mut expects = Vec::new();
146146
for expect in test.expect {
147-
let data_refs = Self::parse_refs(&expect.indexes.data)?;
148-
let gas_refs = Self::parse_refs(&expect.indexes.gas)?;
149-
let value_refs = Self::parse_refs(&expect.indexes.value)?;
147+
// Considered as Anys if missing `indexes`.
148+
let (data_refs, gas_refs, value_refs) = if let Some(indexes) = expect.indexes {
149+
(
150+
Self::parse_refs(&indexes.data)?,
151+
Self::parse_refs(&indexes.gas)?,
152+
Self::parse_refs(&indexes.value)?,
153+
)
154+
} else {
155+
(
156+
Refs(vec![Ref::Any]),
157+
Refs(vec![Ref::Any]),
158+
Refs(vec![Ref::Any]),
159+
)
160+
};
161+
150162
let result = self.parse_accounts_post(&expect.result)?;
151163

152164
if MainnetFork::in_network_range(&expect.network)? {

testool/src/statetest/yaml.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ impl<'a> YamlStateTestBuilder<'a> {
137137
}
138138

139139
let data_refs = Self::parse_refs(&expect["indexes"]["data"])?;
140-
let gparse_refs = Self::parse_refs(&expect["indexes"]["gas"])?;
140+
let gas_refs = Self::parse_refs(&expect["indexes"]["gas"])?;
141141
let value_refs = Self::parse_refs(&expect["indexes"]["value"])?;
142142
let result = self.parse_accounts(&expect["result"])?;
143143

144144
if MainnetFork::in_network_range(&networks)? {
145-
expects.push((exception, data_refs, gparse_refs, value_refs, result));
145+
expects.push((exception, data_refs, gas_refs, value_refs, result));
146146
}
147147
}
148148

@@ -152,7 +152,7 @@ impl<'a> YamlStateTestBuilder<'a> {
152152
for (idx_gas, gas_limit) in gas_limit_s.iter().enumerate() {
153153
for (idx_value, value) in value_s.iter().enumerate() {
154154
// find the first result that fulfills the pattern
155-
for (exception, data_refs, parse_refs, value_refs, result) in &expects {
155+
for (exception, data_refs, gas_refs, value_refs, result) in &expects {
156156
// check if this result can be applied to the current test
157157
let mut data_label = String::new();
158158
if let Some(label) = &data.1 {
@@ -164,7 +164,7 @@ impl<'a> YamlStateTestBuilder<'a> {
164164
continue;
165165
}
166166

167-
if !parse_refs.contains_index(idx_gas) {
167+
if !gas_refs.contains_index(idx_gas) {
168168
continue;
169169
}
170170

@@ -386,6 +386,11 @@ impl<'a> YamlStateTestBuilder<'a> {
386386
/// <range_lo>-<range_hi> >= Ref::Index(range_lo)..=RefIndex(range_hi)
387387
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
388388
fn parse_refs(yaml: &Yaml) -> Result<Refs> {
389+
if yaml.is_badvalue() {
390+
// It is considered as Any if missing this field.
391+
return Ok(Refs(vec![Ref::Any]));
392+
}
393+
389394
// convert a unique element into a list
390395
let yamls = if yaml.is_array() {
391396
yaml.as_vec().context("as_vec")?.iter().collect()

0 commit comments

Comments
 (0)