Skip to content

Commit

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

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

if (_dispute.disputer != msg.sender) {
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 @@ -499,6 +499,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 1752678

Please sign in to comment.