Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: response module deadline #58

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract BondedResponseModule is Module, IBondedResponseModule {
RequestParameters memory _params = decodeRequestData(_request.responseModuleData);

// Cannot propose after the deadline
if (block.timestamp >= _params.deadline) revert BondedResponseModule_TooLateToPropose();
if (block.number >= _params.deadline) revert BondedResponseModule_TooLateToPropose();
Comment on lines 30 to +31
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revise the interface NatSpec for the deadline param.


// Cannot propose to a request with a response, unless the response is being disputed
bytes32[] memory _responseIds = ORACLE.getResponseIds(_response.requestId);
Expand Down
2 changes: 1 addition & 1 deletion solidity/test/integration/EscalateDispute.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract Integration_EscalateDispute is IntegrationBase {
bondToken: usdc,
bondSize: _expectedBondSize,
maxNumberOfEscalations: 1,
bondEscalationDeadline: _expectedDeadline,
bondEscalationDeadline: block.timestamp + BLOCK_TIME * _blocksDeadline,
tyingBuffer: 0,
disputeWindow: 0
})
Expand Down
2 changes: 1 addition & 1 deletion solidity/test/integration/IntegrationBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ contract IntegrationBase is DSTestPlus, TestConstants, Helpers {
vm.stopPrank();

// Set the expected deadline
_expectedDeadline = block.timestamp + BLOCK_TIME * _blocksDeadline;
_expectedDeadline = block.number + _blocksDeadline;

// Configure the mock request
mockRequest.requestModuleData = abi.encode(
Expand Down
6 changes: 3 additions & 3 deletions solidity/test/integration/ResponseProposal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ contract Integration_ResponseProposal is IntegrationBase {
/**
* @notice Proposing a response after the deadline reverts
*/
function test_proposeResponse_afterDeadline(uint256 _timestamp, bytes memory _responseBytes) public {
vm.assume(_timestamp > _expectedDeadline);
function test_proposeResponse_afterDeadline(uint256 _blockNumber, bytes memory _responseBytes) public {
vm.assume(_blockNumber > _expectedDeadline);

// Warp to timestamp after deadline
vm.warp(_timestamp);
vm.roll(_blockNumber);

mockResponse.response = _responseBytes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ contract ContractCallRequestModule_Unit_FinalizeRequest is BaseTest {

// Mock and expect oracle to return the response's creation time
_mockAndExpect(
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_getId(mockResponse))), abi.encode(block.timestamp)
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_getId(mockResponse))), abi.encode(block.number)
);

// Mock and expect IAccountingExtension.pay to be called
Expand Down
2 changes: 1 addition & 1 deletion solidity/test/unit/modules/request/HttpRequestModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ contract HttpRequestModule_Unit_FinalizeRequest is BaseTest {

// Mock and expect oracle to return the response's creation time
_mockAndExpect(
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_getId(mockResponse))), abi.encode(block.timestamp)
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_getId(mockResponse))), abi.encode(block.number)
);

// Mock and expect IAccountingExtension.pay to be called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ contract SparseMerkleTreeRequestModule_Unit_FinalizeRequest is BaseTest {

// Oracle confirms that the response has been created
_mockAndExpect(
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_getId(mockResponse))), abi.encode(block.timestamp)
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_getId(mockResponse))), abi.encode(block.number)
);

// Mock and expect IAccountingExtension.pay to be called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ contract BaseTest is Test, Helpers {
mockDispute = _getDispute(mockRequest, mockResponse);
_disputeId = _getId(mockDispute);

vm.mockCall(address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_responseId)), abi.encode(block.timestamp));
vm.mockCall(address(oracle), abi.encodeCall(IOracle.disputeCreatedAt, (_disputeId)), abi.encode(block.timestamp));
vm.mockCall(address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_responseId)), abi.encode(block.number));
vm.mockCall(address(oracle), abi.encodeCall(IOracle.disputeCreatedAt, (_disputeId)), abi.encode(block.number));
}

function _getRequestResponseDispute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ contract BondedResponseModule_Unit_FinalizeRequest is BaseTest {

// Mock and expect IOracle.responseCreatedAt to be called
_mockAndExpect(
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_getId(mockResponse))), abi.encode(block.timestamp)
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_getId(mockResponse))), abi.encode(block.number)
);

// Mock and expect IAccountingExtension.release to be called
Expand Down Expand Up @@ -542,9 +542,7 @@ contract BondedResponseModule_Unit_ReleaseUnutilizedResponse is BaseTest {
address(oracle), abi.encodeCall(IOracle.finalizedResponseId, (_requestId)), abi.encode(_finalizedResponseId)
);

_mockAndExpect(
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_responseId)), abi.encode(block.timestamp)
);
_mockAndExpect(address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_responseId)), abi.encode(block.number));

// We're going to test all possible dispute statuses
for (uint256 _i = 0; _i < uint256(type(IOracle.DisputeStatus).max); _i++) {
Expand Down
Loading