Skip to content

Commit

Permalink
Add logic to restrict withdrawals for 24 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdossa committed Jun 19, 2018
1 parent 1d0a4e1 commit aa6a207
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
5 changes: 3 additions & 2 deletions contracts/Arbitration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ contract Arbitration {
uint256 public DISPUTE_DISPERSAL_DURATION = 1 days;
uint256 public DISPUTE_WINDOW = 30 minutes;
uint256 public DISPUTE_EXTENSION = 30 minutes;
uint256 public VOTE_LOCKUP = 24 hours; //amount of time users must wait to withdraw their tokens
uint256 public DISPUTE_WINDOW_MAX = 5 * 10**16; //percentage multiplued by 10**16
uint256 public MIN_VOTE = 1 * 10**16; //percentage multiplied by 10**16
uint256 public MIN_WIN = 1 * 10**16; //percentage multiplied by 10**16
Expand Down Expand Up @@ -516,7 +517,7 @@ contract Arbitration {
emit DisputeEndsAdjusted(newDisputeEnds, disputeEnds);
disputeEnds = newDisputeEnds;
}
require(getNow() >= disputeEnds);
require(getNow() >= disputeEnds.add(VOTE_LOCKUP));
//There should be a clear winner now, otherwise the dispute would have been extended.
address winnerParty;
address bestMinortyParty;
Expand Down Expand Up @@ -590,7 +591,7 @@ contract Arbitration {
emit DisputeEndsAdjusted(newDisputeEnds, disputeEnds);
disputeEnds = newDisputeEnds;
}
require(getNow() >= disputeEnds);
require(getNow() >= disputeEnds.add(VOTE_LOCKUP));
require(!hasWithdrawn[msg.sender]);
hasWithdrawn[msg.sender] = true;
address winnerParty = getWinner();
Expand Down
14 changes: 12 additions & 2 deletions test/02_simple_dispute.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,17 @@ contract('Arbitration - Simple dispute', function (accounts) {
});
});

it("13. voters receive rewards", async () => {
it("13. voters and parties unable to withdraw in the first 24 hours", async () => {
await assertFail(async () => {
await arbitration.payoutVoter(0, 10, {from: voter1});
});
await assertFail(async () => {
await arbitration.payoutParty({from: party1});
});
});

it("14. voters receive rewards", async () => {
await arbitration.setMockedNow(9 * 24 * 60 * 60);
let voter1Balance = await token.balanceOf(voter1);
let voter2Balance = await token.balanceOf(voter2);
let voter3Balance = await token.balanceOf(voter3);
Expand All @@ -153,7 +163,7 @@ contract('Arbitration - Simple dispute', function (accounts) {
assert.equal(voter3FinalBalance.sub(voter3Balance).toNumber(), 50);
});

it("14. parties receive payouts", async () => {
it("15. parties receive payouts", async () => {
let party1Balance = await token.balanceOf(party1);
let party2Balance = await token.balanceOf(party2);
await arbitration.payoutParty({from: party1});
Expand Down
2 changes: 1 addition & 1 deletion test/03_tied_dispute.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ contract('Arbitration - Tied dispute', function (accounts) {
});

it("12. dispute ends, no more voting possible", async () => {
await arbitration.setMockedNow((8 * 24 * 60 * 60) + (30 * 60));
await arbitration.setMockedNow((9 * 24 * 60 * 60) + (30 * 60));
await assertFail(async () => {
await arbitration.vote(party1, 1, {from: voter2});
});
Expand Down
2 changes: 1 addition & 1 deletion test/04_extended_dispute.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ contract('Arbitration - Tied dispute', function (accounts) {
});

it("13. voters receive rewards", async () => {
await arbitration.setMockedNow((8 * 24 * 60 * 60) + (30 * 60));
await arbitration.setMockedNow((9 * 24 * 60 * 60) + (30 * 60));
let voter1Balance = await token.balanceOf(voter1);
let voter2Balance = await token.balanceOf(voter2);
let voter3Balance = await token.balanceOf(voter3);
Expand Down
2 changes: 1 addition & 1 deletion test/05_reject_dispute.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ contract('Arbitration - Reject dispute', function (accounts) {
});

it("11. dispute ends, no more voting possible", async () => {
await arbitration.setMockedNow(8 * 24 * 60 * 60);
await arbitration.setMockedNow(9 * 24 * 60 * 60);
await assertFail(async () => {
await arbitration.vote(party1, 1, {from: voter2});
});
Expand Down
2 changes: 1 addition & 1 deletion test/06_approve_and_call.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ contract('Arbitration - Approve and call', function (accounts) {
});

it("11. dispute ends, no more voting possible", async () => {
await arbitration.setMockedNow(8 * 24 * 60 * 60);
await arbitration.setMockedNow(9 * 24 * 60 * 60);
await assertFail(async () => {
await arbitration.vote(party1, 1, {from: voter2});
});
Expand Down

0 comments on commit aa6a207

Please sign in to comment.