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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3c1a9b5
test: add basic invariant properties
0xRaccoon Oct 23, 2024
a5d360c
fix: add mising import
0xRaccoon Oct 23, 2024
716ef73
fix: add missing admin set
0xRaccoon Oct 23, 2024
387a085
test: add invariant test properties
0xRaccoon Oct 23, 2024
47df96a
test: update PROPERTIES.md
0xRaccoon Oct 23, 2024
261d610
test: remove test properties constraints
0xRaccoon Oct 24, 2024
4805dc8
fix: updated tests and partially tackled pr comments
0xRaccoon Oct 24, 2024
08ef593
fix: linter
0xRaccoon Oct 24, 2024
7963817
fix: linter
0xRaccoon Oct 24, 2024
5b8ec7d
fix: linter
0xRaccoon Oct 24, 2024
03a3f5f
fix: addressed pr comments
0xRaccoon Oct 25, 2024
973814b
fix: addressed pr comments
0xRaccoon Oct 25, 2024
cbff194
fix: rollback foundry fmt exclude removal
0xRaccoon Oct 25, 2024
9b994ea
fix: remove yarn.lock
0xRaccoon Oct 25, 2024
59f07c4
fix: properties
0xRaccoon Oct 25, 2024
345e961
fix: properties test
0xRaccoon Oct 25, 2024
4f02578
fix: properties test
0xRaccoon Oct 25, 2024
38cf7c3
fix: addressed pr comments
0xRaccoon Oct 29, 2024
7224964
Merge branch 'test/invariants' of github-defi:allo-protocol/allo-v2.1…
0xRaccoon Oct 29, 2024
c8b5d6e
fix: tests
0xRaccoon Oct 29, 2024
5ea6141
test: add admin assertions
0xRaccoon Oct 29, 2024
9c5ac9a
fix: assertion text
0xRaccoon Oct 29, 2024
857580c
fix: invariant properties
0xRaccoon Oct 29, 2024
3b6a0a7
fix: invariant properties assertions
0xRaccoon Oct 29, 2024
d50ac94
fix: invariant tests
0xRaccoon Oct 29, 2024
74a3805
fix: invariant properties test
0xRaccoon Oct 29, 2024
517a9a3
fix: invariant properties
0xRaccoon Oct 29, 2024
eb5636b
test: fix invariant test assertion
0xRaccoon Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions test/invariant/PROPERTIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
| 2 | a token allocation never “disappears” (withdraw cannot impact an allocation) | [] |
| 3 | an address can only withdraw if has allocation | [] |
| 4 | profile owner can always create a pool | [] |
| 5 | profile owner is the only one who can always add/remove/modify profile members (name ⇒ new anchor()) | [] |
| 6 | profile owner is the only one who can always initiate a change of profile owner (2 steps) | [] |
| 5 | profile owner is the only one who can always add/remove/modify profile members (name ⇒ new anchor()) | [x] |
| 6 | profile owner is the only one who can always initiate a change of profile owner (2 steps) | [x] |
| 7 | profile member can always create a pool | [] |
| 8 | only profile owner or member can create a pool | [] |
| 9 | initial admin is always the creator of the pool | [] |
| 10 | pool admin can always change admin (but not to address(0)) | [] |
| 11 | pool admin can always add/remove pool managers | [] |
| 10 | pool admin can always change admin (but not to address(0)) | [x] |
| 11 | pool admin can always add/remove pool managers | [x] |
| 12 | pool manager can always withdraw within strategy limits/logic | [] |
| 13 | pool manager can always change metadata | [] |
| 14 | allo owner can always change base fee (flat) and percent flee (./. funding amt) to any arbitrary value (max 100%) | [] |
| 15 | allo owner can always change the treasury address/trustred forwarded/etc | [] |
| 13 | pool manager can always change metadata | [x] |
| 14 | allo owner can always change base fee (flat) and percent flee (./. funding amt) to any arbitrary value (max 100%) | [x] |
| 15 | allo owner can always change the treasury address/trustred forwarded/etc | [x] |
| 16 | allo owner can always recover funds from allo contract ( (non-)native token ) | [] |
| 17 | only funds not allocated can be withdrawn | [] |
| 18 | anyone can increase fund in a pool, if strategy (hook) logic allows so and if more than base fee | [] |
Expand Down
39 changes: 10 additions & 29 deletions test/invariant/fuzz/Setup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,13 @@ contract Setup is Actors, Pools {
registry = new Registry();

// Deploy the proxy, pointing to the implementation
TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(
implementation,
proxyOwner,
""
);
TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(implementation, proxyOwner, "");

allo = Allo(payable(address(proxy)));

// Initialize
vm.prank(protocolDeployer);
allo.initialize(
protocolDeployer,
address(registry),
payable(treasury),
percentFee,
baseFee,
forwarder
);
allo.initialize(protocolDeployer, address(registry), payable(treasury), percentFee, baseFee, forwarder);

// Deploy strategies implementations
_initImplementations(address(allo));
Expand All @@ -75,19 +64,12 @@ contract Setup is Actors, Pools {
token = ERC20(address(new FuzzERC20()));

// Create profile for 4 addresses
for (uint i; i < 4; i++) {
for (uint256 i; i < 4; i++) {
bytes32 _id = registry.createProfile(
0,
"a",
Metadata({protocol: i + 1, pointer: ""}),
_ghost_actors[i],
new address[](0)
0, "a", Metadata({protocol: i + 1, pointer: ""}), _ghost_actors[i], new address[](0)
);

_addAnchorToActor(
_ghost_actors[i],
registry.getProfileById(_id).anchor
);
_addAnchorToActor(_ghost_actors[i], registry.getProfileById(_id).anchor, _id);
}

// Create pools for each strategy
Expand All @@ -105,9 +87,7 @@ contract Setup is Actors, Pools {
for (uint256 i = 1; i <= uint256(type(PoolStrategies).max); i++) {
address _deployer = _ghost_actors[i % 4];

IRegistry.Profile memory profile = registry.getProfileByAnchor(
_ghost_anchorOf[_deployer]
);
IRegistry.Profile memory profile = registry.getProfileByAnchor(_ghost_anchorOf[_deployer]);

bytes memory _metadata;

Expand All @@ -126,9 +106,9 @@ contract Setup is Actors, Pools {
token,
true
);
} else if (
PoolStrategies(i) == PoolStrategies.EasyRPGF
) {} else if (PoolStrategies(i) == PoolStrategies.ImpactStream) {
} else if (PoolStrategies(i) == PoolStrategies.EasyRPGF) {} else if (
PoolStrategies(i) == PoolStrategies.ImpactStream
) {
_metadata = abi.encode(
IRecipientsExtension.RecipientInitializeData({
metadataRequired: false,
Expand Down Expand Up @@ -182,6 +162,7 @@ contract Setup is Actors, Pools {
);

ghost_poolAdmins[_poolId] = _deployer;
assertTrue(allo.isPoolAdmin(_poolId, _deployer), "Admin not set _initPools_");

_recordPool(_poolId, PoolStrategies(i));
}
Expand Down
Loading
Loading