Skip to content

Commit

Permalink
feat: add check proposer (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashitakah authored Jul 15, 2024
1 parent 1e39da6 commit 77e9130
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions solidity/contracts/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ contract Oracle is IOracle {
) external returns (bytes32 _disputeId) {
_disputeId = _validateDispute(_request, _response, _dispute);

if (_dispute.disputer != msg.sender) {
if (_dispute.proposer != _response.proposer) {
revert Oracle_InvalidDisputeBody();
}

if (createdAt[_dispute.requestId] == 0) {
if (_dispute.disputer != msg.sender || createdAt[_dispute.requestId] == 0) {
revert Oracle_InvalidDisputeBody();
}

Expand Down
17 changes: 17 additions & 0 deletions solidity/test/unit/Oracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,23 @@ contract Oracle_Unit_DisputeResponse is BaseTest {
}
}

/**
* @notice Reverts if the dispute proposer and response proposer are not same
*/
function test_disputeResponse_revertIfProposerIsNotValid(address _otherProposer) public {
vm.assume(_otherProposer != proposer);
oracle.mock_setCreatedAt(_getId(mockRequest), 0);

// Check: revert?
vm.expectRevert(IOracle.Oracle_InvalidDisputeBody.selector);

mockDispute.proposer = _otherProposer;

// Test: try to dispute the response
vm.prank(disputer);
oracle.disputeResponse(mockRequest, mockResponse, mockDispute);
}

/**
* @notice Reverts if the request doesn't exist
*/
Expand Down

0 comments on commit 77e9130

Please sign in to comment.