Skip to content

Commit

Permalink
test: fix flaky test (#1326)
Browse files Browse the repository at this point in the history
  • Loading branch information
Torres-ssf authored Oct 10, 2023
1 parent fec3f74 commit 3b8648b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .changeset/nervous-bottles-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
17 changes: 12 additions & 5 deletions packages/fuel-gauge/src/multi-token-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ describe('MultiTokenContract', () => {
};

// validates contract has expected balance after mint
subIds.forEach(async (subId) => {
const validateMintPromises = subIds.map(async (subId) => {
expect(bn(await getBalance(contractId, helperDict[subId].assetId)).toNumber()).toBe(
helperDict[subId].amount
);
});

await Promise.all(validateMintPromises);

// transfer coins to user wallet
await multiTokenContract
.multiCall(
Expand All @@ -96,15 +98,16 @@ describe('MultiTokenContract', () => {
)
.call();

subIds.forEach(async (subId) => {
const validateTransferPromises = subIds.map(async (subId) => {
// validates that user wallet has expected balance after transfer
expect(bn(await userWallet.getBalance(helperDict[subId].assetId)).toNumber()).toBe(
helperDict[subId].amount
);

// validates contract has not balance after transfer
expect(bn(await getBalance(contractId, helperDict[subId].assetId)).toNumber()).toBe(0);
});

await Promise.all(validateTransferPromises);
});

it('can burn coins', async () => {
Expand Down Expand Up @@ -158,12 +161,14 @@ describe('MultiTokenContract', () => {
};

// validates contract has expected balance after mint
subIds.forEach(async (subId) => {
const validateMintPromises = subIds.map(async (subId) => {
expect(bn(await getBalance(contractId, helperDict[subId].assetId)).toNumber()).toBe(
helperDict[subId].amount
);
});

await Promise.all(validateMintPromises);

// burning coins
await multiTokenContract
.multiCall(
Expand All @@ -173,11 +178,13 @@ describe('MultiTokenContract', () => {
)
.call();

subIds.forEach(async (subId) => {
const validateBurnPromises = subIds.map(async (subId) => {
// validates contract has expected balance for each coin after burn
expect(bn(await getBalance(contractId, helperDict[subId].assetId)).toNumber()).toBe(
helperDict[subId].amount - helperDict[subId].amountToBurn
);
});

await Promise.all(validateBurnPromises);
});
});

0 comments on commit 3b8648b

Please sign in to comment.