embark/dapps/tests/app/test/simple_storage_deploy_spec.js
Jonathan Rainville 2193d82399 fix(test-app): make test app test all pass (#1980)
Fix a lot of bugs and reenable a couple of modules
Some tests were kept disabled, mostly the ENS and EmbarkJS tests
Those need to add back a fairly significant feature to work
Add back missing solidity contracts
2019-10-22 09:27:22 -04:00

41 lines
1.4 KiB
JavaScript

/*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) => {
const gas = await SimpleStorage.deploy({arguments: [150]}).estimateGas();
Utils.secureSend(web3, SimpleStorage.deploy({arguments: [150]}), {gas, from: web3.eth.defaultAccount}, true, function(err, receipt) {
if(err) {
return reject(err);
}
simpleStorageInstance = SimpleStorage;
simpleStorageInstance.options.address = receipt.contractAddress;
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();
});
});
});
});