Skip to content

Commit 82d64ba

Browse files
committed
statetest: Error on parsing Transction with mixed legacy/1559 contents
1 parent b4ab2f2 commit 82d64ba

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

test/statetest/statetest_loader.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ static void from_json_tx_common(const json::json& j, state::Transaction& o)
195195
o.kind = state::Transaction::Kind::legacy;
196196
o.max_gas_price = from_json<intx::uint256>(*gas_price_it);
197197
o.max_priority_gas_price = o.max_gas_price;
198+
if (j.contains("maxFeePerGas") || j.contains("maxPriorityFeePerGas"))
199+
throw std::invalid_argument(
200+
"Misformatted transaction -- contains both legacy and 1559 fees");
198201
}
199202
else
200203
{

test/unittests/statetest_loader_tx_test.cpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,6 @@ TEST(statetest_loader, tx_confusing)
101101
"accessList": []
102102
})";
103103

104-
const auto tx = test::from_json<state::Transaction>(json::json::parse(input));
105-
EXPECT_EQ(tx.kind, state::Transaction::Kind::legacy);
106-
EXPECT_EQ(tx.data, (bytes{0xb0, 0xb1}));
107-
EXPECT_EQ(tx.gas_limit, 0x9091);
108-
EXPECT_EQ(tx.value, 0xe0e1);
109-
EXPECT_EQ(tx.sender, 0xa0a1_address);
110-
EXPECT_EQ(tx.to, 0xc0c1_address);
111-
EXPECT_EQ(tx.max_gas_price, 0x8081);
112-
EXPECT_EQ(tx.max_priority_gas_price, 0x8081);
113-
EXPECT_TRUE(tx.access_list.empty());
104+
EXPECT_THROW(
105+
test::from_json<state::Transaction>(json::json::parse(input)), std::invalid_argument);
114106
}

0 commit comments

Comments
 (0)