Skip to content

Commit 615e40b

Browse files
committed
test: added e2e test for Jumbo
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
1 parent d8b02b3 commit 615e40b

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

packages/server/tests/acceptance/sendRawTransactionExtension.spec.ts

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('@sendRawTransactionExtension Acceptance Tests', function () {
5656

5757
describe('Prechecks', function () {
5858
describe('transactionSize', function () {
59-
it('@release should execute "eth_sendRawTransaction" with regular transaction size within the limit', async function () {
59+
it('@release should execute "eth_sendRawTransaction" with regular transaction size within the SEND_RAW_TRANSACTION_SIZE_LIMIT - 130kb limit', async function () {
6060
const gasPrice = await relay.gasPrice(requestId);
6161
const transaction = {
6262
type: 2,
@@ -79,7 +79,7 @@ describe('@sendRawTransactionExtension Acceptance Tests', function () {
7979
expect(info.result).to.equal('SUCCESS');
8080
});
8181

82-
it('@release should fail "eth_sendRawTransaction" when transaction size exceeds the limit', async function () {
82+
it('@release should fail "eth_sendRawTransaction" when transaction size exceeds the SEND_RAW_TRANSACTION_SIZE_LIMIT - 130kb limit', async function () {
8383
const gasPrice = await relay.gasPrice(requestId);
8484
const transaction = {
8585
type: 2,
@@ -104,7 +104,7 @@ describe('@sendRawTransactionExtension Acceptance Tests', function () {
104104
});
105105

106106
describe('callDataSize', function () {
107-
it('@release should execute "eth_sendRawTransaction" with regular transaction size within the limit', async function () {
107+
it('@release should execute "eth_sendRawTransaction" with regular transaction size within the CALL_DATA_SIZE_LIMIT - 128kb limit', async function () {
108108
const gasPrice = await relay.gasPrice(requestId);
109109
const transaction = {
110110
type: 2,
@@ -127,7 +127,7 @@ describe('@sendRawTransactionExtension Acceptance Tests', function () {
127127
expect(info.result).to.equal('SUCCESS');
128128
});
129129

130-
it('@release should fail "eth_sendRawTransaction" when transaction size exceeds the limit', async function () {
130+
it('@release should fail "eth_sendRawTransaction" when transaction size exceeds the CALL_DATA_SIZE_LIMIT - 128kb limit', async function () {
131131
const gasPrice = await relay.gasPrice(requestId);
132132
const transaction = {
133133
type: 2,
@@ -152,16 +152,18 @@ describe('@sendRawTransactionExtension Acceptance Tests', function () {
152152
});
153153

154154
describe('contractCodeSize', function () {
155-
it('@release should execute "eth_sendRawTransaction" and deploy a contract with code size within the limit', async function () {
155+
it('@release should execute "eth_sendRawTransaction" and deploy a contract with code size within the CONTRACT_CODE_SIZE_LIMIT - 24kb limit', async function () {
156156
const gasPrice = await relay.gasPrice(requestId);
157+
158+
// create a regular deployment transaction with contract code size within the CONTRACT_CODE_SIZE_LIMIT - 24kb limit
157159
const transaction = {
158160
type: 2,
159161
chainId: Number(CHAIN_ID),
160162
nonce: await relay.getAccountNonce(accounts[1].address, requestId),
161163
maxPriorityFeePerGas: gasPrice,
162164
maxFeePerGas: gasPrice,
163165
gasLimit: defaultGasLimit,
164-
data: '0x' + '00'.repeat(Constants.CONTRACT_CODE_SIZE_LIMIT), // Within the CONTRACT_CODE_SIZE_LIMIT limit
166+
data: '0x' + '00'.repeat(5120),
165167
};
166168

167169
const signedTx = await accounts[1].wallet.signTransaction(transaction);
@@ -175,17 +177,17 @@ describe('@sendRawTransactionExtension Acceptance Tests', function () {
175177
expect(info.created_contract_ids.length).to.be.equal(1);
176178
});
177179

178-
it('@release should fail "eth_sendRawTransaction" for contract with code size exceeding the limit', async function () {
180+
it('@release should fail "eth_sendRawTransaction" for contract with code size exceeding the CONTRACT_CODE_SIZE_LIMIT - 24kb limit', async function () {
179181
const gasPrice = await relay.gasPrice(requestId);
180-
// Create a transaction with contract code size exceeding CONTRACT_CODE_SIZE_LIMIT
182+
// Create a deployment transaction with contract code size exceeding CONTRACT_CODE_SIZE_LIMIT
181183
const transaction = {
182184
type: 2,
183185
chainId: Number(CHAIN_ID),
184186
nonce: await relay.getAccountNonce(accounts[1].address, requestId),
185187
maxPriorityFeePerGas: gasPrice,
186188
maxFeePerGas: gasPrice,
187189
gasLimit: defaultGasLimit,
188-
data: '0x' + '00'.repeat(Constants.CONTRACT_CODE_SIZE_LIMIT + 1),
190+
data: '0x' + '00'.repeat(Constants.CONTRACT_CODE_SIZE_LIMIT + 1024), // exceeds the limit by 1KB
189191
};
190192

191193
const signedTx = await accounts[1].wallet.signTransaction(transaction);
@@ -198,7 +200,7 @@ describe('@sendRawTransactionExtension Acceptance Tests', function () {
198200
await Assertions.assertPredefinedRpcError(error, sendRawTransaction, false, relay, [signedTx, requestDetails]);
199201
});
200202

201-
it('@release should pass precheck and execute "eth_sendRawTransaction" for a regular transaction i.e. non contract deployment transaction with data exceeding the limit', async function () {
203+
it('@release should pass precheck and execute "eth_sendRawTransaction" for a regular transaction i.e. non contract deployment transaction with data exceeding the CONTRACT_CODE_SIZE_LIMIT - 24kb limit', async function () {
202204
const gasPrice = await relay.gasPrice(requestId);
203205
// Create a transaction with large data but sent to an existing address (not contract creation)
204206
const transaction = {
@@ -219,4 +221,33 @@ describe('@sendRawTransactionExtension Acceptance Tests', function () {
219221
});
220222
});
221223
});
224+
225+
describe('Jumbo Transaction', function () {
226+
it('@release should execute "eth_sendRawTransaction" with Jumbo Transaction', async function () {
227+
const isJumboTransaction = ConfigService.get('JUMBO_TX_ENABLED');
228+
// skip this test if JUMBO_TX_ENABLED is false
229+
if (!isJumboTransaction) {
230+
this.skip();
231+
}
232+
233+
const gasPrice = await relay.gasPrice(requestId);
234+
const transaction = {
235+
type: 2,
236+
chainId: Number(CHAIN_ID),
237+
nonce: await relay.getAccountNonce(accounts[1].address, requestId),
238+
maxPriorityFeePerGas: gasPrice,
239+
maxFeePerGas: gasPrice,
240+
gasLimit: defaultGasLimit,
241+
to: accounts[0].address,
242+
data: '0x' + '00'.repeat(6144), // = 6kb just barely above the HFS threshold to trigger the jumbo transaction flow
243+
};
244+
245+
const signedTx = await accounts[1].wallet.signTransaction(transaction);
246+
const transactionHash = await relay.sendRawTransaction(signedTx, requestId);
247+
await relay.pollForValidTransactionReceipt(transactionHash);
248+
249+
const info = await mirrorNode.get(`/contracts/results/${transactionHash}`, requestId);
250+
expect(info).to.exist;
251+
});
252+
});
222253
});

packages/server/tests/localAcceptance.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ HAPI_CLIENT_ERROR_RESET=[21, 50]
1818
FILTER_API_ENABLED=true
1919
WS_RELAY_URL=ws://127.0.0.1:8546
2020
DEBUG_API_ENABLED=true
21-
SEND_RAW_TRANSACTION_SIZE_LIMIT=131072
2221
BATCH_REQUESTS_ENABLED=true
2322
TEST_GAS_PRICE_DEVIATION=0.2
2423
TEST_TRANSACTION_RECORD_COST_TOLERANCE=0.05
@@ -33,4 +32,5 @@ HBAR_RATE_LIMIT_DURATION=86400000# 24 hours
3332
HBAR_RATE_LIMIT_BASIC=6000000000# 60 HBARs
3433
HBAR_SPENDING_PLANS_CONFIG_FILE=./packages/server/tests/testSpendingPlansConfig.json
3534
USE_ASYNC_TX_PROCESSING=false
35+
JUMBO_TX_ENABLED=false
3636

0 commit comments

Comments
 (0)