-
Notifications
You must be signed in to change notification settings - Fork 314
/
test-balance.ts
44 lines (36 loc) · 1.95 KB
/
test-balance.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { expect } from "chai";
import { step } from "mocha-steps";
import { describeWithAcala } from "./util";
import { ethers } from "ethers";
describeWithAcala("Acala RPC (Balance)", (context) => {
let alice: Signer;
let alice_stash: Signer;
async function transfer() {
return new Promise(async (resolve) => {
context.provider.api.tx.balances.transfer(await alice_stash.getSubstrateAddress(), 1000).signAndSend(await alice.getSubstrateAddress(), (result) => {
if (result.status.isInBlock) {
resolve(undefined);
}
});
});
}
before("init wallets", async function () {
[ alice, alice_stash ] = await context.provider.getWallets();
});
step("genesis balance is setup correctly", async function () {
expect((await context.provider.getBalance(alice.getAddress())).toString()).to.equal("8999999986219144000");
expect((await context.provider.getBalance(alice.getAddress(), "latest")).toString()).to.equal("8999999986219144000");
expect((await context.provider.getBalance(alice.getAddress(), "latest")).toString())
.to.equal((await context.provider.api.query.system.account(await alice.getSubstrateAddress())).data.free.toString());
});
step("balance to be updated after transfer", async function () {
this.timeout(15000);
expect((await context.provider.getBalance(alice.getAddress())).toString()).to.equal("8999999986219144000");
expect((await context.provider.getBalance(alice_stash.getAddress())).toString()).to.equal("10100000986219149180");
await transfer();
expect((await context.provider.getBalance(alice.getAddress())).toString()).to.equal("8999999969451542608");
expect((await context.provider.getBalance(alice_stash.getAddress())).toString()).to.equal("10100000986219150180");
expect((await context.provider.getBalance(alice.getAddress(), "latest")).toString()).to.equal("8999999969451542608");
expect((await context.provider.getBalance(alice_stash.getAddress(), "earliest")).toString()).to.equal("10100001000000000000");
});
});