Skip to content

Commit

Permalink
Disputable: Support payable actions (#593)
Browse files Browse the repository at this point in the history
* Chore: Bump v5.0.0-beta.2

* disputables: support payable actions

* disputable: enhance test case description

Co-authored-by: Brett Sun <qisheng.brett.sun@gmail.com>

Co-authored-by: Brett Sun <qisheng.brett.sun@gmail.com>
  • Loading branch information
facuspagnuolo and sohkai authored Jul 15, 2020
1 parent 16f8ab5 commit 348593f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion contracts/apps/disputable/DisputableAragonApp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ contract DisputableAragonApp is IDisputable, AragonApp {
*/
function _newAgreementAction(uint256 _disputableActionId, bytes _context, address _submitter) internal returns (uint256) {
IAgreement agreement = _ensureAgreement();
return agreement.newAction(_disputableActionId, _context, _submitter);
return agreement.newAction.value(msg.value)(_disputableActionId, _context, _submitter);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/apps/disputable/IAgreement.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract IAgreement is IArbitrable, IACLOracle {

function deactivate(address _disputable) external;

function newAction(uint256 _disputableActionId, bytes _context, address _submitter) external returns (uint256);
function newAction(uint256 _disputableActionId, bytes _context, address _submitter) external payable returns (uint256);

function closeAction(uint256 _actionId) external;

Expand Down
4 changes: 2 additions & 2 deletions contracts/test/mocks/apps/disputable/AgreementMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ pragma solidity 0.4.24;


contract AgreementMock {
function newAction(uint256 _disputableActionId, bytes _context, address _submitter) external returns (uint256) {
function newAction(uint256 /* _disputableActionId */, bytes /* _context */, address /* _submitter */) external payable returns (uint256) {
// do nothing
return 0;
}

function closeAction(uint256 _actionId) external {
function closeAction(uint256 /* _actionId */) external {
// do nothing
}
}
2 changes: 1 addition & 1 deletion contracts/test/mocks/apps/disputable/DisputableAppMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract DisputableAppMock is DisputableAragonApp {
initialized();
}

function newAction(uint256 _disputableActionId, bytes _context, address _submitter) external {
function newAction(uint256 _disputableActionId, bytes _context, address _submitter) external payable {
_newAgreementAction(_disputableActionId, _context, _submitter);
}

Expand Down
13 changes: 12 additions & 1 deletion test/contracts/apps/disputable/disputable_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,25 @@ contract('DisputableApp', ([_, owner, agreement, anotherAgreement, someone]) =>
})

context('when the agreement is set', () => {
let agreement

beforeEach('set agreement', async () => {
const agreement = await AgreementMock.new()
agreement = await AgreementMock.new()
await disputable.setAgreement(agreement.address, { from: owner })
})

it('does not revert', async () => {
await disputable.newAction(0, '0x00', owner)
})

it('receives ETH when sent', async () => {
const previousBalance = await web3.eth.getBalance(agreement.address)

await disputable.newAction(0, '0x00', owner, { value: 1e18 })

const currentBalance = await web3.eth.getBalance(agreement.address)
assert.equal(currentBalance.sub(previousBalance).toString(), 1e18, 'agreement balance does not match')
})
})
})

Expand Down

0 comments on commit 348593f

Please sign in to comment.