Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: paralel tests for balance #312

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions e2e/test/e2e-tx-parallel-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down
Loading