Skip to content

Commit 593cc95

Browse files
authored
test: Support chain_id in loading multi-transaction state tests (#1023)
Also set default `chain_id` to 1 - see confirmation that this is expected behavior https://discord.com/channels/595666850260713488/753271902520213625/1280839101687533619 Pulled out of #961, required for 7702 tests.
1 parent eaecdd5 commit 593cc95

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

test/statetest/statetest_loader.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ static void from_json_tx_common(const json::json& j, state::Transaction& o)
299299
o.sender = from_json<evmc::address>(j.at("sender"));
300300
o.nonce = from_json<uint64_t>(j.at("nonce"));
301301

302+
if (const auto chain_id_it = j.find("chainId"); chain_id_it != j.end())
303+
o.chain_id = from_json<uint8_t>(*chain_id_it);
304+
else
305+
o.chain_id = 1;
306+
302307
if (const auto to_it = j.find("to"); to_it != j.end())
303308
{
304309
if (!to_it->is_null() && !to_it->get<std::string>().empty())
@@ -339,8 +344,6 @@ state::Transaction from_json<state::Transaction>(const json::json& j)
339344
{
340345
state::Transaction o;
341346
from_json_tx_common(j, o);
342-
if (const auto chain_id_it = j.find("chainId"); chain_id_it != j.end())
343-
o.chain_id = from_json<uint8_t>(*chain_id_it);
344347

345348
if (const auto it = j.find("data"); it != j.end())
346349
o.data = from_json<bytes>(*it);

test/unittests/statetest_loader_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ TEST(statetest_loader, load_minimal_test)
145145
EXPECT_EQ(st.multi_tx.value, 0);
146146
EXPECT_EQ(st.multi_tx.nonce, 0);
147147
EXPECT_EQ(st.multi_tx.access_list.size(), 0);
148-
EXPECT_EQ(st.multi_tx.chain_id, 0);
148+
EXPECT_EQ(st.multi_tx.chain_id, 1);
149149
EXPECT_EQ(st.multi_tx.nonce, 0);
150150
EXPECT_EQ(st.multi_tx.r, 0);
151151
EXPECT_EQ(st.multi_tx.s, 0);

test/unittests/statetest_loader_tx_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ TEST(statetest_loader, tx_eip1559)
9595
EXPECT_EQ(tx.type, state::Transaction::Type::eip1559);
9696
EXPECT_EQ(tx.data, (bytes{0xb0, 0xb1}));
9797
EXPECT_EQ(tx.gas_limit, 0x9091);
98-
EXPECT_EQ(tx.chain_id, 0);
98+
EXPECT_EQ(tx.chain_id, 1);
9999
EXPECT_EQ(tx.value, 0xe0e1);
100100
EXPECT_EQ(tx.sender, 0xa0a1_address);
101101
EXPECT_EQ(tx.to, 0xc0c1_address);

0 commit comments

Comments
 (0)