Skip to content

Commit 303884d

Browse files
author
Oren Sokolowsky
committed
tests
1 parent 0056cf0 commit 303884d

File tree

2 files changed

+35
-27
lines changed

2 files changed

+35
-27
lines changed

test/fundingrequest.js

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const helpers = require("./helpers");
2-
const JoinAndQuit = artifacts.require("./JoinAndQuit.sol");
2+
const Join = artifacts.require("./Join.sol");
33
const FundingRequest = artifacts.require("./FundingRequest.sol");
44
const ERC20Mock = artifacts.require('./test/ERC20Mock.sol');
55
const Redeemer = artifacts.require("./Redeemer.sol");
66

7-
class JoinAndQuitParams {
7+
class JoinParams {
88
constructor() {
99
}
1010
}
@@ -14,7 +14,7 @@ class FundingRequestParams {
1414
}
1515
}
1616

17-
const setupJoinAndQuit = async function(
17+
const setupJoin = async function(
1818
accounts,
1919
genesisProtocol,
2020
token,
@@ -24,42 +24,40 @@ const setupJoinAndQuit = async function(
2424
_fundingGoal,
2525
_fundingGoalDeadline
2626
) {
27-
var joinAndQuitParams = new JoinAndQuitParams();
27+
var joinParams = new JoinParams();
2828

2929
if (genesisProtocol === true) {
30-
joinAndQuitParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token,helpers.NULL_ADDRESS);
31-
joinAndQuitParams.initdata = await new web3.eth.Contract(registration.joinAndQuit.abi)
30+
joinParams.votingMachine = await helpers.setupGenesisProtocol(accounts,token,helpers.NULL_ADDRESS);
31+
joinParams.initdata = await new web3.eth.Contract(registration.join.abi)
3232
.methods
3333
.initialize(helpers.NULL_ADDRESS,
34-
joinAndQuitParams.votingMachine.genesisProtocol.address,
35-
joinAndQuitParams.votingMachine.uintArray,
36-
joinAndQuitParams.votingMachine.voteOnBehalf,
34+
joinParams.votingMachine.genesisProtocol.address,
35+
joinParams.votingMachine.uintArray,
36+
joinParams.votingMachine.voteOnBehalf,
3737
helpers.NULL_HASH,
3838
_fundingToken,
3939
_minFeeToJoin,
4040
_memberReputation,
4141
_fundingGoal,
42-
_fundingGoalDeadline,
43-
false)
42+
_fundingGoalDeadline)
4443
.encodeABI();
4544
} else {
46-
joinAndQuitParams.votingMachine = await helpers.setupAbsoluteVote(helpers.NULL_ADDRESS,50);
47-
joinAndQuitParams.initdata = await new web3.eth.Contract(registration.joinAndQuit.abi)
45+
joinParams.votingMachine = await helpers.setupAbsoluteVote(helpers.NULL_ADDRESS,50);
46+
joinParams.initdata = await new web3.eth.Contract(registration.join.abi)
4847
.methods
4948
.initialize(helpers.NULL_ADDRESS,
50-
joinAndQuitParams.votingMachine.absoluteVote.address,
49+
joinParams.votingMachine.absoluteVote.address,
5150
[1,1,1,1,1,1,1,1,1,1,1],
5251
helpers.NULL_ADDRESS,
53-
joinAndQuitParams.votingMachine.params,
52+
joinParams.votingMachine.params,
5453
_fundingToken,
5554
_minFeeToJoin,
5655
_memberReputation,
5756
_fundingGoal,
58-
_fundingGoalDeadline,
59-
false)
57+
_fundingGoalDeadline)
6058
.encodeABI();
6159
}
62-
return joinAndQuitParams;
60+
return joinParams;
6361
};
6462

6563

@@ -125,7 +123,7 @@ const setup = async function (accounts,
125123
fundPath = helpers.NULL_ADDRESS;
126124
}
127125

128-
testSetup.joinAndQuitParams= await setupJoinAndQuit(
126+
testSetup.joinParams= await setupJoin(
129127
accounts,
130128
genesisProtocol,
131129
tokenAddress,
@@ -151,32 +149,32 @@ const setup = async function (accounts,
151149
[1000,0,0],
152150
testSetup.reputationArray,
153151
0,
154-
[web3.utils.fromAscii("JoinAndQuit"), web3.utils.fromAscii("FundingRequest")],
155-
helpers.concatBytes(testSetup.joinAndQuitParams.initdata, testSetup.fundingRequestParams.initdata),
156-
[helpers.getBytesLength(testSetup.joinAndQuitParams.initdata), helpers.getBytesLength(testSetup.fundingRequestParams.initdata)],
152+
[web3.utils.fromAscii("Join"), web3.utils.fromAscii("FundingRequest")],
153+
helpers.concatBytes(testSetup.joinParams.initdata, testSetup.fundingRequestParams.initdata),
154+
[helpers.getBytesLength(testSetup.joinParams.initdata), helpers.getBytesLength(testSetup.fundingRequestParams.initdata)],
157155
[permissions, permissions],
158156
"metaData");
159157

160-
testSetup.joinAndQuit = await JoinAndQuit.at(tx.logs[6].args._scheme);
158+
testSetup.join = await Join.at(tx.logs[6].args._scheme);
161159
testSetup.fundingRequest = await FundingRequest.at(tx.logs[8].args._scheme);
162160

163161

164162
if(setupJAQProposal) {
165163
await testSetup.standardTokenMock.transfer(accounts[3],10000);
166-
await testSetup.standardTokenMock.approve(testSetup.joinAndQuit.address,testSetup.fundingGoal,{from:accounts[3]});
164+
await testSetup.standardTokenMock.approve(testSetup.join.address,testSetup.fundingGoal,{from:accounts[3]});
167165
let value = 0;
168166
if (ethFunding) {
169167
value = testSetup.fundingGoal;
170168
}
171-
tx = await testSetup.joinAndQuit.proposeToJoin(
169+
tx = await testSetup.join.proposeToJoin(
172170
"description-hash",
173171
testSetup.fundingGoal,
174172
{value, from:accounts[3]});
175173
var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1);
176174
if (genesisProtocol === false) {
177-
await testSetup.joinAndQuitParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]});
175+
await testSetup.joinParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]});
178176
} else {
179-
await testSetup.joinAndQuitParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]});
177+
await testSetup.joinParams.votingMachine.genesisProtocol.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]});
180178
}
181179
}
182180
return testSetup;

test/join.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,16 @@ contract('Join', accounts => {
343343
//Vote with reputation to trigger execution
344344
var proposalId = await helpers.getValueFromLogs(tx, '_proposalId',1);
345345
await testSetup.joinParams.votingMachine.absoluteVote.vote(proposalId,1,0,helpers.NULL_ADDRESS,{from:accounts[2]});
346+
try {
347+
await testSetup.join.proposeToJoin(
348+
"description-hash",
349+
testSetup.minFeeToJoin,
350+
{from:accounts[3]});
351+
assert(false, 'accepted candidate which not redeemed yet cannt be proposed again');
352+
} catch (ex) {
353+
helpers.assertVMException(ex);
354+
}
355+
346356
tx = await testSetup.join.redeemReputation(proposalId);
347357
assert.equal(tx.logs[0].event, "RedeemReputation");
348358
assert.equal(tx.logs[0].args._amount, testSetup.memberReputation);

0 commit comments

Comments
 (0)