From 10e41dd4f2fc03566ea393fcb78d189cdabec5f3 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 1 Sep 2018 10:34:12 -0400 Subject: [PATCH] update examples --- templates/boilerplate/test/contract_spec.js | 22 +++++++++++++++++++-- templates/demo/test/simple_storage_spec.js | 16 +++++++++++++++ templates/simple/test/contract_spec.js | 22 +++++++++++++++++++-- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/templates/boilerplate/test/contract_spec.js b/templates/boilerplate/test/contract_spec.js index 20030176..71d999f3 100644 --- a/templates/boilerplate/test/contract_spec.js +++ b/templates/boilerplate/test/contract_spec.js @@ -1,12 +1,24 @@ // /*global contract, config, it, assert*/ -/*const SimpleStorage = require('Embark/contracts/SimpleStorage'); +/* +const SimpleStorage = require('Embark/contracts/SimpleStorage'); +let accounts; + +// For documentation please see https://embark.status.im/docs/contracts_testing.html config({ + //deployment: { + // accounts: [ + // // you can configure custom accounts with a custom balance + // // see https://embark.status.im/docs/contracts_testing.html#Configuring-accounts + // ] + //}, contracts: { "SimpleStorage": { args: [100] } } +}, (_err, web3_accounts) => { + accounts = web3_accounts }); contract("SimpleStorage", function () { @@ -22,4 +34,10 @@ contract("SimpleStorage", function () { 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); + }); +} +*/ diff --git a/templates/demo/test/simple_storage_spec.js b/templates/demo/test/simple_storage_spec.js index 262cd291..aa09607d 100644 --- a/templates/demo/test/simple_storage_spec.js +++ b/templates/demo/test/simple_storage_spec.js @@ -1,12 +1,23 @@ /*global contract, config, it, assert*/ const SimpleStorage = require('Embark/contracts/SimpleStorage'); +let accounts; + +// For documentation please see https://embark.status.im/docs/contracts_testing.html config({ + //deployment: { + // accounts: [ + // // you can configure custom accounts with a custom balance + // // see https://embark.status.im/docs/contracts_testing.html#Configuring-accounts + // ] + //}, contracts: { "SimpleStorage": { args: [100] } } +}, (_err, web3_accounts) => { + accounts = web3_accounts }); contract("SimpleStorage", function () { @@ -22,4 +33,9 @@ contract("SimpleStorage", function () { 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); + }); }); diff --git a/templates/simple/test/contract_spec.js b/templates/simple/test/contract_spec.js index 20030176..71d999f3 100644 --- a/templates/simple/test/contract_spec.js +++ b/templates/simple/test/contract_spec.js @@ -1,12 +1,24 @@ // /*global contract, config, it, assert*/ -/*const SimpleStorage = require('Embark/contracts/SimpleStorage'); +/* +const SimpleStorage = require('Embark/contracts/SimpleStorage'); +let accounts; + +// For documentation please see https://embark.status.im/docs/contracts_testing.html config({ + //deployment: { + // accounts: [ + // // you can configure custom accounts with a custom balance + // // see https://embark.status.im/docs/contracts_testing.html#Configuring-accounts + // ] + //}, contracts: { "SimpleStorage": { args: [100] } } +}, (_err, web3_accounts) => { + accounts = web3_accounts }); contract("SimpleStorage", function () { @@ -22,4 +34,10 @@ contract("SimpleStorage", function () { 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); + }); +} +*/