Skip to content

Commit

Permalink
Merge pull request #58 from allo-protocol/test/summary-md
Browse files Browse the repository at this point in the history
chore: test doc + echidna retrocompat
  • Loading branch information
simon-something authored Jan 15, 2025
2 parents 447d8bd + c0ffee2 commit 0b14776
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"compile": "forge compile",
"build": "forge build",
"test": "forge test",
"test:unit": "forge test --no-match-contract 'Integration'",
"test:integration": "forge test --match-contract 'Integration'",
"fmt": "forge fmt contracts/**/*.sol && forge fmt test/**/*.sol",
"lint:sol": "solhint -c .solhint.json 'contracts/**/*.sol'",
"lint:natspec": "npx @defi-wonderland/natspec-smells --config natspec-smells.config.js",
Expand Down
18 changes: 14 additions & 4 deletions test/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# Tests summary.

## Unit Tests
Written using [Forge Foundry](https://getfoundry.sh/), [Smock](https://github.com/defi-wonderland/smock-foundry) and [Bulloak](https://www.bulloak.dev/),
they cover every contracts of this repository.

To run them, after installing all dependencies, generate the mocks using `[your package manager] smock` (eg `yarn mock`)
then run the tests using `[your package manager] test:unit` (eg `yarn test`).

Medusa:
- No agent, substitued by profile owner or member
## Integration Tests
We cover every user story of the strategies.
To run them, after installing depedencies, define both Optimism and Mainnet RPC URL (eg `export MAINNET_RPC_URL=https://etc`), then use `[your package manager] test:integration` (eg `yarn test:integration`).


TODO: use trusted forwarder
## Invariant Tests
We assess how 8 invariants are holding against Medusa and Echidna fuzzer (see the PROPERTIES.md file
for the complete list). To run both campaigns, use the following commands:
- `medusa fuzz .` (this is our default tool, configuration is included in this repo)
- `echidna --contract FuzzTest --test-mode assertion test/invariant/fuzz/FuzzTest.t.sol`
18 changes: 13 additions & 5 deletions test/invariant/fuzz/Setup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,29 @@ contract Setup is HandlerActors, Pools {

constructor() {
// Deploy Allo
vm.prank(protocolDeployer);
address implementation = address(new Allo());

// Deploy the registry
vm.prank(protocolDeployer);
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 Down
14 changes: 7 additions & 7 deletions test/invariant/fuzz/helpers/Actors.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ contract Actors is Utils {
uint256 msgValue,
bytes memory payload
) public returns (bool, bytes memory) {
emit ActorsLog(
string.concat("call using anchor of ", vm.toString(address(this)))
);
//emit ActorsLog(
// string.concat("call using anchor of ", vm.toString(address(this)))
//);

vm.deal(payable(address(this)), msgValue);

Expand All @@ -36,7 +36,7 @@ contract Actors is Utils {
);

if (!succ) {
emit ActorsLog(vm.toString(ret));
//emit ActorsLog(vm.toString(ret));
return (succ, ret);
}

Expand All @@ -52,9 +52,9 @@ contract Actors is Utils {
uint256 msgValue,
bytes memory payload
) public returns (bool success, bytes memory returnData) {
emit ActorsLog(
string.concat("call using actor ", vm.toString(address(this)))
);
// emit ActorsLog(
// string.concat("call using actor ", vm.toString(address(this)))
// );

vm.deal(payable(address(this)), msgValue);

Expand Down

0 comments on commit 0b14776

Please sign in to comment.