Skip to content

Commit

Permalink
fix: Resolve issue with failing acceptance batch 1 test (hashgraph#2546)
Browse files Browse the repository at this point in the history
* fix: resolve issue with failing test

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

* chore: fix sonarcloud

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

* chore: revert changes in package-lock

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>

---------

Signed-off-by: Ivo Yankov <ivo@devlabs.bg>
  • Loading branch information
Ivo-Yankov authored May 31, 2024
1 parent de03c6c commit a0e762f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions packages/server/tests/acceptance/rpc_batch1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
.setTransactionMemo('Relay test token transfer');
const resp = await transaction.execute(servicesNode.client);
await resp.getRecord(servicesNode.client);
await new Promise((r) => setTimeout(r, 1000));
await Utils.wait(1000);
const logsRes = await mirrorNode.get(`/contracts/results/logs?limit=1`, requestId);
const blockNumber = logsRes.logs[0].block_number;
const formattedBlockNumber = prepend0x(blockNumber.toString(16));
Expand Down Expand Up @@ -856,7 +856,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
};
const signedSendHbarTx = await accounts[0].wallet.signTransaction(sendHbarTx);
await relay.sendRawTransaction(signedSendHbarTx, requestId);
await new Promise((r) => setTimeout(r, 5000)); // wait for signer's account to propagate accross the network
await Utils.wait(5000); // wait for signer's account to propagate accross the network
const deployerBalance = await global.relay.getBalance(constants.DETERMINISTIC_DEPLOYMENT_SIGNER, 'latest');
expect(deployerBalance).to.not.eq(0);

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

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

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

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

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

const signedTx = await accounts[2].wallet.signTransaction(transaction);
const transactionHash = await relay.sendRawTransaction(signedTx, requestId);

await Utils.wait(1000);
const txInfo = await mirrorNode.get(`/contracts/results/${transactionHash}`, requestId);

const contractResult = await mirrorNode.get(`/contracts/${txInfo.contract_id}`);
Expand Down
4 changes: 4 additions & 0 deletions packages/server/tests/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,8 @@ export class Utils {
}, delayMs);
});
}

static async wait(time: number): Promise<void> {
await new Promise((r) => setTimeout(r, time));
}
}

0 comments on commit a0e762f

Please sign in to comment.