diff --git a/apps/voting/contracts/test/mocks/VotingMock.sol b/apps/voting/contracts/test/mocks/VotingMock.sol index 78bbc4fd7c..8f54735ab4 100644 --- a/apps/voting/contracts/test/mocks/VotingMock.sol +++ b/apps/voting/contracts/test/mocks/VotingMock.sol @@ -1,14 +1,10 @@ pragma solidity 0.4.24; import "../../Voting.sol"; +import "@aragon/test-helpers/contracts/TimeHelpersMock.sol"; -contract VotingMock is Voting { - uint64 mockTime; - - function mock_setTimestamp(uint64 i) public { mockTime = i; } - function getTimestamp64() internal view returns (uint64) { return mockTime; } - +contract VotingMock is Voting, TimeHelpersMock { /* Ugly hack to work around this issue: * https://github.com/trufflesuite/truffle/issues/569 * https://github.com/trufflesuite/truffle/issues/737 diff --git a/apps/voting/test/voting.js b/apps/voting/test/voting.js index 2cb9481eab..2a8b34981b 100644 --- a/apps/voting/test/voting.js +++ b/apps/voting/test/voting.js @@ -1,5 +1,3 @@ -const sha3 = require('solidity-sha3').default - const { assertRevert } = require('@aragon/test-helpers/assertThrow') const getBlockNumber = require('@aragon/test-helpers/blockNumber')(web3) const { encodeCallScript, EMPTY_SCRIPT } = require('@aragon/test-helpers/evmScript') @@ -63,7 +61,7 @@ contract('Voting App', accounts => { const receipt = await dao.newAppInstance('0x1234', votingBase.address, '0x', false, { from: root }) voting = Voting.at(receipt.logs.filter(l => l.event == 'NewAppProxy')[0].args.proxy) - await voting.mock_setTimestamp(startTime) + await voting.mockSetTimestamp(startTime) await acl.createPermission(ANY_ADDR, voting.address, CREATE_VOTES_ROLE, root, { from: root }) await acl.createPermission(ANY_ADDR, voting.address, MODIFY_SUPPORT_ROLE, root, { from: root }) @@ -252,7 +250,7 @@ contract('Voting App', accounts => { await voting.vote(voteId, true, false, { from: holder51 }) await voting.vote(voteId, true, false, { from: holder20 }) await voting.vote(voteId, false, false, { from: holder29 }) - await voting.mock_setTimestamp(votingEnd) + await voting.mockSetTimestamp(votingEnd) const state = await voting.getVote(voteId) assert.equal(state[4].toString(), neededSupport.toString(), 'required support in vote should stay equal') @@ -267,7 +265,7 @@ contract('Voting App', accounts => { // it will succeed await voting.vote(voteId, true, true, { from: holder29 }) - await voting.mock_setTimestamp(votingEnd) + await voting.mockSetTimestamp(votingEnd) const state = await voting.getVote(voteId) assert.equal(state[5].toString(), minimumAcceptanceQuorum.toString(), 'acceptance quorum in vote should stay equal') @@ -310,7 +308,7 @@ contract('Voting App', accounts => { }) it('throws when voting after voting closes', async () => { - await voting.mock_setTimestamp(votingEnd) + await voting.mockSetTimestamp(votingEnd) return assertRevert(async () => { await voting.vote(voteId, true, true, { from: holder29 }) }) @@ -319,14 +317,14 @@ contract('Voting App', accounts => { it('can execute if vote is approved with support and quorum', async () => { await voting.vote(voteId, true, true, { from: holder29 }) await voting.vote(voteId, false, true, { from: holder20 }) - await voting.mock_setTimestamp(votingEnd) + await voting.mockSetTimestamp(votingEnd) await voting.executeVote(voteId) assert.equal(await executionTarget.counter(), 2, 'should have executed result') }) it('cannot execute vote if not enough quorum met', async () => { await voting.vote(voteId, true, true, { from: holder20 }) - await voting.mock_setTimestamp(votingEnd) + await voting.mockSetTimestamp(votingEnd) return assertRevert(async () => { await voting.executeVote(voteId) }) @@ -335,7 +333,7 @@ contract('Voting App', accounts => { it('cannot execute vote if not support met', async () => { await voting.vote(voteId, false, true, { from: holder29 }) await voting.vote(voteId, false, true, { from: holder20 }) - await voting.mock_setTimestamp(votingEnd) + await voting.mockSetTimestamp(votingEnd) return assertRevert(async () => { await voting.executeVote(voteId) })