Skip to content

Commit

Permalink
court: improve appeals tests
Browse files Browse the repository at this point in the history
  • Loading branch information
facuspagnuolo committed Sep 19, 2019
1 parent 14da657 commit e2cac0b
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 168 deletions.
1 change: 1 addition & 0 deletions contracts/Court.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,7 @@ contract Court is IJurorsRegistryOwner, ICRVotingOwner, ISubscriptionsOwner, Tim

// Otherwise, return the times the active balance of the juror fits in the min active balance, multiplying
// it by a round factor to ensure a better precision rounding.
// TODO: review, we are not using the final round discount here
return (FINAL_ROUND_WEIGHT_PRECISION.mul(activeBalance) / minJurorsActiveBalance).toUint64();
}

Expand Down
18 changes: 9 additions & 9 deletions test/court/court-appeal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const { bigExp } = require('../helpers/numbers')(web3)
const { filterJurors } = require('../helpers/jurors')
const { assertRevert } = require('@aragon/os/test/helpers/assertThrow')
const { assertAmountOfEvents, assertEvent } = require('@aragon/os/test/helpers/assertEvent')(web3)
const { buildHelper, ROUND_STATES, DISPUTE_STATES } = require('../helpers/court')(web3, artifacts)
const { OUTCOMES, getVoteId, oppositeOutcome, outcomeFor } = require('../helpers/crvoting')(web3)
const { getVoteId, oppositeOutcome, outcomeFor, OUTCOMES } = require('../helpers/crvoting')(web3)
const { buildHelper, DEFAULTS, ROUND_STATES, DISPUTE_STATES } = require('../helpers/court')(web3, artifacts)

const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'

Expand Down Expand Up @@ -109,8 +109,8 @@ contract('Court', ([_, disputer, drafter, appealMaker, appealTaker, juror500, ju

context('when the appeal maker has enough balance', () => {
beforeEach('mint fee tokens for appeal maker', async () => {
await courtHelper.feeToken.generateTokens(appealMaker, bigExp(1e6, 18))
await courtHelper.feeToken.approve(court.address, bigExp(1e6, 18), { from: appealMaker })
const { appealDeposit } = await courtHelper.getAppealFees(disputeId, roundId)
await courtHelper.mintAndApproveFeeTokens(appealMaker, court.address, appealDeposit)
})

it('emits an event', async () => {
Expand All @@ -124,15 +124,15 @@ contract('Court', ([_, disputer, drafter, appealMaker, appealTaker, juror500, ju
await court.appeal(disputeId, roundId, appealMakerRuling, { from: appealMaker })

const { appealer, appealedRuling, taker, opposedRuling } = await courtHelper.getAppeal(disputeId, roundId)
assert.equal(appealer, appealMaker, 'appealer does not match')
assert.equal(appealer, appealMaker, 'appeal maker does not match')
assert.equal(appealedRuling.toString(), appealMakerRuling, 'appealed ruling does not match')
assert.equal(taker.toString(), ZERO_ADDRESS, 'appeal taker does not match')
assert.equal(opposedRuling.toString(), 0, 'opposed ruling does not match')
})

it('transfers the appeal deposit to the court', async () => {
const { accounting, feeToken } = courtHelper
const expectedAppealDeposit = await courtHelper.getAppealDeposit(disputeId, roundId)
const { appealDeposit } = await courtHelper.getAppealFees(disputeId, roundId)

const previousCourtBalance = await feeToken.balanceOf(court.address)
const previousAccountingBalance = await feeToken.balanceOf(accounting.address)
Expand All @@ -144,10 +144,10 @@ contract('Court', ([_, disputer, drafter, appealMaker, appealTaker, juror500, ju
assert.equal(previousCourtBalance.toString(), currentCourtBalance.toString(), 'court balances do not match')

const currentAccountingBalance = await feeToken.balanceOf(accounting.address)
assert.equal(previousAccountingBalance.plus(expectedAppealDeposit).toString(), currentAccountingBalance.toString(), 'court accounting balances do not match')
assert.equal(previousAccountingBalance.plus(appealDeposit).toString(), currentAccountingBalance.toString(), 'court accounting balances do not match')

const currentAppealerBalance = await feeToken.balanceOf(appealMaker)
assert.equal(previousAppealerBalance.minus(expectedAppealDeposit).toString(), currentAppealerBalance.toString(), 'sender balances do not match')
assert.equal(previousAppealerBalance.minus(appealDeposit).toString(), currentAppealerBalance.toString(), 'sender balances do not match')
})

it('does not create a new round for the dispute', async () => {
Expand Down Expand Up @@ -279,7 +279,7 @@ contract('Court', ([_, disputer, drafter, appealMaker, appealTaker, juror500, ju
})

context('for a final round', () => {
const roundId = 3
const roundId = DEFAULTS.maxRegularAppealRounds.toNumber()

beforeEach('move to final round', async () => {
await courtHelper.moveToFinalRound({ disputeId })
Expand Down
Loading

0 comments on commit e2cac0b

Please sign in to comment.