Skip to content

Commit

Permalink
test(medusa): track chains added after setup
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJabberwock committed Nov 22, 2024
1 parent b7da278 commit 3e7ae3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions test/invariants/handlers/BaseHandler.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ contract BaseHandler is Setup, Actors {
mapping(uint256 _epoch => mapping(string _chainId => bytes32[] _requestIds)) internal _ghost_requestsPerEpochChainId;

// Track the chainId->chain (reverse the hash)
mapping(bytes32 _hash => string _chain) internal ghost_chainIdToChain;
mapping(bytes32 _hash => string _chain) internal _ghost_chainIdToChain;

// Track request details
mapping(bytes32 _requestId => IOracle.Request _data) internal _ghost_requestData;
Expand All @@ -39,7 +39,7 @@ contract BaseHandler is Setup, Actors {
bytes32[] memory chainIds = eboRequestCreator.getAllowedChainIds();
if (chainIds.length == 0) return '';

return string(ghost_chainIdToChain[chainIds[_seed % chainIds.length]]);
return _ghost_chainIdToChain[chainIds[_seed % chainIds.length]];
}

function _getRandomRequestId(uint256 _seed) internal view returns (bytes32) {
Expand Down
9 changes: 6 additions & 3 deletions test/invariants/handlers/HandlerEBORequestCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ contract HandlerEBORequestCreator is BaseHandler {
constructor() {
// Initialize the ghost mapping, allowing to reverse lookup the chain
for (uint256 i; i < INITIAL_CHAINS.length; i++) {
ghost_chainIdToChain[keccak256(abi.encodePacked(INITIAL_CHAINS[i]))] = INITIAL_CHAINS[i];
_ghost_chainIdToChain[keccak256(abi.encodePacked(INITIAL_CHAINS[i]))] = INITIAL_CHAINS[i];
}
}

Expand Down Expand Up @@ -56,8 +56,11 @@ contract HandlerEBORequestCreator is BaseHandler {
emit RequestCreated(requestId, _epoch, chainId);
}

function handleAddChain(string memory chainId) external {
eboRequestCreator.addChain(chainId);
function handleAddChain(string memory _chainId) external {
eboRequestCreator.addChain(_chainId);

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

function handleRemoveChain(uint256 _chainIdSeed) external {
Expand Down

0 comments on commit 3e7ae3e

Please sign in to comment.