Skip to content

Commit

Permalink
fix: addressed pr comments
Browse files Browse the repository at this point in the history
Signed-off-by: 0xRaccoon <[email protected]>
  • Loading branch information
0xRaccoon committed Oct 29, 2024
1 parent 4f02578 commit 38cf7c3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
11 changes: 10 additions & 1 deletion test/invariant/fuzz/handlers/HandlerAllo.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ contract HandlerAllo is Setup {
function _pickPoolId(uint256 _idSeed) internal view returns (uint256) {
if (ghost_poolIds.length == 0) return 0;

return ghost_poolIds[_idSeed % ghost_poolIds.length];
return ghost_poolIds[_idSeed % ghost_poolIds.length - 1];
}

function _pickPoolId(uint256[] memory _seeds) internal view returns (uint256[] memory) {
Expand All @@ -231,4 +231,13 @@ contract HandlerAllo is Setup {

return _poolIds;
}

function _isManager(address _sende, uint256 _poolId) internal returns (bool _isManager) {
for (uint256 _i; _i < ghost_poolManagers[_poolId].length; _i++) {
if (msg.sender == ghost_poolManagers[_poolId][_i]) {
_isManager = true;
break;
}
}
}
}
4 changes: 4 additions & 0 deletions test/invariant/fuzz/helpers/Actors.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,8 @@ contract Actors is Utils {
function _removeAnchorFromActor(address _actor, bytes32 _profileId) internal {
delete _ghost_anchorOf[_actor];
}

function _pickActor(uint256 _seed) internal view returns (address _actor) {
_actor = _ghost_actors[_seed % (_ghost_actors.length - 1)];
}
}
14 changes: 3 additions & 11 deletions test/invariant/fuzz/properties/PropertiesAllo.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract PropertiesAllo is HandlersParent {
IRegistry.Profile memory _profile = registry.getProfileByAnchor(_ghost_anchorOf[msg.sender]);

address[] memory _members = new address[](1);
address _newMember = _ghost_actors[_actorSeed % (_ghost_actors.length - 1)];
address _newMember = _pickActor(_actorSeed);
_members[0] = _newMember;

(bool _success,) =
Expand Down Expand Up @@ -115,7 +115,7 @@ contract PropertiesAllo is HandlersParent {

bytes32 _poolAdminRole = keccak256(abi.encodePacked(_poolId, "admin"));

address _newAdmin = _ghost_actors[_actorSeed % (_ghost_actors.length - 1)];
address _newAdmin = _pickActor(_actorSeed);

(bool _success,) = targetCall(address(allo), 0, abi.encodeCall(allo.changeAdmin, (_poolId, _newAdmin)));

Expand Down Expand Up @@ -217,15 +217,7 @@ contract PropertiesAllo is HandlersParent {

(bool _success,) = targetCall(address(allo), 0, abi.encodeCall(allo.updatePoolMetadata, (_poolId, _metadata)));

bool _isManager;
for (uint256 _i; _i < ghost_poolManagers[_poolId].length; _i++) {
if (msg.sender == ghost_poolManagers[_poolId][_i]) {
_isManager = true;
break;
}
}

if (_isManager || msg.sender == ghost_poolAdmins[_poolId]) {
if (_isManager(msg.sender, _poolId) || msg.sender == ghost_poolAdmins[_poolId]) {
if (_success) {
Allo.Pool memory _pool = allo.getPool(_poolId);
assertEq(
Expand Down

0 comments on commit 38cf7c3

Please sign in to comment.