Skip to content

Commit

Permalink
test(medusa): unwrap ghost logic from try blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJabberwock committed Nov 27, 2024
1 parent ed0d9fc commit 10a7a07
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions test/invariants/handlers/HandlerEBORequestCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,35 @@ contract HandlerEBORequestCreator is BaseHandler {
if (bytes(chainId).length == 0) return;

// Create request via EBORequestCreator
try eboRequestCreator.createRequest(_epoch, chainId) {
// Get current request data
IOracle.Request memory requestData = eboRequestCreator.getRequestData();
eboRequestCreator.createRequest(_epoch, chainId);

// Build request module parameters
IEBORequestModule.RequestParameters memory requestParams =
abi.decode(requestData.requestModuleData, (IEBORequestModule.RequestParameters));
requestParams.epoch = _epoch;
requestParams.chainId = chainId;
requestData.requestModuleData = abi.encode(requestParams);
// Get current request data
IOracle.Request memory requestData = eboRequestCreator.getRequestData();

// Calculate request ID using same logic as Oracle
bytes32 requestId = keccak256(abi.encode(requestData));
// Build request module parameters
IEBORequestModule.RequestParameters memory requestParams =
abi.decode(requestData.requestModuleData, (IEBORequestModule.RequestParameters));
requestParams.epoch = _epoch;
requestParams.chainId = chainId;
requestData.requestModuleData = abi.encode(requestParams);

// Track the request
_ghost_requests.push(requestId);
_ghost_requestsPerEpochChainId[_epoch][chainId].push(requestId);
_ghost_requestData[requestId] = requestData;
_ghost_validRequests[requestId] = true;
// Calculate request ID using same logic as Oracle
bytes32 requestId = keccak256(abi.encode(requestData));

emit RequestCreated(requestId, _epoch, chainId);
} catch {
return;
}
// Track the request
_ghost_requests.push(requestId);
_ghost_requestsPerEpochChainId[_epoch][chainId].push(requestId);
_ghost_requestData[requestId] = requestData;
_ghost_validRequests[requestId] = true;

emit RequestCreated(requestId, _epoch, chainId);
}

function handleAddChain(string memory _chainId) external {
try eboRequestCreator.addChain(_chainId) {
// Track the chain
_ghost_chainIdToChain[keccak256(abi.encodePacked(_chainId))] = _chainId;
} catch {
return;
}
eboRequestCreator.addChain(_chainId);

// Track the chain
_ghost_chainIdToChain[keccak256(abi.encodePacked(_chainId))] = _chainId;
}

// function handleRemoveChain(uint256 _chainIdSeed) external {
Expand Down

0 comments on commit 10a7a07

Please sign in to comment.