From 9f97714ba58a264af40489ea61ad9b3ade2d0979 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Sat, 19 May 2018 23:36:34 -0300 Subject: [PATCH] add test to controlled, use "Contract" as generic name --- test/controlled.js | 29 +++++++++++++++++++++++++++++ test/erc20token.js | 24 ++++++++++++------------ test/testtoken.js | 2 +- 3 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 test/controlled.js diff --git a/test/controlled.js b/test/controlled.js new file mode 100644 index 0000000..d2b14b4 --- /dev/null +++ b/test/controlled.js @@ -0,0 +1,29 @@ + +exports.Test = (contractsConfig, afterDeploy) => { + + describe("Controlled", async function() { + this.timeout(0); + var Controlled; + var accountsArr; + before(function(done) { + EmbarkSpec.deployAll(contractsConfig, async function(accounts) { + Controlled = Contract; + accountsArr = accounts; + await afterDeploy(accounts, Contract); + done() + }); + }); + + + it("should start with msg.sender as controller", async function() { + var controller = await Controlled.methods.controller().call(); + assert(controller, accountsArr[0]); + }); + + it("should allow controller to set new controller", async function() { + await Controlled.methods.changeController(accountsArr[1]).send({from: accountsArr[0]}); + var controller = await Controlled.methods.controller().call(); + assert(controller, accountsArr[1]); + }); + }); +} \ No newline at end of file diff --git a/test/erc20token.js b/test/erc20token.js index 9c3d0ba..6889734 100644 --- a/test/erc20token.js +++ b/test/erc20token.js @@ -1,18 +1,18 @@ exports.Test = (contractsConfig, afterDeploy) => { - describe("ERC20Token", async function() { - this.timeout(0); - var ERC20Token; - var accountsArr; - before(function(done) { - contractsConfig["ERC20Receiver"] = {}; - EmbarkSpec.deployAll(contractsConfig, async function(accounts) { - ERC20Token = Token; - accountsArr = accounts; - await afterDeploy(accounts, Token); - done() + describe("ERC20Token", async function() { + this.timeout(0); + var ERC20Token; + var accountsArr; + before(function(done) { + contractsConfig["ERC20Receiver"] = {}; + EmbarkSpec.deployAll(contractsConfig, async function(accounts) { + ERC20Token = Contract; + accountsArr = accounts; + await afterDeploy(accounts, Contract); + done() + }); }); - }); it("should transfer 1 token", async function() { let initialBalance0 = await ERC20Token.methods.balanceOf(accountsArr[0]).call(); diff --git a/test/testtoken.js b/test/testtoken.js index a8fad7b..15fcd15 100644 --- a/test/testtoken.js +++ b/test/testtoken.js @@ -29,7 +29,7 @@ describe("TestToken", async function() { assert.equal(result, +initialBalance+100); }); var erc20tokenConfig = { - "Token": { "instanceOf" : "TestToken" } + "Contract": { "instanceOf" : "TestToken" } } ERC20Token.Test(erc20tokenConfig, async function (accounts, TestToken) { for(i=0;i