forked from valyakin/aa-testkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvars_setting_check.spec.js
61 lines (46 loc) · 1.73 KB
/
vars_setting_check.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
const { Testkit } = require('../../main')
const { Network } = Testkit()
const { varsSettingCheck } = require('./agents')
describe('AA state vars', function () {
this.timeout(60000)
before(async () => {
this.network = await Network.create().run()
})
it('Check agent deployment', async () => {
const network = this.network
const genesis = await network.getGenesisNode().ready()
const deployer = await network.newHeadlessWallet().ready()
const deployerAddress = await deployer.getAddress()
const wallet = await network.newHeadlessWallet().ready()
const walletAddress = await wallet.getAddress()
await genesis.sendBytes({ toAddress: deployerAddress, amount: 1000000 })
const { unit } = await genesis.sendBytes({ toAddress: walletAddress, amount: 1000000 })
await network.witnessUntilStable(unit)
const { address: agentAddress, unit: agentUnit } = await deployer.deployAgent(varsSettingCheck)
expect(agentAddress).to.be.validAddress
expect(agentUnit).to.be.validUnit
await network.witnessUntilStable(agentUnit)
this.agentAddress = agentAddress
this.deployer = deployer
this.wallet = wallet
}).timeout(30000)
it('Check agent state vars read', async () => {
const { agentAddress, wallet, network, deployer } = this
const { unit } = await wallet.triggerAaWithData({
toAddress: agentAddress,
amount: 10000,
data: {
var: 'trigger_var',
},
})
expect(unit).to.be.validUnit
await network.witnessUntilStable(unit)
const { vars } = await deployer.readAAStateVars(agentAddress)
expect(vars.constant_var).to.be.equal('constant_var')
expect(vars.trigger_var).to.be.equal('trigger_var')
expect(vars.sum_var).to.be.equal(579)
}).timeout(30000)
after(async () => {
await this.network.stop()
})
})