From bc37ab56866fd57b1fd7c4e6c058e8c1b79fec7b Mon Sep 17 00:00:00 2001 From: Haythem Sellami Date: Tue, 24 Sep 2019 15:55:41 +0100 Subject: [PATCH] fix revert claim test --- apps/contribution/test/contribution.js | 43 +++++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/apps/contribution/test/contribution.js b/apps/contribution/test/contribution.js index 6e46934..f817093 100644 --- a/apps/contribution/test/contribution.js +++ b/apps/contribution/test/contribution.js @@ -9,7 +9,6 @@ const Token = artifacts.require("Token.sol"); // eslint-disable-next-line no-undef const getContract = name => artifacts.require(name); const { assertRevert } = require('@aragon/test-helpers/assertThrow'); - const ZERO_ADDR = '0x0000000000000000000000000000000000000000'; const timeTravel = function(time){ @@ -44,6 +43,16 @@ const mineBlock = function() { }); }; +const getBlockNumber = function() { + return new Promise((resolve, reject) => { + // eslint-disable-next-line no-undef + web3.eth.getBlockNumber(async (err, res) => { + if (err || !res) return reject(err); + resolve(res); + }); + }); +}; + contract('Contribution app', (accounts) => { // eslint-disable-next-line no-undef let kernelBase, aclBase, daoFactory, r, dao, acl, contribution, token, contributor; @@ -249,14 +258,22 @@ contract('Contribution app', (accounts) => { // eslint-disable-next-line no-undef before(async () =>{ + //add contributor + let account = root; + let contributorHashDigest = '0x0000000000000000000000000000000000000000000000000000000000000000'; + let contributorHashFunction = 0; + let contributorHashSize = 0; + await contributor.addContributor(account, contributorHashDigest, contributorHashFunction, contributorHashSize); + // eslint-disable-next-line no-undef + assert.equal(await contributor.addressExists(account), true); + + //add contribution let amount = 200; - let contributorId = 1; - let hashDigest = '0x0000000000000000000000000000000000000000000000000000000000000000'; - let hashFunction = 1; - let hashSize = 1; - - await contribution.add(amount, contributorId, hashDigest, hashFunction, hashSize, {from: root}); - + let contributorId = await contributor.getContributorIdByAddress(root); + let contributionHashDigest = '0x0000000000000000000000000000000000000000000000000000000000000000'; + let contributionHashFunction = 1; + let contributionHashSize = 1; + await contribution.add(amount, contributorId.toNumber(), contributionHashDigest, contributionHashFunction, contributionHashSize, {from: root}); contributionId = await contribution.contributionsCount(); }); @@ -268,10 +285,12 @@ contract('Contribution app', (accounts) => { }); it("should revert when claim contribution before confirmation block", async () => { - return assertRevert(async () => { - await contribution.claim(contributionId.toNumber(), {from: root}); - 'contribution not confirmed yet'; - }); + if(contributionId > 10) { + return assertRevert(async () => { + await contribution.claim(contributionId.toNumber(), {from: root}); + 'contribution not confirmed yet'; + }); + } }); it("claim contribution", async () => {