Fix embark test using node option

This commit is contained in:
Anthony Laibe 2018-09-11 14:45:50 +01:00
parent 4e3e27df6c
commit 63d2478dd0
1 changed files with 22 additions and 10 deletions

View File

@ -1,22 +1,34 @@
/*global contract, it, embark, assert, before*/ /*global contract, it, embark, assert, before, web3*/
const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); const SimpleStorage = embark.require('Embark/contracts/SimpleStorage');
const Utils = require('embarkjs').Utils;
contract("SimpleStorage Deploy", function () { contract("SimpleStorage Deploy", function () {
let SimpleStorageInstance; let simpleStorageInstance;
before(function(done) {
before(async function() { Utils.secureSend(web3, SimpleStorage.deploy({arguments: [150]}), {}, true, function(err, receipt) {
SimpleStorageInstance = await SimpleStorage.deploy({arguments: [150]}).send(); if(err) {
return done(err);
}
simpleStorageInstance = SimpleStorage;
simpleStorageInstance.options.address = receipt.contractAddress;
done();
});
}); });
it("should set constructor value", async function () { it("should set constructor value", async function () {
let result = await SimpleStorageInstance.methods.storedData().call(); let result = await simpleStorageInstance.methods.storedData().call();
assert.strictEqual(parseInt(result, 10), 150); assert.strictEqual(parseInt(result, 10), 150);
}); });
it("set storage value", async function () { it("set storage value", function (done) {
await SimpleStorageInstance.methods.set(150).send(); Utils.secureSend(web3, simpleStorageInstance.methods.set(200), {}, false, async function(err) {
let result = await SimpleStorageInstance.methods.get().call(); if (err) {
assert.strictEqual(parseInt(result, 10), 150); return done(err);
}
let result = await simpleStorageInstance.methods.get().call();
assert.strictEqual(parseInt(result, 10), 200);
done();
});
}); });
}); });