embark/dapps/templates/demo/test/simple_storage_spec.js
Pascal Precht b021689387 feat(@embark/test-runner): introduce artifacts.require API
This commit adds a convenience API `artifacts.require(name)` that aims to make
requiring artifacts a little bit more straight forward.

Usage:

```
const SimpleStorage = artifacts.require('SimpleStorage');
const EmbarkJS = artifacts.require('EmbarkJS');
```
2020-02-12 14:17:30 -05:00

44 lines
1.2 KiB
JavaScript

/*global artifacts, contract, config, it, assert, web3*/
const SimpleStorage = artifacts.require('SimpleStorage');
let accounts;
// For documentation please see https://framework.embarklabs.io/docs/contracts_testing.html
config({
//blockchain: {
// accounts: [
// // you can configure custom accounts with a custom balance
// // see https://framework.embarklabs.io/docs/contracts_testing.html#Configuring-accounts
// ]
//},
contracts: {
deploy: {
"SimpleStorage": {
args: [100]
}
}
}
}, (_err, web3_accounts) => {
accounts = web3_accounts;
});
contract("SimpleStorage", function () {
this.timeout(0);
it("should set constructor value", async function () {
let result = await SimpleStorage.methods.storedData().call();
assert.strictEqual(parseInt(result, 10), 100);
});
it("set storage value", async function () {
await SimpleStorage.methods.set(150).send({from: web3.eth.defaultAccount});
let result = await SimpleStorage.methods.get().call();
assert.strictEqual(parseInt(result, 10), 150);
});
it("should have account with balance", async function() {
let balance = await web3.eth.getBalance(accounts[0]);
assert.ok(parseInt(balance, 10) > 0);
});
});