LCOV - differential code coverage report
Current view: top level - test/state - errors.hpp (source / functions) Coverage Total Hit UBC
Current: DIFF_COVERAGE Lines: 0.0 % 44 0 44
Current Date: 2024-03-20 16:29:22 Functions: 0.0 % 4 0 4
Baseline: coverage_BASE.lcov
Baseline Date: 2024-03-20 14:19:08

           TLA  Line data    Source code
       1                 : // evmone: Fast Ethereum Virtual Machine implementation
       2                 : // Copyright 2023 The evmone Authors.
       3                 : // SPDX-License-Identifier: Apache-2.0
       4                 : #pragma once
       5                 : 
       6                 : #include <cassert>
       7                 : #include <system_error>
       8                 : 
       9                 : namespace evmone::state
      10                 : {
      11                 : 
      12                 : enum ErrorCode : int
      13                 : {
      14                 :     SUCCESS = 0,
      15                 :     INTRINSIC_GAS_TOO_LOW,
      16                 :     TX_TYPE_NOT_SUPPORTED,
      17                 :     INSUFFICIENT_FUNDS,
      18                 :     NONCE_HAS_MAX_VALUE,
      19                 :     NONCE_TOO_HIGH,
      20                 :     NONCE_TOO_LOW,
      21                 :     TIP_GT_FEE_CAP,
      22                 :     FEE_CAP_LESS_THEN_BLOCKS,
      23                 :     GAS_LIMIT_REACHED,
      24                 :     SENDER_NOT_EOA,
      25                 :     INIT_CODE_SIZE_LIMIT_EXCEEDED,
      26                 :     CREATE_BLOB_TX,
      27                 :     EMPTY_BLOB_HASHES_LIST,
      28                 :     INVALID_BLOB_HASH_VERSION,
      29                 :     BLOB_GAS_LIMIT_EXCEEDED,
      30                 :     UNKNOWN_ERROR,
      31                 : };
      32                 : 
      33                 : /// Obtains a reference to the static error category object for evmone errors.
      34 UBC           0 : inline const std::error_category& evmone_category() noexcept
      35                 : {
      36                 :     struct Category : std::error_category
      37                 :     {
      38               0 :         [[nodiscard]] const char* name() const noexcept final { return "evmone"; }
      39                 : 
      40               0 :         [[nodiscard]] std::string message(int ev) const noexcept final
      41                 :         {
      42               0 :             switch (ev)
      43                 :             {
      44               0 :             case SUCCESS:
      45               0 :                 return "";
      46               0 :             case INTRINSIC_GAS_TOO_LOW:
      47               0 :                 return "intrinsic gas too low";
      48               0 :             case TX_TYPE_NOT_SUPPORTED:
      49               0 :                 return "transaction type not supported";
      50               0 :             case INSUFFICIENT_FUNDS:
      51               0 :                 return "insufficient funds for gas * price + value";
      52               0 :             case NONCE_HAS_MAX_VALUE:
      53               0 :                 return "nonce has max value:";
      54               0 :             case NONCE_TOO_HIGH:
      55               0 :                 return "nonce too high";
      56               0 :             case NONCE_TOO_LOW:
      57               0 :                 return "nonce too low";
      58               0 :             case TIP_GT_FEE_CAP:
      59               0 :                 return "max priority fee per gas higher than max fee per gas";
      60               0 :             case FEE_CAP_LESS_THEN_BLOCKS:
      61               0 :                 return "max fee per gas less than block base fee";
      62               0 :             case GAS_LIMIT_REACHED:
      63               0 :                 return "gas limit reached";
      64               0 :             case SENDER_NOT_EOA:
      65               0 :                 return "sender not an eoa:";
      66               0 :             case INIT_CODE_SIZE_LIMIT_EXCEEDED:
      67               0 :                 return "max initcode size exceeded";
      68               0 :             case CREATE_BLOB_TX:
      69               0 :                 return "blob transaction must not be a create transaction";
      70               0 :             case EMPTY_BLOB_HASHES_LIST:
      71               0 :                 return "empty blob hashes list";
      72               0 :             case INVALID_BLOB_HASH_VERSION:
      73               0 :                 return "invalid blob hash version";
      74               0 :             case BLOB_GAS_LIMIT_EXCEEDED:
      75               0 :                 return "blob gas limit exceeded";
      76               0 :             case UNKNOWN_ERROR:
      77               0 :                 return "Unknown error";
      78               0 :             default:
      79               0 :                 assert(false);
      80                 :                 return "Wrong error code";
      81                 :             }
      82                 :         }
      83                 :     };
      84                 : 
      85               0 :     static const Category category_instance;
      86               0 :     return category_instance;
      87                 : }
      88                 : 
      89                 : /// Creates error_code object out of an evmone error code value.
      90                 : /// This is used by std::error_code to implement implicit conversion
      91                 : /// evmone::ErrorCode -> std::error_code, therefore the definition is
      92                 : /// in the global namespace to match the definition of ethash_errc.
      93               0 : inline std::error_code make_error_code(ErrorCode errc) noexcept
      94                 : {
      95               0 :     return {errc, evmone_category()};
      96                 : }
      97                 : 
      98                 : }  // namespace evmone::state
        

Generated by: LCOV version 2.0-1