diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java index 0f6d6c2b1bc..9b92221e65a 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java @@ -52,7 +52,6 @@ import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; -import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator; import java.math.BigInteger; @@ -215,7 +214,13 @@ public void shouldValidateExcessBlobGasCorrectly() { @Test public void shouldRejectTransactionsWithFullBlob() { - List transactions = List.of(createBlobTransactionEncodedForNetwork()); + + Bytes transactionWithBlobsBytes = + TransactionEncoder.encodeOpaqueBytes( + createTransactionWithBlobs(), EncodingContext.POOLED_TRANSACTION); + + List transactions = List.of(transactionWithBlobsBytes.toString()); + BlockHeader mockHeader = setupValidPayload( new BlockProcessingResult(Optional.of(new BlockProcessingOutputs(null, List.of()))), @@ -229,24 +234,19 @@ public void shouldRejectTransactionsWithFullBlob() { verify(engineCallListener, times(1)).executionEngineCalled(); } - private String createBlobTransactionEncodedForNetwork() { + private Transaction createTransactionWithBlobs() { BlobTestFixture blobTestFixture = new BlobTestFixture(); BlobsWithCommitments bwc = blobTestFixture.createBlobsWithCommitments(1); - Transaction blobTx = - new TransactionTestFixture() - .to(Optional.of(Address.fromHexString("0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF"))) - .type(TransactionType.BLOB) - .chainId(Optional.of(BigInteger.ONE)) - .maxFeePerGas(Optional.of(Wei.of(15))) - .maxFeePerBlobGas(Optional.of(Wei.of(128))) - .maxPriorityFeePerGas(Optional.of(Wei.of(1))) - .blobsWithCommitments(Optional.of(bwc)) - .versionedHashes(Optional.of(bwc.getVersionedHashes())) - .createTransaction(senderKeys); - - final BytesValueRLPOutput bytesValueRLPOutput = new BytesValueRLPOutput(); - TransactionEncoder.encodeOpaqueBytes(blobTx, EncodingContext.POOLED_TRANSACTION); - Bytes encodedRLP = bytesValueRLPOutput.encoded(); - return encodedRLP.toString(); + + return new TransactionTestFixture() + .to(Optional.of(Address.fromHexString("0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF"))) + .type(TransactionType.BLOB) + .chainId(Optional.of(BigInteger.ONE)) + .maxFeePerGas(Optional.of(Wei.of(15))) + .maxFeePerBlobGas(Optional.of(Wei.of(128))) + .maxPriorityFeePerGas(Optional.of(Wei.of(1))) + .blobsWithCommitments(Optional.of(bwc)) + .versionedHashes(Optional.of(bwc.getVersionedHashes())) + .createTransaction(senderKeys); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/BlobTransactionEncodingTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/BlobTransactionEncodingTest.java index cc1829505ec..b1bb4be6764 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/BlobTransactionEncodingTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/BlobTransactionEncodingTest.java @@ -57,10 +57,13 @@ public void blobTransactionEncodingDecodingForNetWorkTest( final Transaction transaction = TransactionDecoder.decodeOpaqueBytes(bytes, EncodingContext.POOLED_TRANSACTION); + final BytesValueRLPOutput output = new BytesValueRLPOutput(); + TransactionEncoder.encodeRLP(transaction.getType(), bytes, output); + final BytesValueRLPOutput bytesValueRLPOutput = new BytesValueRLPOutput(); TransactionEncoder.encodeRLP( transaction, bytesValueRLPOutput, EncodingContext.POOLED_TRANSACTION); - assertThat(transaction.getSize()).isEqualTo(bytes.size()); + assertThat(transaction.getSize()).isEqualTo(output.encodedSize()); } @ParameterizedTest(name = "{index} {0}") @@ -72,8 +75,7 @@ public void blobTransactionEncodingDecodingTest(final TypedTransactionBytesArgum TransactionDecoder.decodeOpaqueBytes(bytes, EncodingContext.BLOCK_BODY); // Encode the transaction for wire using the TransactionEncoder. - Bytes encoded = - TransactionEncoder.encodeOpaqueBytes(transaction, EncodingContext.POOLED_TRANSACTION); + Bytes encoded = TransactionEncoder.encodeOpaqueBytes(transaction, EncodingContext.BLOCK_BODY); // Assert that the encoded transaction matches the original bytes. assertThat(encoded.toHexString()).isEqualTo(bytes.toHexString());