-
Notifications
You must be signed in to change notification settings - Fork 242
[DO NOT MERGE] Disputable: Move set agreement to Kernel #599
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
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| const { toChecksumAddress } = require('web3-utils') | ||
| const { assertRevert } = require('../../../helpers/assertThrow') | ||
| const { getEventArgument } = require('../../../helpers/events') | ||
| const { getNewProxyAddress } = require('../../../helpers/events') | ||
| const { decodeEventsOfType } = require('../../../helpers/decodeEvent') | ||
| const { assertEvent, assertAmountOfEvents } = require('../../../helpers/assertEvent')(web3) | ||
|
|
||
| const ACL = artifacts.require('ACL') | ||
|
|
@@ -30,15 +32,15 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => | |
|
|
||
| const APP_MANAGER_ROLE = await kernelBase.APP_MANAGER_ROLE() | ||
| await acl.createPermission(owner, dao.address, APP_MANAGER_ROLE, owner, { from: owner }) | ||
|
|
||
| const SET_AGREEMENT_ROLE = await kernelBase.SET_AGREEMENT_ROLE() | ||
| await acl.createPermission(owner, dao.address, SET_AGREEMENT_ROLE, owner, { from: owner }) | ||
| }) | ||
|
|
||
| beforeEach('install disputable app', async () => { | ||
| const initializeData = disputableBase.contract.initialize.getData() | ||
| const receipt = await dao.newAppInstance('0x1234', disputableBase.address, initializeData, false, { from: owner }) | ||
| disputable = await DisputableApp.at(getNewProxyAddress(receipt)) | ||
|
|
||
| const SET_AGREEMENT_ROLE = await disputable.SET_AGREEMENT_ROLE() | ||
| await acl.createPermission(owner, disputable.address, SET_AGREEMENT_ROLE, owner, { from: owner }) | ||
| }) | ||
|
|
||
| describe('supportsInterface', () => { | ||
|
|
@@ -67,17 +69,19 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => | |
|
|
||
| const itSetsTheAgreementAddress = agreement => { | ||
| it('sets the agreement', async () => { | ||
| await disputable.setAgreement(agreement, { from }) | ||
| await dao.setAgreement(disputable.address, agreement, { from }) | ||
|
|
||
| const currentAgreement = await disputable.getAgreement() | ||
| assert.equal(currentAgreement, agreement, 'disputable agreement does not match') | ||
| }) | ||
|
|
||
| it('emits an event', async () => { | ||
| const receipt = await disputable.setAgreement(agreement, { from }) | ||
| const { tx } = await dao.setAgreement(disputable.address, agreement, { from }) | ||
| const receipt = await web3.eth.getTransactionReceipt(tx) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh interesting, was the receipt we got as the return of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some reason, it wasn't working. I think this will be fixed when we upgrade to Truffle 5 + helpers |
||
| const logs = decodeEventsOfType(receipt, DisputableApp.abi, 'AgreementSet') | ||
|
|
||
| assertAmountOfEvents(receipt, 'AgreementSet') | ||
| assertEvent(receipt, 'AgreementSet', { agreement }) | ||
| assertAmountOfEvents({ logs }, 'AgreementSet') | ||
| assertEvent({ logs }, 'AgreementSet', { agreement: toChecksumAddress(agreement) }) | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -88,31 +92,31 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => | |
|
|
||
| context('when trying to unset the agreement', () => { | ||
| it('reverts', async () => { | ||
| await assertRevert(disputable.setAgreement(ZERO_ADDRESS, { from }), 'DISPUTABLE_AGREEMENT_STATE_INVAL') | ||
| await assertRevert(dao.setAgreement(disputable.address, ZERO_ADDRESS, { from }), 'DISPUTABLE_AGREEMENT_STATE_INVAL') | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| context('when the agreement was already set', () => { | ||
| beforeEach('set agreement', async () => { | ||
| await disputable.setAgreement(agreement, { from }) | ||
| await dao.setAgreement(disputable.address, agreement, { from }) | ||
| }) | ||
|
|
||
| context('when trying to re-set the agreement', () => { | ||
| it('reverts', async () => { | ||
| await assertRevert(disputable.setAgreement(agreement, { from }), 'DISPUTABLE_AGREEMENT_STATE_INVAL') | ||
| await assertRevert(dao.setAgreement(disputable.address, agreement, { from }), 'DISPUTABLE_AGREEMENT_STATE_INVAL') | ||
| }) | ||
| }) | ||
|
|
||
| context('when trying to set a new agreement', () => { | ||
| it('reverts', async () => { | ||
| await assertRevert(disputable.setAgreement(anotherAgreement, { from }), 'DISPUTABLE_AGREEMENT_STATE_INVAL') | ||
| await assertRevert(dao.setAgreement(disputable.address, anotherAgreement, { from }), 'DISPUTABLE_AGREEMENT_STATE_INVAL') | ||
| }) | ||
| }) | ||
|
|
||
| context('when trying to unset the agreement', () => { | ||
| it('reverts', async () => { | ||
| await assertRevert(disputable.setAgreement(ZERO_ADDRESS, { from }), 'DISPUTABLE_AGREEMENT_STATE_INVAL') | ||
| await assertRevert(dao.setAgreement(disputable.address, ZERO_ADDRESS, { from }), 'DISPUTABLE_AGREEMENT_STATE_INVAL') | ||
| }) | ||
| }) | ||
| }) | ||
|
|
@@ -121,8 +125,16 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => | |
| context('when the sender does not have permissions', () => { | ||
| const from = someone | ||
|
|
||
| it('reverts', async () => { | ||
| await assertRevert(disputable.setAgreement(agreement, { from }), 'APP_AUTH_FAILED') | ||
| context('when going through the kernel', () => { | ||
| it('reverts', async () => { | ||
| await assertRevert(dao.setAgreement(disputable.address, agreement, { from }), 'KERNEL_AUTH_FAILED') | ||
| }) | ||
| }) | ||
|
|
||
| context('when going through the disputable', () => { | ||
| it('reverts', async () => { | ||
| await assertRevert(disputable.setAgreement(agreement, { from }), 'DISPUTABLE_SENDER_NOT_KERNEL') | ||
| }) | ||
| }) | ||
| }) | ||
| }) | ||
|
|
@@ -139,7 +151,7 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => | |
|
|
||
| beforeEach('set agreement', async () => { | ||
| agreement = await AgreementMock.new() | ||
| await disputable.setAgreement(agreement.address, { from: owner }) | ||
| await dao.setAgreement(disputable.address, agreement.address, { from: owner }) | ||
| }) | ||
|
|
||
| it('does not revert', async () => { | ||
|
|
@@ -167,7 +179,7 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => | |
| context('when the agreement is set', () => { | ||
| beforeEach('set agreement', async () => { | ||
| const agreement = await AgreementMock.new() | ||
| await disputable.setAgreement(agreement.address, { from: owner }) | ||
| await dao.setAgreement(disputable.address, agreement.address, { from: owner }) | ||
| }) | ||
|
|
||
| it('does not revert', async () => { | ||
|
|
@@ -183,7 +195,7 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => | |
| const agreement = someone | ||
|
|
||
| beforeEach('set agreement', async () => { | ||
| await disputable.setAgreement(agreement, { from: owner }) | ||
| await dao.setAgreement(disputable.address, agreement, { from: owner }) | ||
| }) | ||
|
|
||
| context('when the sender is the agreement', () => { | ||
|
|
@@ -219,7 +231,7 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => | |
| const agreement = someone | ||
|
|
||
| beforeEach('set agreement', async () => { | ||
| await disputable.setAgreement(agreement, { from: owner }) | ||
| await dao.setAgreement(disputable.address, agreement, { from: owner }) | ||
| }) | ||
|
|
||
| context('when the sender is the agreement', () => { | ||
|
|
@@ -255,7 +267,7 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => | |
| const agreement = someone | ||
|
|
||
| beforeEach('set agreement', async () => { | ||
| await disputable.setAgreement(agreement, { from: owner }) | ||
| await dao.setAgreement(disputable.address, agreement, { from: owner }) | ||
| }) | ||
|
|
||
| context('when the sender is the agreement', () => { | ||
|
|
@@ -291,7 +303,7 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) => | |
| const agreement = someone | ||
|
|
||
| beforeEach('set agreement', async () => { | ||
| await disputable.setAgreement(agreement, { from: owner }) | ||
| await dao.setAgreement(disputable.address, agreement, { from: owner }) | ||
| }) | ||
|
|
||
| context('when the sender is the agreement', () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments:
AragonAppas the type forsetApp()'sappparameter? I'm debating if this interface dependency tree is worth it, but if not, then we may also want to typesetAgreement()with just addresses.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to discuss this as one of the things to change in the new breaking version, but yea, I'd love to polish all the interfaces we provide