Skip to content

Commit 184b2c4

Browse files
committed
statetest: Extend failure message for invalid tx
1 parent ecdd703 commit 184b2c4

3 files changed

Lines changed: 54 additions & 1 deletion

File tree

test/integration/statetest/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(PREFIX ${PREFIX}/statetest)
88
set(TESTS1 ${CMAKE_CURRENT_SOURCE_DIR}/tests1)
99
set(TESTS2 ${CMAKE_CURRENT_SOURCE_DIR}/tests2)
1010
set(TESTS_EOF ${CMAKE_CURRENT_SOURCE_DIR}/eof)
11+
set(TESTS_TX ${CMAKE_CURRENT_SOURCE_DIR}/tx)
1112

1213
add_test(
1314
NAME ${PREFIX}/no_arguments
@@ -106,3 +107,12 @@ set_tests_properties(
106107
${PREFIX}/invalid_eof_in_state PROPERTIES
107108
PASS_REGULAR_EXPRESSION "EOF container at 0x0000000000000000000000000000000000bade0f is invalid"
108109
)
110+
111+
add_test(
112+
NAME ${PREFIX}/tx_invalid_nonce
113+
COMMAND evmone-statetest ${TESTS_TX}/invalid_nonce.json
114+
)
115+
set_tests_properties(
116+
${PREFIX}/tx_invalid_nonce PROPERTIES
117+
PASS_REGULAR_EXPRESSION "unexpected invalid transaction: nonce too high"
118+
)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"invalid_nonce": {
3+
"env": {
4+
"currentBaseFee": "0x0a",
5+
"currentCoinbase": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
6+
"currentDifficulty": "0x020000",
7+
"currentGasLimit": "0xff112233445566",
8+
"currentNumber": "0x01",
9+
"currentRandom": "0x0000000000000000000000000000000000000000000000000000000000020000",
10+
"currentTimestamp": "0x03e8"
11+
},
12+
"post": {
13+
"Shanghai": [
14+
{
15+
"hash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
16+
"indexes": {
17+
"data": 0,
18+
"gas": 0,
19+
"value": 0
20+
},
21+
"logs": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
22+
}
23+
]
24+
},
25+
"pre": {},
26+
"transaction": {
27+
"data": [
28+
"0x"
29+
],
30+
"gasLimit": [
31+
"0x00"
32+
],
33+
"gasPrice": "0x0a",
34+
"nonce": "0x01",
35+
"sender": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
36+
"to": "0x00",
37+
"value": [
38+
"0x00"
39+
]
40+
}
41+
}
42+
}

test/statetest/statetest_runner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ void run_state_test(const StateTransitionTest& test, evmc::VM& vm, bool trace_su
5353
if (holds_alternative<state::TransactionReceipt>(res))
5454
EXPECT_EQ(logs_hash(get<state::TransactionReceipt>(res).logs), expected.logs_hash);
5555
else
56-
EXPECT_TRUE(expected.exception);
56+
EXPECT_TRUE(expected.exception)
57+
<< "unexpected invalid transaction: " << get<std::error_code>(res).message();
5758

5859
EXPECT_EQ(state_root, expected.state_hash);
5960
}

0 commit comments

Comments
 (0)