diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthSendRawTransactionTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthSendRawTransactionAcceptanceTest.java similarity index 98% rename from acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthSendRawTransactionTest.java rename to acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthSendRawTransactionAcceptanceTest.java index 1aecce2936..4e4330da03 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthSendRawTransactionTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthSendRawTransactionAcceptanceTest.java @@ -27,7 +27,7 @@ import java.util.function.UnaryOperator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class EthSendRawTransactionTest extends AcceptanceTestBase { +public class EthSendRawTransactionAcceptanceTest extends AcceptanceTestBase { private static final long CHAIN_ID = 20211; private Account sender; diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java index df2ba1829b..1d1b69f9ce 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java @@ -55,6 +55,8 @@ public class JsonRpcErrorConverter { return JsonRpcError.MAX_PRIORITY_FEE_PER_GAS_EXCEEDS_MAX_FEE_PER_GAS; case OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST: return JsonRpcError.OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST; + case INVALID_TRANSACTION_FORMAT: + return JsonRpcError.INVALID_TRANSACTION_TYPE; case TRANSACTION_ALREADY_KNOWN: return JsonRpcError.ETH_SEND_TX_ALREADY_KNOWN; case TRANSACTION_REPLACEMENT_UNDERPRICED: diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java index 2a1b7e6809..bc633fdeff 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java @@ -55,6 +55,7 @@ public enum JsonRpcError { // Transaction validation failures NONCE_TOO_LOW(-32001, "Nonce too low"), INVALID_TRANSACTION_SIGNATURE(-32002, "Invalid signature"), + INVALID_TRANSACTION_TYPE(-32602, "Invalid transaction type"), INTRINSIC_GAS_EXCEEDS_LIMIT(-32003, "Intrinsic gas exceeds gas limit"), TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE(-32004, "Upfront cost exceeds account balance"), EXCEEDS_BLOCK_GAS_LIMIT(-32005, "Transaction gas limit exceeds block gas limit"), diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransactionTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransactionTest.java index 37d3375fcd..33521b2544 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransactionTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransactionTest.java @@ -41,6 +41,7 @@ public class EthSendRawTransactionTest { private static final String VALID_TRANSACTION = "0xf86d0485174876e800830222e0945aae326516b4f8fe08074b7e972e40a713048d62880de0b6b3a7640000801ba05d4e7998757264daab67df2ce6f7e7a0ae36910778a406ca73898c9899a32b9ea0674700d5c3d1d27f2e6b4469957dfd1a1c49bf92383d80717afc84eb05695d5b"; + @Mock private TransactionPool transactionPool; private EthSendRawTransaction method; @@ -170,6 +171,12 @@ public class EthSendRawTransactionTest { TransactionInvalidReason.TX_SENDER_NOT_AUTHORIZED, JsonRpcError.TX_SENDER_NOT_AUTHORIZED); } + @Test + public void transactionWithIncorrectTransactionTypeIsRejected() { + verifyErrorForInvalidTransaction( + TransactionInvalidReason.INVALID_TRANSACTION_FORMAT, JsonRpcError.INVALID_TRANSACTION_TYPE); + } + @Test public void transactionWithFeeCapExceededIsRejected() { verifyErrorForInvalidTransaction(