From 72a37c2c00a202fbaaa39e453ebca1c1fd8f9a5d Mon Sep 17 00:00:00 2001 From: renancloudwalk Date: Tue, 5 Mar 2024 15:23:46 -0300 Subject: [PATCH] fix: paralel tests for balance --- e2e/test/e2e-tx-parallel-contract.test.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/e2e/test/e2e-tx-parallel-contract.test.ts b/e2e/test/e2e-tx-parallel-contract.test.ts index f1a85caa3..c5fcdfa1a 100644 --- a/e2e/test/e2e-tx-parallel-contract.test.ts +++ b/e2e/test/e2e-tx-parallel-contract.test.ts @@ -71,23 +71,28 @@ describe("Transaction: parallel TestContractBalances", async () => { it("Sends parallel transactions that should have one success and one fail due to lack of balance", async () => { expect(await _contract.get(BOB.address)).eq(625); + const senders = randomAccounts(20); const signedTxsSub = []; - - for (let i = 0; i < 2; i++) { - const nonce = await sendGetNonce(ALICE.address); - const tx = await _contract.connect(ALICE.signer()).sub.populateTransaction(BOB.address, 600, { + for (let accountIndex = 0; accountIndex < senders.length; accountIndex++) { + const sender = senders[accountIndex]; + let nonce = await sendGetNonce(sender.address); + const tx = await _contract.connect(sender.signer()).sub.populateTransaction(BOB.address, 60, { nonce: nonce, ...TX_PARAMS, }); - signedTxsSub.push(await ALICE.signer().signTransaction(tx)); + nonce++; + + signedTxsSub.push(await sender.signer().signTransaction(tx)); } - const result = await sendRawTransactions(signedTxsSub); + let result = await sendRawTransactions(signedTxsSub); - // only one transaction should be successful expect(await _contract.get(BOB.address)).eq(25); - expect(result[1]).eq(undefined); + const undefinedCount = result.reduce((count, element) => { + return element === undefined ? count + 1 : count; + }, 0); + expect(undefinedCount).eq(10); }); });