Skip to content
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

Merged
merged 28 commits into from
Oct 29, 2024

Conversation

0xRaccoon
Copy link

No description provided.

@0xRaccoon 0xRaccoon changed the base branch from main to test/invariants October 23, 2024 12:57
Copy link

@simon-something simon-something left a 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]>
Comment on lines 220 to 225
bool _isManager;
for (uint256 _i; _i < ghost_poolManagers[_poolId].length; _i++) {
if (msg.sender == ghost_poolManagers[_poolId][_i]) {
_isManager = true;
break;
}

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)];

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

@@ -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];

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)

Copy link

@simon-something simon-something Oct 29, 2024

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

Copy link
Author

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)];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, no -1

@0xRaccoon 0xRaccoon merged commit eb5636b into test/invariants Oct 29, 2024
2 checks passed
@0xRaccoon 0xRaccoon deleted the test/invariant-basic-properties branch October 29, 2024 16:27
@0xRaccoon 0xRaccoon restored the test/invariant-basic-properties branch October 29, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants