forked from valyakin/aa-testkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayments.spec.js
64 lines (45 loc) · 1.86 KB
/
payments.spec.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const { Testkit } = require('../../main')
const { Network } = Testkit()
describe('Check payments', function () {
this.timeout(60000 * 1000)
before(async () => {
this.network = await Network.create()
.run()
})
it('Check sending bytes', async () => {
const network = this.network
const genesis = await network.getGenesisNode().ready()
const alice = await network.newHeadlessWallet().ready()
const bob = await network.newHeadlessWallet().ready()
const aliceAddress = await alice.getAddress()
const bobAddress = await bob.getAddress()
const { unit: unit1 } = await genesis.sendBytes({ toAddress: aliceAddress, amount: 100000 })
await network.sync()
let aliceBalance = await alice.getBalance()
expect(aliceBalance.base.pending).to.be.equal(100000)
await network.witnessUntilStable(unit1)
aliceBalance = await alice.getBalance()
expect(aliceBalance.base.stable).to.be.equal(100000)
const { unit: unit2 } = await alice.sendBytes({ toAddress: bobAddress, amount: 50000 })
await network.sync()
aliceBalance = await alice.getBalance()
expect(aliceBalance.base.pending).to.be.equal(49172)
let bobBalance = await bob.getBalance()
expect(bobBalance.base.pending).to.be.equal(50000)
await network.witnessUntilStable(unit2)
aliceBalance = await alice.getBalance()
expect(aliceBalance.base.stable).to.be.equal(49626)
bobBalance = await bob.getBalance()
expect(bobBalance.base.stable).to.be.equal(50000)
const { unit: unit3 } = await genesis.sendBytes({ toAddress: aliceAddress, amount: 1e9 })
await network.sync()
aliceBalance = await alice.getBalance()
expect(aliceBalance.base.pending).to.be.equal(1000000000)
await network.witnessUntilStable(unit3)
aliceBalance = await alice.getBalance()
expect(aliceBalance.base.stable).to.be.equal(1000049626)
}).timeout(30000 * 1000)
after(async () => {
await this.network.stop()
})
})