-
Notifications
You must be signed in to change notification settings - Fork 495
/
simple_storage_deploy_spec.js
36 lines (32 loc) · 1.15 KB
/
simple_storage_deploy_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
/*global contract, it, assert, before, web3*/
const SimpleStorage = require('Embark/contracts/SimpleStorage');
const {Utils} = require('Embark/EmbarkJS');
contract("SimpleStorage Deploy", function () {
let simpleStorageInstance;
before(function() {
return new Promise(async (resolve, reject) => {
SimpleStorage.deploy([150]);
SimpleStorage.deployed().then(instance => {
simpleStorageInstance = instance;
resolve();
});
});
});
it("should set constructor value", async function () {
let result = await simpleStorageInstance.methods.storedData().call();
assert.strictEqual(parseInt(result, 10), 150);
});
it("set storage value", function() {
return new Promise(async (resolve, reject) => {
const gas = await simpleStorageInstance.methods.set(200).estimateGas();
Utils.secureSend(web3, simpleStorageInstance.methods.set(200), {gas}, false, async function(err) {
if (err) {
return reject(err);
}
let result = await simpleStorageInstance.methods.get().call();
assert.strictEqual(parseInt(result, 10), 200);
resolve();
});
});
});
});