Skip to content

Commit be81410

Browse files
authored
feat: enhance acceptance test suite for Consensus Node XTS (#4329)
Signed-off-by: Logan Nguyen <[email protected]>
1 parent 4361c54 commit be81410

File tree

3 files changed

+50
-24
lines changed

3 files changed

+50
-24
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"acceptancetest:serverconfig": "c8 ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@server-config' --exit",
6868
"acceptancetest:send_raw_transaction_extension": "c8 ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@sendRawTransactionExtension' --exit",
6969
"acceptancetest:debug": "c8 ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@debug' --exit",
70+
"acceptancetest:xts": "c8 ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@xts' --exit",
7071
"build": "npx lerna run build",
7172
"build-and-test": "npx lerna run build && npx lerna run test",
7273
"build:docker": "docker build . -t ${npm_package_name}",

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

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
987987
await Assertions.assertPredefinedRpcError(error, sendRawTransaction, true, relay, [signedTx, requestDetails]);
988988
});
989989

990-
it('should execute "eth_sendRawTransaction" for deterministic deployment transaction', async function () {
990+
it('@xts should execute "eth_sendRawTransaction" for deterministic deployment transaction', async function () {
991991
// send gas money to the proxy deployer
992992
const sendHbarTx = {
993993
...defaultLegacyTransactionData,
@@ -997,8 +997,8 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
997997
gasPrice: await relay.gasPrice(),
998998
};
999999
const signedSendHbarTx = await accounts[0].wallet.signTransaction(sendHbarTx);
1000-
await relay.sendRawTransaction(signedSendHbarTx);
1001-
await Utils.wait(5000); // wait for signer's account to propagate accross the network
1000+
const txHash = await relay.sendRawTransaction(signedSendHbarTx);
1001+
await relay.pollForValidTransactionReceipt(txHash);
10021002
const deployerBalance = await global.relay.getBalance(Constants.DETERMINISTIC_DEPLOYMENT_SIGNER, 'latest');
10031003
expect(deployerBalance).to.not.eq(0);
10041004

@@ -1038,7 +1038,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
10381038
}
10391039
});
10401040

1041-
it('@release-light, @release should execute "eth_sendRawTransaction" for legacy EIP 155 transactions', async function () {
1041+
it('@release-light @release @xts should execute "eth_sendRawTransaction" for legacy EIP 155 transactions', async function () {
10421042
const receiverInitialBalance = await relay.getBalance(parentContractAddress, 'latest');
10431043
const gasPriceWithDeviation = await getGasWithDeviation(relay, gasPriceDeviation);
10441044
const transaction = {
@@ -1049,9 +1049,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
10491049
};
10501050
const signedTx = await accounts[2].wallet.signTransaction(transaction);
10511051
const transactionHash = await relay.sendRawTransaction(signedTx);
1052-
// Since the transactionId is not available in this context
1053-
// Wait for the transaction to be processed and imported in the mirror node with axios-retry
1054-
await Utils.wait(5000);
1052+
await relay.pollForValidTransactionReceipt(transactionHash);
10551053
await mirrorNode.get(`/contracts/results/${transactionHash}`);
10561054

10571055
const receiverEndBalance = await relay.getBalance(parentContractAddress, 'latest');
@@ -1074,7 +1072,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
10741072
await Assertions.assertPredefinedRpcError(error, sendRawTransaction, true, relay, [signedTx, requestDetails]);
10751073
});
10761074

1077-
it('should execute "eth_sendRawTransaction" for legacy transactions (with no chainId i.e. chainId=0x0)', async function () {
1075+
it('@xts should execute "eth_sendRawTransaction" for legacy transactions (with no chainId i.e. chainId=0x0)', async function () {
10781076
const receiverInitialBalance = await relay.getBalance(parentContractAddress, 'latest');
10791077
const transaction = {
10801078
...defaultLegacyTransactionData,
@@ -1084,17 +1082,15 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
10841082
};
10851083
const signedTx = await accounts[2].wallet.signTransaction(transaction);
10861084
const transactionHash = await relay.sendRawTransaction(signedTx);
1087-
// Since the transactionId is not available in this context
1088-
// Wait for the transaction to be processed and imported in the mirror node with axios-retry
1089-
await Utils.wait(5000);
1085+
await relay.pollForValidTransactionReceipt(transactionHash);
10901086
await mirrorNode.get(`/contracts/results/${transactionHash}`);
10911087

10921088
const receiverEndBalance = await relay.getBalance(parentContractAddress, 'latest');
10931089
const balanceChange = receiverEndBalance - receiverInitialBalance;
10941090
expect(balanceChange.toString()).to.eq(Number(ONE_TINYBAR).toString());
10951091
});
10961092

1097-
it('should return transaction result with no chainId field for legacy EIP155 transactions (with no chainId i.e. chainId=0x0)', async function () {
1093+
it('@xts should execute "eth_sendRawTransaction" with no chainId field for legacy EIP155 transactions (with no chainId i.e. chainId=0x0)', async function () {
10981094
const transaction = {
10991095
...defaultLegacyTransactionData,
11001096
to: parentContractAddress,
@@ -1197,7 +1193,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
11971193
await Assertions.assertPredefinedRpcError(error, sendRawTransaction, true, relay, [signedTx, requestDetails]);
11981194
});
11991195

1200-
it('should execute "eth_sendRawTransaction" for London transactions', async function () {
1196+
it('@xts should execute "eth_sendRawTransaction" for London transactions', async function () {
12011197
const receiverInitialBalance = await relay.getBalance(parentContractAddress, 'latest');
12021198
const gasPrice = await relay.gasPrice();
12031199

@@ -1210,18 +1206,14 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
12101206
};
12111207
const signedTx = await accounts[2].wallet.signTransaction(transaction);
12121208
const transactionHash = await relay.sendRawTransaction(signedTx);
1213-
1214-
// Since the transactionId is not available in this context
1215-
// Wait for the transaction to be processed and imported in the mirror node with axios-retry
1216-
await Utils.wait(5000);
1217-
1209+
await relay.pollForValidTransactionReceipt(transactionHash);
12181210
await mirrorNode.get(`/contracts/results/${transactionHash}`);
12191211
const receiverEndBalance = await relay.getBalance(parentContractAddress, 'latest');
12201212
const balanceChange = receiverEndBalance - receiverInitialBalance;
12211213
expect(balanceChange.toString()).to.eq(Number(ONE_TINYBAR).toString());
12221214
});
12231215

1224-
it('should execute "eth_sendRawTransaction" and deploy a large contract', async function () {
1216+
it('@xts should execute "eth_sendRawTransaction" and deploy a large contract', async function () {
12251217
const gasPrice = await relay.gasPrice();
12261218
const transaction = {
12271219
type: 2,
@@ -1235,6 +1227,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
12351227

12361228
const signedTx = await accounts[2].wallet.signTransaction(transaction);
12371229
const transactionHash = await relay.sendRawTransaction(signedTx);
1230+
await relay.pollForValidTransactionReceipt(transactionHash);
12381231
const info = await mirrorNode.get(`/contracts/results/${transactionHash}`);
12391232
expect(info).to.have.property('contract_id');
12401233
expect(info.contract_id).to.not.be.null;
@@ -1245,7 +1238,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
12451238
// note: according to this ticket https://github.com/hiero-ledger/hiero-json-rpc-relay/issues/2563,
12461239
// if calldata's size fails into the range of [2568 bytes, 5217 bytes], the request fails and throw
12471240
// `Null Entity ID` error. This unit test makes sure that with the new fix, requests should work with all case scenarios.
1248-
it('should execute "eth_sendRawTransaction" and deploy a contract with any arbitrary calldata size', async () => {
1241+
it('@xts should execute "eth_sendRawTransaction" and deploy a contract with any arbitrary calldata size', async () => {
12491242
const gasPrice = await relay.gasPrice();
12501243

12511244
const randomBytes = [2566, 2568, 3600, 5217, 7200];
@@ -1262,6 +1255,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
12621255
};
12631256
const signedTx = await accounts[0].wallet.signTransaction(transaction);
12641257
const transactionHash = await relay.sendRawTransaction(signedTx);
1258+
await relay.pollForValidTransactionReceipt(transactionHash);
12651259
const info = await mirrorNode.get(`/contracts/results/${transactionHash}`);
12661260
expect(info).to.have.property('contract_id');
12671261
expect(info.contract_id).to.not.be.null;
@@ -1297,7 +1291,35 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
12971291
expect(fileInfo.size.toNumber()).to.eq(0);
12981292
});
12991293

1300-
it('should execute "eth_sendRawTransaction" of type 1 and deploy a real contract', async function () {
1294+
it('@xts should execute "eth_sendRawTransaction" and deploy a real contract which can be accessible', async function () {
1295+
// deploy contract
1296+
const deploymentTransaction = {
1297+
...defaultLondonTransactionData,
1298+
value: 0,
1299+
data: basicContract.bytecode,
1300+
nonce: await relay.getAccountNonce(accounts[2].address),
1301+
};
1302+
const signedTx = await accounts[2].wallet.signTransaction(deploymentTransaction);
1303+
const deploymentTxHash = await relay.sendRawTransaction(signedTx);
1304+
await relay.pollForValidTransactionReceipt(deploymentTxHash);
1305+
1306+
// confirm contract deployment successful via MN
1307+
const info = await mirrorNode.get(`/contracts/results/${deploymentTxHash}`);
1308+
expect(info).to.have.property('address');
1309+
expect(info.address).to.not.be.null;
1310+
const contractInfo = await mirrorNode.get(`/contracts/${info.address}`);
1311+
expect(contractInfo).to.have.property('bytecode');
1312+
expect(contractInfo.bytecode).to.not.be.null;
1313+
1314+
// confirm contract accessibility
1315+
const deployedContract = new ethers.Contract(info.address, basicContract.abi, accounts[2].wallet);
1316+
expect(await deployedContract.getAddress()).to.eq(contractInfo.evm_address);
1317+
expect(await deployedContract.getDeployedCode()).to.eq(contractInfo.runtime_bytecode);
1318+
const result = await deployedContract.ping();
1319+
expect(result).to.eq(1n);
1320+
});
1321+
1322+
it('@xts should execute "eth_sendRawTransaction" of type 1 and deploy a real contract', async function () {
13011323
//omitting the "to" and "nonce" fields when creating a new contract
13021324
const transaction = {
13031325
...defaultLegacy2930TransactionData,
@@ -1308,6 +1330,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
13081330

13091331
const signedTx = await accounts[2].wallet.signTransaction(transaction);
13101332
const transactionHash = await relay.sendRawTransaction(signedTx);
1333+
await relay.pollForValidTransactionReceipt(transactionHash);
13111334
const info = await mirrorNode.get(`/contracts/results/${transactionHash}`);
13121335
expect(info).to.have.property('contract_id');
13131336
expect(info.contract_id).to.not.be.null;
@@ -1318,7 +1341,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
13181341
expect(info).to.have.property('access_list');
13191342
});
13201343

1321-
it('should execute "eth_sendRawTransaction" of type 2 and deploy a real contract', async function () {
1344+
it('@xts should execute "eth_sendRawTransaction" of type 2 and deploy a real contract', async function () {
13221345
//omitting the "to" and "nonce" fields when creating a new contract
13231346
const transaction = {
13241347
...defaultLondonTransactionData,
@@ -1329,6 +1352,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
13291352

13301353
const signedTx = await accounts[2].wallet.signTransaction(transaction);
13311354
const transactionHash = await relay.sendRawTransaction(signedTx);
1355+
await relay.pollForValidTransactionReceipt(transactionHash);
13321356
const info = await mirrorNode.get(`/contracts/results/${transactionHash}`);
13331357
expect(info).to.have.property('contract_id');
13341358
expect(info.contract_id).to.not.be.null;
@@ -1341,7 +1365,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
13411365
expect(info).to.have.property('access_list');
13421366
});
13431367

1344-
it('should execute "eth_sendRawTransaction" and deploy a contract with more than 2 HBAR transaction fee and less than max transaction fee', async function () {
1368+
it('@xts should execute "eth_sendRawTransaction" and deploy a contract with more than 2 HBAR transaction fee and less than max transaction fee', async function () {
13451369
const balanceBefore = await relay.getBalance(accounts[2].wallet.address, 'latest');
13461370

13471371
const gasPrice = await relay.gasPrice();
@@ -1357,6 +1381,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
13571381

13581382
const signedTx = await accounts[2].wallet.signTransaction(transaction);
13591383
const transactionHash = await relay.sendRawTransaction(signedTx);
1384+
await relay.pollForValidTransactionReceipt(transactionHash);
13601385
const info = await mirrorNode.get(`/contracts/results/${transactionHash}`);
13611386
const balanceAfter = await relay.getBalance(accounts[2].wallet.address, 'latest');
13621387
expect(info).to.have.property('contract_id');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ describe('@sendRawTransactionExtension Acceptance Tests', function () {
147147
});
148148

149149
describe('Jumbo Transaction', function () {
150-
it('@release should execute "eth_sendRawTransaction" with Jumbo Transaction', async function () {
150+
it('@release @xts should execute "eth_sendRawTransaction" with Jumbo Transaction', async function () {
151151
const isJumboTransaction = ConfigService.get('JUMBO_TX_ENABLED');
152152
// skip this test if JUMBO_TX_ENABLED is false
153153
if (!isJumboTransaction) {

0 commit comments

Comments
 (0)