Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Introduce TestState and TestAccount #811

Merged
merged 1 commit into from
Jun 6, 2024
Merged

Conversation

chfast
Copy link
Member

@chfast chfast commented Feb 8, 2024

This decouples the state::State for transaction execution from the state object for test definitions and asserts.

The state::State (also called "intra state") has some constructs and data related to transaction execution only (like "current" and "original" storage values). These should not be exposed to tests and make test definitions more complicated.

This separation should also help with adding new public API for EVM with transaction-level execution granularity.

Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: Patch coverage is 94.73684% with 12 lines in your changes missing coverage. Please review.

Project coverage is 95.15%. Comparing base (189bbaf) to head (924b6b8).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #811   +/-   ##
=======================================
  Coverage   95.14%   95.15%           
=======================================
  Files         138      140    +2     
  Lines       15766    15785   +19     
=======================================
+ Hits        15001    15020   +19     
  Misses        765      765           
Flag Coverage Δ
ethereum_tests 26.62% <17.75%> (+0.05%) ⬆️
ethereum_tests_silkpre 18.47% <13.55%> (+0.06%) ⬆️
execution_spec_tests 17.95% <18.66%> (+0.07%) ⬆️
unittests 90.27% <92.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
test/blockchaintest/blockchaintest.hpp 100.00% <ø> (ø)
test/blockchaintest/blockchaintest_loader.cpp 98.64% <100.00%> (ø)
test/state/mpt_hash.cpp 100.00% <100.00%> (ø)
test/state/mpt_hash.hpp 100.00% <ø> (ø)
test/state/state.hpp 100.00% <100.00%> (ø)
test/state/test_state.cpp 100.00% <100.00%> (ø)
test/statetest/statetest.hpp 100.00% <ø> (ø)
test/statetest/statetest_export.cpp 100.00% <100.00%> (ø)
test/statetest/statetest_loader.cpp 96.86% <100.00%> (-0.03%) ⬇️
test/statetest/statetest_runner.cpp 96.66% <100.00%> (ø)
... and 10 more

@chfast chfast force-pushed the test/test_account branch 2 times, most recently from 78d4e78 to 9aa80be Compare February 9, 2024 10:10
@chfast chfast force-pushed the test/test_account branch 2 times, most recently from 43616e1 to 7b5c45d Compare June 4, 2024 11:27
@chfast chfast changed the title test: TestState test: Introduce TestState and TestAccount Jun 4, 2024
@chfast chfast requested review from pdobacz, gumb0 and rodiazet June 4, 2024 11:28
@chfast chfast marked this pull request as ready for review June 4, 2024 11:42
Copy link
Collaborator

@pdobacz pdobacz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 items to look at, otherwise makes sense to me

// Find unexpected storage keys. This will also report entries with value 0.
EXPECT_TRUE(expected_acc.storage.contains(key))
<< "unexpected storage key " << key << "=" << value.current << " in " << addr;
// FIXME:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this fixme ok to be left behind? I'm staring at this and can't seem to figure it out, pls check

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I need to figure it out. This code has been changed since the start of this PR. The new types makes the comparison easier (e.g. TestState{} == TestState{}) but we also want to have rich failure comments.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Mostly in #920.

test/state/test_state.hpp Outdated Show resolved Hide resolved
@chfast chfast self-assigned this Jun 5, 2024
@chfast chfast changed the base branch from master to test/state_transition_checks June 5, 2024 14:05
Base automatically changed from test/state_transition_checks to master June 6, 2024 13:10
This decouples the `state::State` for transaction execution from
the state object for test definitions and asserts.

The `state::State` (also called "intra state") has some constructs
and data related to transaction execution only (like "current" and
"original" storage values). These should not be exposed to tests
and make test definitions more complicated.

This separation should also help with adding new public API
for EVM with transaction-level execution granularity.
@chfast chfast merged commit 64d1db5 into master Jun 6, 2024
24 of 25 checks passed
@chfast chfast deleted the test/test_account branch June 6, 2024 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants