-
Notifications
You must be signed in to change notification settings - Fork 25
/
distributereputation.js
46 lines (38 loc) · 2.18 KB
/
distributereputation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const helpers = require('./helpers')
var SimpleVote = artifacts.require("./SimpleVote.sol");
var SimpleContribution = artifacts.require("./SimpleContribution.sol");
contract('Proposal to distribute Reputation', function(accounts) {
it("should respect basic sanity", async function() {
let submissionFee = 0;
await helpers.setupController(this)
// set up a distribution scheme for minting tokens
let contributionVotingScheme = await SimpleVote.new();
let contributionScheme = await SimpleContribution.new(
this.controllerAddress,
submissionFee,
contributionVotingScheme.address
);
// vote and accept the schema (founders[1] has the majority)
await this.genesis.proposeScheme(contributionScheme.address);
await this.genesis.voteScheme(contributionScheme.address, true, {from: this.founders[1]});
// now we can make a proposal to distribute tokens to beneficiary
let beneficiary = accounts[4]
let askedTokens = 0
let askedReputation = 3415
let contributionId = await contributionScheme.submitContribution.call("Give 3415 reputation to accounts[4]",
askedTokens,
askedReputation,
beneficiary);
// do the same call onchain
await contributionScheme.submitContribution("Give 3415 reputation to accounts[4]",
askedTokens,
askedReputation,
beneficiary);
// vote on contribution. 2nd founder has majority
await contributionScheme.voteContribution(contributionId, true, {'from': this.founders[1]});
// now the beneficiary should have askedTokens
let reputation0AfterSubmission = await this.reputationInstance.reputationOf(beneficiary);
assert.equal(reputation0AfterSubmission, askedReputation)
return
})
});