-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: invariant basic properties #47
Conversation
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nooooice!
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
bool _isManager; | ||
for (uint256 _i; _i < ghost_poolManagers[_poolId].length; _i++) { | ||
if (msg.sender == ghost_poolManagers[_poolId][_i]) { | ||
_isManager = true; | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be tidier as a function (ideally have it on the address type, so you could just use if(msg.sender.isManager() ...)
?
// Get the profile ID | ||
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)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be an helper in actors, pickActor(seed)
or smth
Signed-off-by: 0xRaccoon <[email protected]>
… into test/invariant-basic-properties Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
Signed-off-by: 0xRaccoon <[email protected]>
@@ -224,7 +230,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]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the -1
seems incorrect to me. idSeed
starts at 0, meaning seed % length starts at 0 too (and goes up to length - 1
when seed = length-1
(when seed = length, then length%length is back to the indice 0 of the array)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not reverting due to the underflow during the test as it's outside of an assert, but leave the last element of the array untouched
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, will fix
@@ -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)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, no -1
No description provided.