Skip to content

Commit

Permalink
test(medusa): correct prop-1
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJabberwock committed Nov 27, 2024
1 parent 710c3d1 commit bc114a9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions test/invariants/properties/PropertyRequester.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ contract PropertyRequester is HandlerParent {
constructor() {}

/// @custom:property-id 1
/// @custom:property Requester can always create a request as long as the same chainId/epoch isn't finalized with response
/// @custom:property Requester can always create a request as long as the same chainId/epoch isn't already active
/// or finalized with response
function property_canAlwaysCreateRequest(uint256 _epoch, uint256 _chainIdSeed) external {
_epoch = bound(_epoch, START_EPOCH, block.timestamp);

Expand All @@ -18,20 +19,23 @@ contract PropertyRequester is HandlerParent {

uint256 requestsPerEpochChainId = _ghost_requestsPerEpochChainId[_epoch][chainId].length;
bytes32 requestId;
uint256 activeRequests;
bool isFinalizedWithResponse;

// Create request via EBORequestCreator
try eboRequestCreator.createRequest(_epoch, chainId) {
// Check if there is a request finalized with response
// Check if there are active requests and a request finalized with response
for (uint256 i; i < requestsPerEpochChainId; ++i) {
requestId = _ghost_requestsPerEpochChainId[_epoch][chainId][i];
if (oracle.finalizedAt(requestId) == 0) ++activeRequests;
if (oracle.finalizedResponseId(requestId) != 0) {
isFinalizedWithResponse = true;
break;
}
}

assertFalse(isFinalizedWithResponse, 'prop-1: same chainId/epoch request already finalized with response');
assertEq(activeRequests, 0, 'prop-1: same chainId/epoch active request');

// Get current request data
IOracle.Request memory requestData = eboRequestCreator.getRequestData();
Expand All @@ -54,16 +58,17 @@ contract PropertyRequester is HandlerParent {

emit RequestCreated(requestId, _epoch, chainId);
} catch {
// Check if there is a request finalized with response
// Check if there are active requests and a request finalized with response
for (uint256 i; i < requestsPerEpochChainId; ++i) {
requestId = _ghost_requestsPerEpochChainId[_epoch][chainId][i];
if (oracle.finalizedAt(requestId) == 0) ++activeRequests;
if (oracle.finalizedResponseId(requestId) != 0) {
isFinalizedWithResponse = true;
break;
}
}

assertTrue(isFinalizedWithResponse, 'prop-1: create request reverted');
assertTrue(isFinalizedWithResponse || activeRequests > 0, 'prop-1: create request reverted');
}
}

Expand Down

0 comments on commit bc114a9

Please sign in to comment.