Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielailie committed Dec 9, 2024
1 parent e8aa3e2 commit cbe8b53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/testutils/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
12 changes: 6 additions & 6 deletions src/transaction.local.net.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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));
});
Expand All @@ -94,15 +94,15 @@ 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 });
await provider.sendTransaction(transactionOne);
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));
});
Expand Down Expand Up @@ -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,
Expand All @@ -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));
});
Expand Down

0 comments on commit cbe8b53

Please sign in to comment.