mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-13 07:14:29 +00:00
991d958436
[PR 1318][PR1318] introduces a monorepo member that's used as a DApp dependency, but the present arrangement whereby `test_dapps/` is an embedded monorepo makes it difficult to develop and test such packages in tandem with changes to `test_dapps/packages/*`. Reorganize `test_dapps/*` as members of the root monorepo and make various adjustments accordingly. This makes it easy to develop test dapps and any packages they depend on simultaneously, but we lose the CI/QA arrangement where test dapps are run with an embark installed from fresh tarballs. That arrangement, which is quite worthwhile as a means to detect problems arising from transitive dependencies as soon as possible, will be re-introduced in another PR, possibly involving an auxiliary repository such as embark-framework/dapp-bin. Since the `package.json` `"test"` scripts of `test_dapps/*` are now kicked off as part of `yarn test` in the root, and since port allocation isn't fully dynamic, it's important to run `yarn test` with `lerna run`'s `--concurrency=1` option. For the same reasons, the root `ci` and `qa` scripts are similarly restricted. In the future, this setup can be refactored and improved, along with use of `lerna run`'s `--since` option to increase testing efficiency in CI. [PR1318]: https://github.com/embark-framework/embark/pull/1318
68 lines
1.9 KiB
JavaScript
68 lines
1.9 KiB
JavaScript
/*global embark, config, it, web3*/
|
|
const assert = require('assert');
|
|
|
|
let gasUsedForDeploy = 0;
|
|
let gasPrice = 1;
|
|
let accounts;
|
|
|
|
config({
|
|
deployment: {
|
|
accounts: [
|
|
// you can configure custom accounts with a custom balance
|
|
// see https://embark.status.im/docs/contracts_testing.html#Configuring-accounts
|
|
{
|
|
privateKey: "random",
|
|
balance: "100000 ether"
|
|
}
|
|
]
|
|
},
|
|
contracts: {
|
|
"Token": {
|
|
deploy: false,
|
|
args: [1000]
|
|
},
|
|
"MyToken2": {
|
|
instanceOf: "Token",
|
|
args: [2000]
|
|
},
|
|
"SomeContract": {
|
|
"args": [
|
|
["$MyToken2", "$accounts[0]"],
|
|
100
|
|
]
|
|
},
|
|
"SimpleStorage": {
|
|
args: [100]
|
|
}
|
|
}
|
|
}, (_err, web3_accounts) => {
|
|
accounts = web3_accounts;
|
|
});
|
|
|
|
// must be declared outside of the 'before' block, otherwise
|
|
// the 'block:header' event does not fire
|
|
embark.events.on("block:header", (blockHeader) => {
|
|
gasUsedForDeploy += blockHeader.gasUsed;
|
|
});
|
|
|
|
describe("Account balance", function () {
|
|
before(function (done) {
|
|
embark.events.request("blockchain:gasPrice", (err, blkGasPrice) => {
|
|
if (err) {
|
|
return next(new Error(__("could not get the gas price")));
|
|
}
|
|
gasPrice = parseInt(blkGasPrice, 10);
|
|
done();
|
|
});
|
|
});
|
|
it('should create an account balance from a large ether value in config', async function () {
|
|
const shouldBeWeiBN = web3.utils.toBN('100000000000000000000000');
|
|
const actualBalanceWei = await web3.eth.getBalance(accounts[0]);
|
|
const actualBalanceWeiBN = web3.utils.toBN(actualBalanceWei);
|
|
const gasUsedWeiBN = web3.utils.toBN((gasUsedForDeploy * gasPrice).toString());
|
|
const totalBalanceWeiBN = actualBalanceWeiBN.add(gasUsedWeiBN);
|
|
assert.ok(totalBalanceWeiBN.gte(shouldBeWeiBN), "Total balance (account balance + deployment costs) should be greater than or equal to 100K ether");
|
|
});
|
|
});
|
|
|