embark/dapps/tests/contracts/test/simple_storage_spec.js

31 lines
773 B
JavaScript
Raw Normal View History

2018-06-07 16:14:42 -04:00
/*global contract, config, it*/
2018-06-01 13:35:15 -04:00
const assert = require('assert');
2018-06-07 16:14:42 -04:00
const SimpleStorage = require('Embark/contracts/SimpleStorage');
config({
contracts: {
deploy: {
"SimpleStorage": {
args: [100]
}
}
}
});
2018-06-01 13:35:15 -04:00
contract("SimpleStorage", function () {
2018-01-05 15:10:47 -05:00
this.timeout(0);
2018-01-15 09:51:45 -05:00
2018-06-01 13:35:15 -04:00
it("should set constructor value", async function () {
let result = await SimpleStorage.methods.storedData().call();
2018-06-01 13:35:15 -04:00
assert.strictEqual(parseInt(result, 10), 100);
2017-02-09 19:38:02 -05:00
});
2018-06-01 13:35:15 -04:00
it("set storage value", async function () {
const toSend = SimpleStorage.methods.set(150);
const gas = await toSend.estimateGas();
await toSend.send({gas});
let result = await SimpleStorage.methods.get().call();
2018-06-01 13:35:15 -04:00
assert.strictEqual(parseInt(result, 10), 499650);
2017-02-09 19:38:02 -05:00
});
});