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

Support chain_id in loading multi-transaction state tests #1023

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions test/statetest/statetest_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ static void from_json_tx_common(const json::json& j, state::Transaction& o)
o.sender = from_json<evmc::address>(j.at("sender"));
o.nonce = from_json<uint64_t>(j.at("nonce"));

if (const auto chain_id_it = j.find("chainId"); chain_id_it != j.end())
o.chain_id = from_json<uint8_t>(*chain_id_it);
else
o.chain_id = 1;

if (const auto to_it = j.find("to"); to_it != j.end())
{
if (!to_it->is_null() && !to_it->get<std::string>().empty())
Expand Down Expand Up @@ -339,8 +344,6 @@ state::Transaction from_json<state::Transaction>(const json::json& j)
{
state::Transaction o;
from_json_tx_common(j, o);
if (const auto chain_id_it = j.find("chainId"); chain_id_it != j.end())
o.chain_id = from_json<uint8_t>(*chain_id_it);

if (const auto it = j.find("data"); it != j.end())
o.data = from_json<bytes>(*it);
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/statetest_loader_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ TEST(statetest_loader, load_minimal_test)
EXPECT_EQ(st.multi_tx.value, 0);
EXPECT_EQ(st.multi_tx.nonce, 0);
EXPECT_EQ(st.multi_tx.access_list.size(), 0);
EXPECT_EQ(st.multi_tx.chain_id, 0);
EXPECT_EQ(st.multi_tx.chain_id, 1);
EXPECT_EQ(st.multi_tx.nonce, 0);
EXPECT_EQ(st.multi_tx.r, 0);
EXPECT_EQ(st.multi_tx.s, 0);
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/statetest_loader_tx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ TEST(statetest_loader, tx_eip1559)
EXPECT_EQ(tx.type, state::Transaction::Type::eip1559);
EXPECT_EQ(tx.data, (bytes{0xb0, 0xb1}));
EXPECT_EQ(tx.gas_limit, 0x9091);
EXPECT_EQ(tx.chain_id, 0);
EXPECT_EQ(tx.chain_id, 1);
EXPECT_EQ(tx.value, 0xe0e1);
EXPECT_EQ(tx.sender, 0xa0a1_address);
EXPECT_EQ(tx.to, 0xc0c1_address);
Expand Down