-
Notifications
You must be signed in to change notification settings - Fork 5
/
wallet2-tests.js
executable file
·61 lines (53 loc) · 1.89 KB
/
wallet2-tests.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
const seedWithWaves = "create genesis wallet devnet-0"
const dappSeed = "dapp 1313159"
const userSeed = "user 1313159"
const dappAddress = address(dappSeed)
const userAddress = address(userSeed)
describe('Wallet test suite', () => {
it('funds dapp account', async function(){
console.log(dappAddress)
const ttx = transfer({ amount: 1000000000, recipient: dappAddress }, seedWithWaves)
await broadcast(ttx)
await waitForTx(ttx.id)
})
it('funds user account', async function(){
const ttx = transfer({ amount: 1000000000, recipient: userAddress }, seedWithWaves)
await broadcast(ttx)
await waitForTx(ttx.id)
})
it('deploys dapp script', async function(){
const ttx = setScript({ script: compile(file("wallet2.ride"))}, dappSeed)
await broadcast(ttx)
await waitForTx(ttx.id)
})
it('user deposits 3 waves', async function(){
const ttx = invokeScript({
dApp: dappAddress,
call:{function:"deposit",args:[]},
payment: [{amount: 300000000, asset:null }]},
userSeed
)
await broadcast(ttx)
await waitForTx(ttx.id)
})
it('user deposits 2 waves', async function(){
const ttx = invokeScript({
dApp: dappAddress,
call:{function:"deposit",args:[]},
payment: [{amount: 200000000, asset:null }]},
userSeed
)
await broadcast(ttx)
await waitForTx(ttx.id)
})
it('user withdraws 4 waves', async function(){
const ttx = invokeScript({
dApp: dappAddress,
call:{function:"withdraw",args:[{type: "integer", value: 400000000}]},
payment: []},
userSeed
)
await broadcast(ttx)
await waitForTx(ttx.id)
})
})