From 3ed337cdf0ca0e989aa7bfcf0a4ab31cc6460d5e Mon Sep 17 00:00:00 2001 From: pdobacz <5735525+pdobacz@users.noreply.github.com> Date: Wed, 8 May 2024 11:39:37 +0200 Subject: [PATCH] Fix exported error messages for invalid tx tests --- test/state/state.cpp | 52 +++++++++++++++++++++++++++++ test/state/state.hpp | 3 ++ test/unittests/state_transition.cpp | 3 +- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/test/state/state.cpp b/test/state/state.cpp index a839602f20..12f514af57 100644 --- a/test/state/state.cpp +++ b/test/state/state.cpp @@ -610,4 +610,56 @@ std::variant transition(State& state, const withdrawal.amount_in_gwei); } +[[nodiscard]] std::string get_tests_invalid_tx_message(ErrorCode errc) noexcept +{ + switch (errc) + { + case SUCCESS: + return ""; + case INTRINSIC_GAS_TOO_LOW: + return "TR_IntrinsicGas"; + case TX_TYPE_NOT_SUPPORTED: + return "TR_TypeNotSupported"; + case INSUFFICIENT_FUNDS: + return "TR_NoFunds"; + case NONCE_HAS_MAX_VALUE: + return "TR_NonceHasMaxValue:"; + case NONCE_TOO_HIGH: + return "TR_NonceTooHigh"; + case NONCE_TOO_LOW: + return "TR_NonceTooLow"; + case TIP_GT_FEE_CAP: + return "TR_TipGtFeeCap"; + case FEE_CAP_LESS_THEN_BLOCKS: + return "TR_FeeCapLessThanBlocks"; + case GAS_LIMIT_REACHED: + return "TR_GasLimitReached"; + case SENDER_NOT_EOA: + return "SenderNotEOA"; + case INIT_CODE_SIZE_LIMIT_EXCEEDED: + return "TR_InitCodeLimitExceeded"; + case INIT_CODE_EMPTY: + return "TR_InitCodeEmpty"; + case INIT_CODE_COUNT_LIMIT_EXCEEDED: + return "TR_InitCodeCountLimitExceeded"; + case INIT_CODE_COUNT_ZERO: + return "TR_InitCodeCountZero"; + case CREATE_BLOB_TX: + return "TR_CreateBlobTx"; + case EMPTY_BLOB_HASHES_LIST: + return "TR_EmptyBlobHashesList"; + case INVALID_BLOB_HASH_VERSION: + return "TR_InvalidBlobHashVersion"; + case BLOB_GAS_LIMIT_EXCEEDED: + return "TR_BlobGasLimitExceeded"; + case EOF_CREATION_TRANSACTION: + return "TR_EOFCreationTransaction"; + case UNKNOWN_ERROR: + return "Unknown error"; + default: + assert(false); + return "Wrong error code"; + } +} + } // namespace evmone::state diff --git a/test/state/state.hpp b/test/state/state.hpp index 61de8c43a3..e5b66a254a 100644 --- a/test/state/state.hpp +++ b/test/state/state.hpp @@ -6,6 +6,7 @@ #include "account.hpp" #include "bloom_filter.hpp" +#include "errors.hpp" #include "hash_utils.hpp" #include #include @@ -293,4 +294,6 @@ void system_call(State& state, const BlockInfo& block, evmc_revision rev, evmc:: /// Defines how to RLP-encode a Withdrawal. [[nodiscard]] bytes rlp_encode(const Withdrawal& withdrawal); +[[nodiscard]] std::string get_tests_invalid_tx_message(ErrorCode errc) noexcept; + } // namespace evmone::state diff --git a/test/unittests/state_transition.cpp b/test/unittests/state_transition.cpp index 4cf4eb2068..7f6fdd8732 100644 --- a/test/unittests/state_transition.cpp +++ b/test/unittests/state_transition.cpp @@ -230,7 +230,8 @@ void state_transition::export_state_test( if (holds_alternative(res)) { - jpost["expectException"] = std::get(res).message(); + jpost["expectException"] = get_tests_invalid_tx_message( + static_cast(std::get(res).value())); jpost["logs"] = hex0x(logs_hash(std::vector())); } else