invalid transaction type pass through to user (#5473)

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/5479/head
Sally MacFarlane 2 years ago committed by GitHub
parent 6a2a1ea0b8
commit 19f07b937a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/EthSendRawTransactionAcceptanceTest.java
  2. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcErrorConverter.java
  3. 1
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/response/JsonRpcError.java
  4. 7
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthSendRawTransactionTest.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;

@ -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:

@ -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"),

@ -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(

Loading…
Cancel
Save