From dfabe0db27f8a9e884b81aabb9c1ce53249205f0 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Wed, 8 Aug 2018 01:20:27 -0300 Subject: [PATCH] fix test script --- test/DelegationProxyTest.js | 457 +++++++++++++----------------------- 1 file changed, 163 insertions(+), 294 deletions(-) diff --git a/test/DelegationProxyTest.js b/test/DelegationProxyTest.js index 12ff55e..5c892ca 100644 --- a/test/DelegationProxyTest.js +++ b/test/DelegationProxyTest.js @@ -1,320 +1,189 @@ -const utils = require("../utils/testUtils.js") +const utils = require("../utils/testUtils") -// TODO: This a very minimal set of tests purely for understanding the contract. I think they can be used though. -describe("DelegationProxy", async function() { +const MiniMeToken = require('Embark/contracts/MiniMeToken'); +const DelegationProxy = require('Embark/contracts/DelegationProxy'); +const tokensBalance = 1000; + +config({ + contracts: { + "MiniMeTokenFactory": { + }, + "MiniMeToken": { + "args": [ + "$MiniMeTokenFactory", + utils.zeroAddress, + 0, + "TestMiniMeToken", + 18, + "TST", + true + ] + }, + "DelegationProxy": { + "args": [ 0 ] + }, + "ChildDelegationProxy": { + "instanceOf": "DelegationProxy", + "args": [ + "$DelegationProxy" + ] + } + + } + }); + +contract("DelegationProxy", function() { this.timeout(0); - //Initialize global/common contracts for all tests - let accounts = []; - - let delegationProxy = [] - let delegateTo = [[],[]] - let delegationOf = [[],[]] - let delegatedInfluence = [[],[]] - let influence = [[],[]] - - let tokensBalance; + var accounts; before(function(done) { - var contractsConfig = { - "MiniMeTokenFactory": { - }, - "MiniMeToken": { - "args": [ - "$MiniMeTokenFactory", - utils.zeroAddress, - 0, - "TestMiniMeToken", - 18, - "TST", - true - ] - }, - "DelegationProxy": { - "args": [ 0 ] - }, - "ChildDelegationProxy": { - "instanceOf": "DelegationProxy", - "args": [ - "$DelegationProxy" - ] - } + web3.eth.getAccounts().then(function (res) { + accounts = res; + done(); + }); + }); - }; - EmbarkSpec.deployAll(contractsConfig, async function(accountsArr) { - accounts = accountsArr - delegationProxy[0] = DelegationProxy - delegationProxy[1] = ChildDelegationProxy - delegateTo = [ - [ - accounts[1], - accounts[2], - 0x0 - ], - [ - 0x0, - accounts[2], - 0x0 - ] - ] - delegationOf = [ - [ - accounts[2], - accounts[2], - accounts[2] - ], - [ - accounts[0], - accounts[2], - accounts[2] - ] - ] - - delegatedInfluence = [ - [0, 1, 2], - [0, 0, 1] - ] - - influence = [ - [0, 0, 3], - [1, 0, 2] - ] - - tokensBalance = 1000 - - for(i=0;i