embark/dapps/templates/demo/test/simple_storage_spec.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

/*global artifacts, contract, config, it, assert, web3*/
const SimpleStorage = artifacts.require('SimpleStorage');
2018-06-18 19:15:24 +00:00
2018-09-01 14:34:12 +00:00
let accounts;
2020-01-19 20:19:30 +00:00
// For documentation please see https://framework.embarklabs.io/docs/contracts_testing.html
2018-06-18 19:15:24 +00:00
config({
//blockchain: {
2018-09-01 14:34:12 +00:00
// accounts: [
// // you can configure custom accounts with a custom balance
2020-01-19 20:19:30 +00:00
// // see https://framework.embarklabs.io/docs/contracts_testing.html#Configuring-accounts
2018-09-01 14:34:12 +00:00
// ]
//},
2018-06-18 19:15:24 +00:00
contracts: {
deploy: {
"SimpleStorage": {
args: [100]
}
2018-06-18 19:15:24 +00:00
}
}
2018-09-01 14:34:12 +00:00
}, (_err, web3_accounts) => {
2019-07-12 14:51:26 +00:00
accounts = web3_accounts;
2018-06-18 19:15:24 +00:00
});
contract("SimpleStorage", function () {
2018-01-12 23:11:24 +00:00
this.timeout(0);
2015-10-12 14:50:52 +00:00
2018-06-18 19:15:24 +00:00
it("should set constructor value", async function () {
2018-04-17 18:48:31 +00:00
let result = await SimpleStorage.methods.storedData().call();
2018-06-18 19:15:24 +00:00
assert.strictEqual(parseInt(result, 10), 100);
2015-10-12 14:50:52 +00:00
});
2018-06-18 19:15:24 +00:00
it("set storage value", async function () {
await SimpleStorage.methods.set(150).send({from: web3.eth.defaultAccount});
2018-05-31 03:19:25 +00:00
let result = await SimpleStorage.methods.get().call();
2018-06-18 19:15:24 +00:00
assert.strictEqual(parseInt(result, 10), 150);
2015-10-12 14:50:52 +00:00
});
2018-09-01 14:34:12 +00:00
it("should have account with balance", async function() {
let balance = await web3.eth.getBalance(accounts[0]);
assert.ok(parseInt(balance, 10) > 0);
});
});