Skip to content

Commit

Permalink
fix: invariant tests
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 3b6a0a7 commit d50ac94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions test/invariant/fuzz/handlers/HandlerAllo.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ contract HandlerAllo is Setup {
return _poolIds;
}

function _isManager(address _sende, uint256 _poolId) internal returns (bool _isManager) {
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;
__isManager = true;
break;
}
}
Expand Down
11 changes: 6 additions & 5 deletions test/invariant/fuzz/properties/PropertiesAllo.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ contract PropertiesAllo is HandlersParent {

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

if (allo.isPoolAdmin(_poolId, msg.sender)) {
if (msg.sender == _admin) {
if (_success) {
if (_newAdmin != _admin) {
assertTrue(
Expand All @@ -128,8 +128,8 @@ contract PropertiesAllo is HandlersParent {
);
}
assertTrue(allo.hasRole(_poolAdminRole, _newAdmin), "property-id 10: changeAdmin failed role not set");
ghost_poolAdmins[_poolId] = _newAdmin;
assertTrue(allo.isPoolAdmin(_poolId, _newAdmin), "property-id 10: admin not set");
ghost_poolAdmins[_poolId] = _newAdmin;
} else {
assertTrue(_newAdmin == address(0) || _usingAnchor, "property-id 10: changeAdmin failed");
}
Expand Down Expand Up @@ -157,7 +157,7 @@ contract PropertiesAllo is HandlersParent {

(bool _success,) = targetCall(address(allo), 0, abi.encodeCall(allo.addPoolManagers, (_poolId, _managers)));

if (allo.isPoolAdmin(_poolId, msg.sender)) {
if (msg.sender == _admin) {
if (_success) {
assertTrue(
allo.hasRole(_poolManagerRole, _newManager), "property-id 11-a: addPoolManagers failed role not set"
Expand Down Expand Up @@ -190,7 +190,7 @@ contract PropertiesAllo is HandlersParent {
(bool _success,) =
targetCall(address(allo), 0, abi.encodeCall(allo.removePoolManagers, (_poolId, _removeManagers)));

if (allo.isPoolAdmin(_poolId, msg.sender)) {
if (msg.sender == _admin) {
if (_success) {
assertTrue(!allo.hasRole(_poolManagerRole, _manager), "property-id 11-b: removePoolManagers failed");
delete ghost_poolManagers[_poolId];
Expand Down Expand Up @@ -218,10 +218,11 @@ contract PropertiesAllo is HandlersParent {
function prop_poolManagerCanAlwaysChangeMetadata(uint256 _idSeed, Metadata calldata _metadata) public {
_idSeed = bound(_idSeed, 0, ghost_poolIds.length - 1);
uint256 _poolId = ghost_poolIds[_idSeed];
address _admin = ghost_poolAdmins[_poolId];

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

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

0 comments on commit d50ac94

Please sign in to comment.