diff --git a/test/state/state.cpp b/test/state/state.cpp index 8697636eda..08e5ec2ded 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_BLOBCREATE"; + case EMPTY_BLOB_HASHES_LIST: + return "TR_EMPTYBLOB"; + case INVALID_BLOB_HASH_VERSION: + return "TR_BLOBVERSION_INVALID"; + case BLOB_GAS_LIMIT_EXCEEDED: + return "TR_BLOBLIST_OVERSIZE"; + 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