Skip to content

Commit

Permalink
feat: code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
gas1cent committed Nov 21, 2023
1 parent 9c00fc3 commit 1edb07b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions solidity/contracts/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ contract Oracle is IOracle {
DisputeStatus _status
) external {
bytes32 _disputeId = _getId(_dispute);
bytes32 _requestId = _getId(_request);

if (_response.requestId != _requestId || createdAt[_requestId] == 0) revert Oracle_InvalidRequestBody();

if (disputeOf[_getId(_response)] != _disputeId) {
revert Oracle_InvalidDisputeId(_disputeId);
Expand Down
6 changes: 6 additions & 0 deletions solidity/test/unit/Oracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ contract MockOracle is Oracle {
nonceToRequestId[_nonce] = _requestId;
}

function mock_setCreatedAt(bytes32 _requestId, uint128 _createdAt) external {
createdAt[_requestId] = _createdAt;
}

function mock_setTotalRequestCount(uint256 _totalRequestCount) external {
totalRequestCount = _totalRequestCount;
}
Expand Down Expand Up @@ -440,6 +444,7 @@ contract Unit_UpdateDisputeStatus is BaseTest {
*/
function test_updateDisputeStatus() public {
bytes32 _requestId = _getId(mockRequest);
oracle.mock_setCreatedAt(_getId(mockRequest), uint128(block.number));

// Try every initial status
for (uint256 _previousStatus; _previousStatus < uint256(type(IOracle.DisputeStatus).max); _previousStatus++) {
Expand Down Expand Up @@ -482,6 +487,7 @@ contract Unit_UpdateDisputeStatus is BaseTest {

// Mock the dispute
oracle.mock_setDisputeOf(_getId(mockResponse), _getId(mockDispute));
oracle.mock_setCreatedAt(_getId(mockRequest), uint128(block.number));

// Check: revert?
vm.expectRevert(abi.encodeWithSelector(IOracle.Oracle_NotDisputeOrResolutionModule.selector, proposer));
Expand Down

0 comments on commit 1edb07b

Please sign in to comment.