-
Notifications
You must be signed in to change notification settings - Fork 285
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
Blockchain tests support: Add nonce value verification #685
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this looks to be done in a wrong place. We should check it in validate_transaction()
where we inspect sender's nonce already.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #685 +/- ##
==========================================
+ Coverage 97.48% 97.52% +0.04%
==========================================
Files 85 86 +1
Lines 8182 8208 +26
==========================================
+ Hits 7976 8005 +29
+ Misses 206 203 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are many state tests failing?
Because tx which is built by Fixed with additional commit. |
test/statetest/statetest_loader.cpp
Outdated
@@ -251,6 +251,9 @@ static void from_json_tx_common(const json::json& j, state::Transaction& o) | |||
{ | |||
o.sender = from_json<evmc::address>(j.at("sender")); | |||
|
|||
if (const auto nonce_it = j.find("nonce"); nonce_it != j.end()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the nonce always expected there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our load_minimal_test
test does not define nonce. So we can add that it's mandatory or we load it only when it's defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be mandatory
6eaedc2
to
601416c
Compare
|
||
using namespace evmone::state; | ||
|
||
TEST(transaction, validate_transaction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TEST(transaction, validate_transaction) | |
TEST(state_tx, validate_nonce) |
Also change file name to state_tx_test.cpp
|
||
{ | ||
const auto res = validate_transaction(acc, bi, tx, EVMC_BERLIN); | ||
ASSERT_TRUE(holds_alternative<int64_t>(res)) << std::get<std::error_code>(res).message(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASSERT_TRUE(holds_alternative<int64_t>(res)) << std::get<std::error_code>(res).message(); | |
EXPECT_FALSE(holds_alternative<std::error_code>(res)) << std::get<std::error_code>(res).message(); |
{ | ||
const auto res = validate_transaction(acc, bi, tx, EVMC_BERLIN); | ||
ASSERT_TRUE(holds_alternative<std::error_code>(res)) | ||
<< make_error_code(ErrorCode::NONCE_TOO_LOW).message(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this additional message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No we don't. I will add also checking the error code returned.
7c5d040
to
32c1434
Compare
|
||
const BlockInfo bi{.gas_limit = 0x989680, | ||
.coinbase = 0x01_address, | ||
.prev_randao = {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.prev_randao = {}, |
I think you can skip default initialized fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I cannot. CI complains during build.
No description provided.