Skip to content

Commit

Permalink
fix: bonded response release unutilized response
Browse files Browse the repository at this point in the history
  • Loading branch information
0xShaito committed Oct 23, 2024
1 parent b72dcda commit 43e8be6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ contract BondedResponseModule is Module, IBondedResponseModule {
}

bytes32 _finalizedResponseId = ORACLE.finalizedResponseId(_response.requestId);
if (_finalizedResponseId == _responseId || _finalizedResponseId == bytes32(0)) {
if (_finalizedResponseId == _responseId || ORACLE.finalizedAt(_response.requestId) == 0) {
revert BondedResponseModule_InvalidReleaseParameters();
}

Expand Down
14 changes: 12 additions & 2 deletions solidity/test/unit/modules/response/BondedResponseModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ contract BondedResponseModule_Unit_ReleaseUnutilizedResponse is BaseTest {
IERC20 _token,
uint256 _bondSize,
uint256 _deadline,
bytes32 _finalizedResponseId
bytes32 _finalizedResponseId,
uint256 _finalizedAt
) public {
// Setting the response module data
mockRequest.responseModuleData = abi.encode(accounting, _token, _bondSize, _deadline, _baseDisputeWindow);
Expand All @@ -529,6 +530,7 @@ contract BondedResponseModule_Unit_ReleaseUnutilizedResponse is BaseTest {
// Can't claim back the bond of the response that was finalized
vm.assume(_finalizedResponseId > 0);
vm.assume(_finalizedResponseId != _responseId);
vm.assume(_finalizedAt > 0);

// Mock and expect IOracle.disputeOf to be called
_mockAndExpect(address(oracle), abi.encodeCall(IOracle.disputeOf, (_responseId)), abi.encode(bytes32(0)));
Expand All @@ -538,6 +540,8 @@ contract BondedResponseModule_Unit_ReleaseUnutilizedResponse is BaseTest {
address(oracle), abi.encodeCall(IOracle.finalizedResponseId, (_requestId)), abi.encode(_finalizedResponseId)
);

_mockAndExpect(address(oracle), abi.encodeCall(IOracle.finalizedAt, (_requestId)), abi.encode(_finalizedAt));

_mockAndExpect(
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_responseId)), abi.encode(block.timestamp)
);
Expand Down Expand Up @@ -580,6 +584,8 @@ contract BondedResponseModule_Unit_ReleaseUnutilizedResponse is BaseTest {
// Mock and expect IOracle.finalizedResponseId to be called
_mockAndExpect(address(oracle), abi.encodeCall(IOracle.finalizedResponseId, (_requestId)), abi.encode(0));

_mockAndExpect(address(oracle), abi.encodeCall(IOracle.finalizedAt, (_requestId)), abi.encode(0));

_mockAndExpect(
address(oracle), abi.encodeCall(IOracle.responseCreatedAt, (_responseId)), abi.encode(block.timestamp)
);
Expand All @@ -599,7 +605,8 @@ contract BondedResponseModule_Unit_ReleaseUnutilizedResponse is BaseTest {
uint256 _deadline,
address _proposer,
bytes32 _finalizedResponseId,
bytes32 _disputeId
bytes32 _disputeId,
uint256 _finalizedAt
) public {
// Setting the response module data
mockRequest.responseModuleData = abi.encode(accounting, _token, _bondSize, _deadline, _baseDisputeWindow);
Expand All @@ -615,6 +622,7 @@ contract BondedResponseModule_Unit_ReleaseUnutilizedResponse is BaseTest {
// Can't claim back the bond of the response that was finalized
vm.assume(_finalizedResponseId > 0);
vm.assume(_finalizedResponseId != _responseId);
vm.assume(_finalizedAt > 0);

// Mock and expect IOracle.disputeOf to be called
_mockAndExpect(address(oracle), abi.encodeCall(IOracle.disputeOf, (_responseId)), abi.encode(_disputeId));
Expand All @@ -624,6 +632,8 @@ contract BondedResponseModule_Unit_ReleaseUnutilizedResponse is BaseTest {
address(oracle), abi.encodeCall(IOracle.finalizedResponseId, (_requestId)), abi.encode(_finalizedResponseId)
);

_mockAndExpect(address(oracle), abi.encodeCall(IOracle.finalizedAt, (_requestId)), abi.encode(_finalizedAt));

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

0 comments on commit 43e8be6

Please sign in to comment.