From cbe8b5301a585a1efb7fe6838f97d73027ab8b54 Mon Sep 17 00:00:00 2001 From: danielailie Date: Mon, 9 Dec 2024 22:48:36 +0200 Subject: [PATCH] Fix integration tests --- src/testutils/wallets.ts | 5 +++++ src/transaction.local.net.spec.ts | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/testutils/wallets.ts b/src/testutils/wallets.ts index 0dac24a8..b6631444 100644 --- a/src/testutils/wallets.ts +++ b/src/testutils/wallets.ts @@ -116,4 +116,9 @@ export class TestWallet { this.account.nonce = accountOnNetwork.nonce; return this; } + + async getBalance(provider: IAccountFetcher) { + let accountOnNetwork = await provider.getAccount(this.address); + return accountOnNetwork.balance; + } } diff --git a/src/transaction.local.net.spec.ts b/src/transaction.local.net.spec.ts index 8d8201dd..45d3b830 100644 --- a/src/transaction.local.net.spec.ts +++ b/src/transaction.local.net.spec.ts @@ -55,7 +55,7 @@ describe("test transaction", function () { await alice.sync(provider); await bob.sync(provider); - let initialBalanceOfBob = new BigNumber(bob.account.balance.toString()); + let initialBalanceOfBob = new BigNumber((await bob.getBalance(provider)).toString()); transactionOne.setNonce(alice.account.nonce); alice.account.incrementNonce(); @@ -71,7 +71,7 @@ describe("test transaction", function () { await watcher.awaitCompleted(transactionTwo.getHash().hex()); await bob.sync(provider); - let newBalanceOfBob = new BigNumber(bob.account.balance.toString()); + let newBalanceOfBob = new BigNumber((await bob.getBalance(provider)).toString()); assert.deepEqual(TokenTransfer.egldFromAmount(85).valueOf(), newBalanceOfBob.minus(initialBalanceOfBob)); }); @@ -94,7 +94,7 @@ describe("test transaction", function () { await alice.sync(provider); await bob.sync(provider); - let initialBalanceOfBob = new BigNumber(bob.account.balance.toString()); + let initialBalanceOfBob = new BigNumber((await bob.getBalance(provider)).toString()); transactionOne.setNonce(alice.account.nonce); await signTransaction({ transaction: transactionOne, wallet: alice }); @@ -102,7 +102,7 @@ describe("test transaction", function () { await watcher.awaitCompleted(transactionOne.getHash().hex()); await bob.sync(provider); - let newBalanceOfBob = new BigNumber(bob.account.balance.toString()); + let newBalanceOfBob = new BigNumber((await bob.getBalance(provider)).toString()); assert.deepEqual(TokenTransfer.egldFromAmount(42).valueOf(), newBalanceOfBob.minus(initialBalanceOfBob)); }); @@ -155,7 +155,7 @@ describe("test transaction", function () { await alice.sync(provider); await bob.sync(provider); - const initialBalanceOfBob = new BigNumber(bob.account.balance.toString()); + const initialBalanceOfBob = new BigNumber((await bob.getBalance(provider)).toString()); const transaction = factory.createTransactionForNativeTokenTransfer(alice.address, { receiver: bob.address, @@ -170,7 +170,7 @@ describe("test transaction", function () { await watcher.awaitCompleted(txHash); await bob.sync(provider); - const newBalanceOfBob = new BigNumber(bob.account.balance.toString()); + const newBalanceOfBob = new BigNumber((await bob.getBalance(provider)).toString()); assert.deepEqual(TokenTransfer.egldFromAmount(42).valueOf(), newBalanceOfBob.minus(initialBalanceOfBob)); });