Skip to content

Commit

Permalink
Do not allow confusing inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Feb 13, 2023
1 parent 12d6467 commit 22b1c5e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
3 changes: 3 additions & 0 deletions test/statetest/statetest_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ static void from_json_tx_common(const json::json& j, state::Transaction& o)
o.kind = state::Transaction::Kind::legacy;
o.max_gas_price = from_json<intx::uint256>(*gas_price_it);
o.max_priority_gas_price = o.max_gas_price;
if (j.contains("maxFeePerGas") || j.contains("maxPriorityFeePerGas"))
throw std::invalid_argument(
"Misformatted transaction -- containts both legacy and 1559 fees");
}
else
{
Expand Down
12 changes: 2 additions & 10 deletions test/unittests/statetest_loader_tx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,6 @@ TEST(statetest_loader, tx_confusing)
"accessList": []
})";

const auto tx = test::from_json<state::Transaction>(json::json::parse(input));
EXPECT_EQ(tx.kind, state::Transaction::Kind::legacy);
EXPECT_EQ(tx.data, (bytes{0xb0, 0xb1}));
EXPECT_EQ(tx.gas_limit, 0x9091);
EXPECT_EQ(tx.value, 0xe0e1);
EXPECT_EQ(tx.sender, 0xa0a1_address);
EXPECT_EQ(tx.to, 0xc0c1_address);
EXPECT_EQ(tx.max_gas_price, 0x8081);
EXPECT_EQ(tx.max_priority_gas_price, 0x8081);
EXPECT_TRUE(tx.access_list.empty());
EXPECT_THROW(
test::from_json<state::Transaction>(json::json::parse(input)), std::invalid_argument);
}

0 comments on commit 22b1c5e

Please sign in to comment.