Skip to content

Commit

Permalink
feat: implement disputer address validation
Browse files Browse the repository at this point in the history
  • Loading branch information
gas1cent committed Dec 12, 2023
1 parent 75af5a4 commit 27b4a8c
Show file tree
Hide file tree
Showing 2 changed files with 19 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 @@ -126,6 +126,10 @@ contract Oracle is IOracle {
) external returns (bytes32 _disputeId) {
_disputeId = _validateDispute(_request, _response, _dispute);

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

if (createdAt[_dispute.requestId] == 0) {
revert Oracle_InvalidDisputeBody();
}
Expand Down
15 changes: 15 additions & 0 deletions solidity/test/unit/Oracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,21 @@ contract Oracle_Unit_DisputeResponse is BaseTest {
oracle.disputeResponse(mockRequest, mockResponse, mockDispute);
}

/**
* @notice Reverts if the caller and the disputer are not the same
*/
function test_disputeResponse_revertIfWrongDisputer(address _caller) public {
vm.assume(_caller != disputer);

// Check: revert?
oracle.mock_setDisputeOf(_responseId, _disputeId);
vm.expectRevert(IOracle.Oracle_InvalidDisputeBody.selector);

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

/**
* @notice Reverts if the request has already been disputed
*/
Expand Down

0 comments on commit 27b4a8c

Please sign in to comment.