From 2cfc572cc66005915428e24a35ae375542c9b21a Mon Sep 17 00:00:00 2001 From: Haythem Sellami Date: Sat, 27 Apr 2019 23:22:03 +0100 Subject: [PATCH] fix contribution tests: get access to token app contracts --- apps/contribution/test/contribution.js | 54 +++++++++++++++++++------- apps/token/artifacts.js | 5 +++ 2 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 apps/token/artifacts.js diff --git a/apps/contribution/test/contribution.js b/apps/contribution/test/contribution.js index 9142afb..a2e0607 100644 --- a/apps/contribution/test/contribution.js +++ b/apps/contribution/test/contribution.js @@ -1,6 +1,7 @@ const namehash = require('eth-ens-namehash').hash; const Contribution = artifacts.require("Contribution.sol"); +const { Token, getTokenContract } = require("../../token/artifacts"); const getContract = name => artifacts.require(name) const { assertRevert } = require('@aragon/test-helpers/assertThrow'); @@ -8,7 +9,7 @@ const { assertRevert } = require('@aragon/test-helpers/assertThrow'); const ZERO_ADDR = '0x0000000000000000000000000000000000000000'; contract('Token app', (accounts) => { - let kernelBase, aclBase, daoFactory, dao, acl, contribution; + let kernelBase, aclBase, daoFactory, dao, acl, contribution, token; const root = accounts[0]; const member1 = accounts[1]; @@ -29,18 +30,6 @@ contract('Token app', (accounts) => { root, { from: root } ); - - //get new app instance from DAO - const receipt = await dao.newAppInstance( - '0x1234', - (await Contribution.new()).address, - 0x0, - false, - { from: root } - ) - contribution = Contribution.at( - receipt.logs.filter(l => l.event == 'NewAppProxy')[0].args.proxy - ) //apps id let appsId = []; @@ -48,6 +37,30 @@ contract('Token app', (accounts) => { appsId[1] = namehash("kredits-contributor"); appsId[2] = namehash("kredits-proposal"); appsId[3] = namehash("kredits-token"); + + + //get new app instance from DAO + let receipt = await dao.newAppInstance( + appsId[0], + (await Contribution.new()).address, + 0x0, + false, + { from: root } + ) + contribution = Contribution.at( + receipt.logs.filter(l => l.event == 'NewAppProxy')[0].args.proxy + ); + + receipt = await dao.newAppInstance( + appsId[3], + (await getTokenContract('Token').new()).address, + 0x0, + false, + { from: root } + ) + token = Token.at( + receipt.logs.filter(l => l.event == 'NewAppProxy')[0].args.proxy + ); //init app await contribution.initialize(appsId); @@ -66,8 +79,21 @@ contract('Token app', (accounts) => { await contribution.VETO_CONTRIBUTION_ROLE(), root, { from: root } - ) + ); + + //init token (app) + await token.initialize(appsId); + //create token mint permission for coin owner + await acl.createPermission( + root, + token.address, + await token.MINT_TOKEN_ROLE(), + root, + { from: root } + ); + + //acl.grantPermission(contribution, token, await token.MINT_TOKEN_ROLE(), {from: root}); }); describe("Owner default space permissions", async() => { diff --git a/apps/token/artifacts.js b/apps/token/artifacts.js new file mode 100644 index 0000000..366a770 --- /dev/null +++ b/apps/token/artifacts.js @@ -0,0 +1,5 @@ +module.exports = { + Token: artifacts.require('Token.sol'), + getTokenContract: name => artifacts.require(name) +} + \ No newline at end of file