Skip to content
Merged
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
3 changes: 3 additions & 0 deletions test/state/errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum ErrorCode : int // NOLINT(*-use-enum-class)
EMPTY_AUTHORIZATION_LIST,
MAX_GAS_LIMIT_EXCEEDED,
INVALID_CHAIN_ID,
INVALID_ENCODING,
UNKNOWN_ERROR,

// Block-level validation.
Expand Down Expand Up @@ -103,6 +104,8 @@ inline const std::error_category& evmone_category() noexcept
return "max gas limit exceeded";
case INVALID_CHAIN_ID:
return "invalid transaction chain id";
case INVALID_ENCODING:
return "invalid transaction encoding";
case UNKNOWN_ERROR:
return "Unknown error";
case INCORRECT_BLOCK_FORMAT:
Expand Down
18 changes: 15 additions & 3 deletions test/statetest/statetest_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,24 @@ void run_state_test(const StateTransitionTest& test, evmc::VM& vm, bool trace_su
// continue;

const auto& expected = cases[case_index];
const auto tx = test.multi_tx.get(expected.indexes);
auto state = test.pre_state;
const auto blob_params = get_blob_params(rev, test.blob_schedule);

const auto res = transition(state, block, test.block_hashes, tx, rev, vm,
block.gas_limit, static_cast<int64_t>(state::max_blob_gas_per_block(blob_params)));
// Decode transaction from txbytes if available.
const auto template_tx = test.multi_tx.get(expected.indexes);
auto tx = std::optional{template_tx};
if (expected.txbytes.has_value())
{
tx = state::decode_transaction(*expected.txbytes);
if (tx.has_value())
tx->sender = template_tx.sender; // No recovery yet, take sender from JSON.
Comment on lines +35 to +37
}
Comment thread
chfast marked this conversation as resolved.

const auto res =
tx.has_value() ?
transition(state, block, test.block_hashes, *tx, rev, vm, block.gas_limit,
static_cast<int64_t>(state::max_blob_gas_per_block(blob_params))) :
make_error_code(state::INVALID_ENCODING);
Comment on lines +40 to +44

if (holds_alternative<state::TransactionReceipt>(res))
{
Expand Down
3 changes: 3 additions & 0 deletions test/utils/statetest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ struct StateTransitionTest
hash256 state_hash;
hash256 logs_hash = EmptyListHash;
bool exception = false;

/// The full encoded transaction for this case. Not always available.
std::optional<bytes> txbytes;
};

evmc_revision rev;
Expand Down
3 changes: 3 additions & 0 deletions test/utils/statetest_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ static void from_json(const json::json& j, StateTransitionTest::Case::Expectatio
o.state_hash = from_json<hash256>(j.at("hash"));
o.logs_hash = from_json<hash256>(j.at("logs"));
o.exception = j.contains("expectException");
// Not load_if_exists(): it maps an absent key to bytes{}, which engages the optional.
if (const auto it = j.find("txbytes"); it != j.end())
o.txbytes = from_json<bytes>(*it);
}

static void from_json(const json::json& j_t, StateTransitionTest& o)
Expand Down