Skip to content

Commit c2ef6ea

Browse files
committed
Fix state account state for storage
1 parent 19fe854 commit c2ef6ea

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

evm-tests/jsontests/src/state.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ fn test_run(test_config: &TestConfig, test: &StateTestCase) -> TestExecutionResu
4949
let mut tests_result = TestExecutionResult::new();
5050
for (spec, states) in &test.post_states {
5151
// TODO
52-
if test_config.name != "tests/static/state_tests/stStaticCall/static_callBasicFiller.json::static_callBasic[fork_Prague-state_test-d1-g0-v0]" {
53-
continue
54-
}
55-
println!("{test:?}");
52+
// if test_config.name != "tests/static/state_tests/stStaticCall/static_callBasicFiller.json::static_callBasic[fork_Prague-state_test-d1-g0-v0]" {
53+
// continue
54+
// }
55+
// println!("{test:?}");
5656

5757
// Run tests for specific EVM hard fork (Spec)
5858
if let Some(s) = test_config.spec.as_ref() {
@@ -121,6 +121,8 @@ fn test_run(test_config: &TestConfig, test: &StateTestCase) -> TestExecutionResu
121121

122122
for (i, state) in states.iter().enumerate() {
123123
let mut backend = MemoryBackend::new(&vicinity, original_state.0.clone());
124+
// TODO
125+
// println!("\nSTATE BEFORE: {:#?}", backend.state());
124126
tests_result.total += 1;
125127

126128
// Test case may be expected to fail with an unsupported tx type if the current fork is
@@ -207,7 +209,7 @@ fn test_run(test_config: &TestConfig, test: &StateTestCase) -> TestExecutionResu
207209
authorization_list.clone(),
208210
);
209211
// TODO
210-
println!("\nCALLER: {caller:?}\nTO: {to:?}\nVALUE: {value:?}n{gas_limit:?}\n{:?}\n{:?}\nREASON: {_reason:?}",access_list,authorization_list);
212+
// println!("\nCALLER: {caller:?}\nTO: {to:?}\nVALUE: {value:?}n{gas_limit:?}\n{:?}\n{:?}\nREASON: {_reason:?}",access_list,authorization_list);
211213
assert_call_exit_exception(state.expect_exception.as_ref(), &test_config.name);
212214
} else {
213215
let code = data;
@@ -284,7 +286,8 @@ fn test_run(test_config: &TestConfig, test: &StateTestCase) -> TestExecutionResu
284286
});
285287
}
286288

287-
println!("\nSTATE: {:#?}", backend.state());
289+
// TODO
290+
// println!("\nSTATE AFTER: {:#?}", backend.state());
288291
let backend_state = MemoryAccountsState(backend.state().clone());
289292
let (is_valid_hash, actual_hash) = backend_state.check_valid_hash(&state.hash);
290293
if !is_valid_hash {

evm-tests/jsontests/src/types/account_state.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,18 @@ impl From<StateAccount> for MemoryAccount {
3131
Self {
3232
nonce: account.nonce,
3333
balance: account.balance,
34-
storage: account.storage,
34+
storage: account
35+
.storage
36+
.iter()
37+
.filter_map(|(k, v)| {
38+
if v.is_zero() {
39+
// If value is zero then the key is not really there
40+
None
41+
} else {
42+
Some((*k, *v))
43+
}
44+
})
45+
.collect(),
3546
code: account.code.unwrap_or_default(),
3647
}
3748
}

0 commit comments

Comments
 (0)