2018-06-07 16:14:42 -04:00
|
|
|
/*global contract, config, it, web3*/
|
2018-06-01 10:48:29 -04:00
|
|
|
const assert = require('assert');
|
2018-06-07 16:14:42 -04:00
|
|
|
const AnotherStorage = require('Embark/contracts/AnotherStorage');
|
|
|
|
const SimpleStorage = require('Embark/contracts/SimpleStorage');
|
2018-06-01 10:48:29 -04:00
|
|
|
|
2019-10-17 14:39:25 -04:00
|
|
|
let accounts, defaultAccount;
|
2019-11-06 14:45:27 -05:00
|
|
|
const numAddresses = 10;
|
2018-06-06 16:43:08 -04:00
|
|
|
|
2018-06-01 10:48:29 -04:00
|
|
|
config({
|
2019-08-30 15:50:20 -05:00
|
|
|
blockchain: {
|
2018-06-06 15:33:48 -04:00
|
|
|
"accounts": [
|
|
|
|
{
|
2018-06-06 16:43:08 -04:00
|
|
|
"mnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm",
|
2019-11-06 14:45:27 -05:00
|
|
|
balance: "5ether",
|
|
|
|
numAddresses: 10
|
2018-06-06 15:33:48 -04:00
|
|
|
}
|
2018-07-31 11:01:52 +01:00
|
|
|
]
|
2018-06-06 15:33:48 -04:00
|
|
|
},
|
2018-06-01 10:48:29 -04:00
|
|
|
contracts: {
|
2019-08-30 15:50:20 -05:00
|
|
|
deploy: {
|
|
|
|
"SimpleStorage": {
|
|
|
|
args: [100]
|
|
|
|
},
|
|
|
|
"AnotherStorage": {
|
|
|
|
args: ["$SimpleStorage"]
|
|
|
|
}
|
2018-06-01 10:48:29 -04:00
|
|
|
}
|
|
|
|
}
|
2018-06-06 16:43:08 -04:00
|
|
|
}, (err, theAccounts) => {
|
|
|
|
accounts = theAccounts;
|
2019-10-17 14:39:25 -04:00
|
|
|
defaultAccount = accounts[0];
|
2018-06-01 10:48:29 -04:00
|
|
|
});
|
|
|
|
|
2019-10-22 09:27:22 -04:00
|
|
|
contract("AnotherStorage", function() {
|
2018-01-05 15:10:47 -05:00
|
|
|
this.timeout(0);
|
2017-02-09 19:38:02 -05:00
|
|
|
|
2019-06-13 12:54:52 -04:00
|
|
|
it("should have got the default account in the describe", function () {
|
|
|
|
assert.strictEqual(defaultAccount, accounts[0]);
|
|
|
|
});
|
|
|
|
|
2018-06-08 13:10:47 -04:00
|
|
|
it("should have account with balance", async function() {
|
2019-10-22 09:27:22 -04:00
|
|
|
const balance = await web3.eth.getBalance(accounts[0]);
|
2018-06-08 13:10:47 -04:00
|
|
|
assert.ok(parseInt(balance, 10) > 4900000000000000000);
|
|
|
|
assert.ok(parseInt(balance, 10) <= 5000000000000000000);
|
|
|
|
});
|
|
|
|
|
2019-11-06 14:45:27 -05:00
|
|
|
it("should have the right balance for all other accounts ", async function() {
|
|
|
|
let balance;
|
|
|
|
|
|
|
|
for (let i = 1; i < numAddresses - 3; i++) {
|
|
|
|
balance = await web3.eth.getBalance(accounts[i]);
|
|
|
|
console.log('Account', i , balance);
|
|
|
|
assert.strictEqual(parseInt(balance, 10), 5000000000000000000, `Account ${i} doesn't have the balance set`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-04-17 14:48:31 -04:00
|
|
|
it("set SimpleStorage address", async function() {
|
|
|
|
let result = await AnotherStorage.methods.simpleStorageAddress().call();
|
|
|
|
assert.equal(result.toString(), SimpleStorage.options.address);
|
2017-02-09 19:38:02 -05:00
|
|
|
});
|
2018-06-06 16:43:08 -04:00
|
|
|
|
2018-06-10 12:11:34 -04:00
|
|
|
it("set SimpleStorage address with alternative syntax", async function() {
|
|
|
|
let result = await AnotherStorage.simpleStorageAddress();
|
|
|
|
assert.equal(result.toString(), SimpleStorage.options.address);
|
|
|
|
});
|
2017-02-09 19:38:02 -05:00
|
|
|
});
|