Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Court: Polish main court contract functionality #103

Merged
merged 38 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8221815
agreements: fix contract warnings
facuspagnuolo Aug 13, 2019
f6dc198
court: rename `appealConfirm` to `confirmAppeal`
facuspagnuolo Aug 13, 2019
3c4320e
court: rename `draftAjudicationRound` to `draft`
facuspagnuolo Aug 13, 2019
8d07709
court: organize functions
facuspagnuolo Aug 13, 2019
c02593a
court: drop redundant `areAllJurorsSettled` function
facuspagnuolo Aug 13, 2019
53ff9e3
court: improve and test heartbeat function
facuspagnuolo Aug 14, 2019
afa7228
court: fix terms initialization
facuspagnuolo Aug 22, 2019
79abd26
court: test disputes creation
facuspagnuolo Aug 26, 2019
79cb27c
tests: batch tests in different CI stages
facuspagnuolo Aug 27, 2019
0cb4d62
court: improve draft tests
facuspagnuolo Aug 27, 2019
c3dfa38
registry: drop duplicated activation tests
facuspagnuolo Aug 27, 2019
2e3cbbd
court: multiple enhancements and test
facuspagnuolo Aug 31, 2019
c0ed4d6
court: use appeal start term for appeal fees
facuspagnuolo Sep 4, 2019
4adbc9b
court: fix requested number of jurors when drafting
facuspagnuolo Sep 4, 2019
4f4e205
chore: ugprade test-helpers to v2.1.0
facuspagnuolo Sep 4, 2019
de43e00
court: improve inline documentation wording and typos
facuspagnuolo Sep 4, 2019
aadd973
court: clarify needed transitions fn comment
facuspagnuolo Sep 4, 2019
da166b3
court: rollback msg.sender check on confirm appeals
facuspagnuolo Sep 4, 2019
83a42d6
court: ensure disputes are always created for future terms
facuspagnuolo Sep 4, 2019
4ab7ae7
court: organize functions modifiers
facuspagnuolo Sep 4, 2019
23cc17e
court: improve first term start time check
facuspagnuolo Sep 5, 2019
5dccdf7
court: gas optimizations
facuspagnuolo Sep 6, 2019
a81c2d1
court: improve adjudication round checks
facuspagnuolo Sep 6, 2019
66194cc
court: draft sloads optimization
facuspagnuolo Sep 6, 2019
3480bc3
court: fix typo
facuspagnuolo Sep 6, 2019
1d84975
court: improve uint256 castings
facuspagnuolo Sep 6, 2019
8bb0168
court: optimize adjudication round validations
facuspagnuolo Sep 7, 2019
d71c47a
court: fix heartbeat court config fetch
facuspagnuolo Sep 17, 2019
87c7b3b
court: rename `_ensureAdjudicationState` to use `check` instead
facuspagnuolo Sep 17, 2019
12cb8ea
court: remove useless memoization in appeal settle
facuspagnuolo Sep 18, 2019
0f31a59
tests: improve wording and fix typos
facuspagnuolo Sep 18, 2019
cce6087
tests: minor enhancements
facuspagnuolo Sep 18, 2019
b953158
court: undo appeal skipped tests
facuspagnuolo Sep 18, 2019
f616da3
court: minor enhacements and optimizations
facuspagnuolo Sep 18, 2019
e470083
court: optimize drafting and improve tests
facuspagnuolo Sep 18, 2019
14da657
court: add appeal details getter
facuspagnuolo Sep 19, 2019
e2cac0b
court: improve appeals tests
facuspagnuolo Sep 19, 2019
234267f
court: add getter to tell dispute fees
facuspagnuolo Sep 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I don't think we should have it here though, but it should definitely be in settleReward when assigning fees for coherent jurors in the final round

accounting.assign(config.feeToken, _juror, jurorFee);

And we should definitely have a test for it. Maybe we should work on it on a specific test file for accounting?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I don't get it. round.jurorFees already has the discount applied, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I was confused. The problem was that we are not testing it 😂

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