Skip to content

Commit a0e762f

Browse files
authored
fix: Resolve issue with failing acceptance batch 1 test (#2546)
* fix: resolve issue with failing test Signed-off-by: Ivo Yankov <[email protected]> * chore: fix sonarcloud Signed-off-by: Ivo Yankov <[email protected]> * chore: revert changes in package-lock Signed-off-by: Ivo Yankov <[email protected]> --------- Signed-off-by: Ivo Yankov <[email protected]>
1 parent de03c6c commit a0e762f

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
782782
.setTransactionMemo('Relay test token transfer');
783783
const resp = await transaction.execute(servicesNode.client);
784784
await resp.getRecord(servicesNode.client);
785-
await new Promise((r) => setTimeout(r, 1000));
785+
await Utils.wait(1000);
786786
const logsRes = await mirrorNode.get(`/contracts/results/logs?limit=1`, requestId);
787787
const blockNumber = logsRes.logs[0].block_number;
788788
const formattedBlockNumber = prepend0x(blockNumber.toString(16));
@@ -856,7 +856,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
856856
};
857857
const signedSendHbarTx = await accounts[0].wallet.signTransaction(sendHbarTx);
858858
await relay.sendRawTransaction(signedSendHbarTx, requestId);
859-
await new Promise((r) => setTimeout(r, 5000)); // wait for signer's account to propagate accross the network
859+
await Utils.wait(5000); // wait for signer's account to propagate accross the network
860860
const deployerBalance = await global.relay.getBalance(constants.DETERMINISTIC_DEPLOYMENT_SIGNER, 'latest');
861861
expect(deployerBalance).to.not.eq(0);
862862

@@ -914,7 +914,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
914914
const transactionHash = await relay.sendRawTransaction(signedTx, requestId);
915915
// Since the transactionId is not available in this context
916916
// Wait for the transaction to be processed and imported in the mirror node with axios-retry
917-
await new Promise((r) => setTimeout(r, 5000));
917+
await Utils.wait(5000);
918918
await mirrorNode.get(`/contracts/results/${transactionHash}`, requestId);
919919

920920
const receiverEndBalance = await relay.getBalance(parentContractAddress, 'latest', requestId);
@@ -949,7 +949,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
949949
const transactionHash = await relay.sendRawTransaction(signedTx, requestId);
950950
// Since the transactionId is not available in this context
951951
// Wait for the transaction to be processed and imported in the mirror node with axios-retry
952-
await new Promise((r) => setTimeout(r, 5000));
952+
await Utils.wait(5000);
953953
await mirrorNode.get(`/contracts/results/${transactionHash}`, requestId);
954954

955955
const receiverEndBalance = await relay.getBalance(parentContractAddress, 'latest', requestId);
@@ -1081,7 +1081,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
10811081

10821082
// Since the transactionId is not available in this context
10831083
// Wait for the transaction to be processed and imported in the mirror node with axios-retry
1084-
await new Promise((r) => setTimeout(r, 5000));
1084+
await Utils.wait(5000);
10851085

10861086
await mirrorNode.get(`/contracts/results/${transactionHash}`, requestId);
10871087
const receiverEndBalance = await relay.getBalance(parentContractAddress, 'latest', requestId);
@@ -1124,6 +1124,8 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
11241124

11251125
const signedTx = await accounts[2].wallet.signTransaction(transaction);
11261126
const transactionHash = await relay.sendRawTransaction(signedTx, requestId);
1127+
1128+
await Utils.wait(1000);
11271129
const txInfo = await mirrorNode.get(`/contracts/results/${transactionHash}`, requestId);
11281130

11291131
const contractResult = await mirrorNode.get(`/contracts/${txInfo.contract_id}`);

packages/server/tests/helpers/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,8 @@ export class Utils {
368368
}, delayMs);
369369
});
370370
}
371+
372+
static async wait(time: number): Promise<void> {
373+
await new Promise((r) => setTimeout(r, time));
374+
}
371375
}

0 commit comments

Comments
 (0)