Skip to content

Commit

Permalink
fix: rely on local npm installation (#171)
Browse files Browse the repository at this point in the history
sakulstra authored Nov 8, 2023

Verified

This commit was signed with the committer’s verified signature.
TimoGlastra Timo Glastra
1 parent 9cc6ab0 commit 2111f26
Showing 6 changed files with 143 additions and 134 deletions.
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,31 +2,48 @@

This package contains various contracts which allow you to streamline testing within the aave protocol in foundry.

## GovHelpers (deprecated)
## Development

This project uses [Foundry](https://getfoundry.sh). See the [book](https://book.getfoundry.sh/getting-started/installation.html) for detailed instructions on how to install and use Foundry.

Some of the tooling relies on external calls via ffi to [aave-cli](https://github.com/bgd-labs/aave-cli).
Therefore you need to install aave-cli locally.

## Setup

```sh
cp .env.example .env
forge install
yarn
```

## Usage

### GovHelpers (deprecated)

These helpers allow you to create and execute proposals on L1 so you don't have to care about having enough proposition power, timings, etc.

## GovV3Helpers
### GovV3Helpers

These helpers allow the creation of proposal for aave governance v3.

The GovernanceV3Helpers also contain scripts to cast a vote directly via foundry.
To do so just run `make vote proposalId=n support=true/false`.

## ProxyHelpers
### ProxyHelpers

These helpers allow you to fetch the current implementation & admin for a specified proxy.

## BridgeExecutorHelpers
### BridgeExecutorHelpers

These helpers allow you to simulate execution of proposals on governance controlled Aave V2/V3 pools.

## ProtocolV3TestBase
### ProtocolV3TestBase

The ProtocolV3TestBase is intended to be used with proposals that alter a V3 pool. While the `helpers` are libraries, you can use from where ever you want `ProtocolV3TestBase` is intended to be inherited from in your test via `is ProtocolV3TestBase`.

When inheriting from `ProtocolV3TestBase` you have access to methods to create readable configuration snapshots of a pool and e2e tests of a pool.

## ProtocolV2TestBase
### ProtocolV2TestBase

Analog to ProtocolV3TestBase but for v2 pools.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -26,6 +26,6 @@
"prettier-plugin-solidity": "^1.1.3"
},
"dependencies": {
"@bgd-labs/aave-cli": "0.0.27-0a01f2a07efe0ec4c875cf479004d20350235f64.0"
"@bgd-labs/aave-cli": "^0.1.0"
}
}
16 changes: 7 additions & 9 deletions src/CommonTestBase.sol
Original file line number Diff line number Diff line change
@@ -127,16 +127,14 @@ contract CommonTestBase is Test {
string memory beforePath = string(abi.encodePacked('./reports/', reportBefore, '.json'));
string memory afterPath = string(abi.encodePacked('./reports/', reportAfter, '.json'));

string[] memory inputs = new string[](9);
string[] memory inputs = new string[](7);
inputs[0] = 'npx';
inputs[1] = '--yes';
inputs[2] = '-s';
inputs[3] = '@bgd-labs/[email protected]';
inputs[4] = 'diff-snapshots';
inputs[5] = beforePath;
inputs[6] = afterPath;
inputs[7] = '-o';
inputs[8] = outPath;
inputs[1] = '@bgd-labs/[email protected]';
inputs[2] = 'diff-snapshots';
inputs[3] = beforePath;
inputs[4] = afterPath;
inputs[5] = '-o';
inputs[6] = outPath;
vm.ffi(inputs);
}

32 changes: 14 additions & 18 deletions src/GovV3Helpers.sol
Original file line number Diff line number Diff line change
@@ -89,17 +89,15 @@ library GovV3Helpers {
uint256 proposalId,
address voter
) internal returns (IVotingMachineWithProofs.VotingBalanceProof[] memory) {
string[] memory inputs = new string[](10);
string[] memory inputs = new string[](8);
inputs[0] = 'npx';
inputs[1] = '--yes';
inputs[2] = '-s';
inputs[3] = '@bgd-labs/[email protected]';
inputs[4] = 'governance';
inputs[5] = 'getVotingProofs';
inputs[6] = '--proposalId';
inputs[7] = vm.toString(proposalId);
inputs[8] = '--voter';
inputs[9] = vm.toString(voter);
inputs[1] = '@bgd-labs/[email protected]';
inputs[2] = 'governance';
inputs[3] = 'getVotingProofs';
inputs[4] = '--proposalId';
inputs[5] = vm.toString(proposalId);
inputs[6] = '--voter';
inputs[7] = vm.toString(voter);
Vm.FfiResult memory f = vm.tryFfi(inputs);
if (f.exitCode != 0) {
console2.logString(string(f.stderr));
@@ -117,15 +115,13 @@ library GovV3Helpers {
Vm vm,
uint256 proposalId
) internal returns (StorageRootResponse[] memory) {
string[] memory inputs = new string[](8);
string[] memory inputs = new string[](6);
inputs[0] = 'npx';
inputs[1] = '--yes';
inputs[2] = '-s';
inputs[3] = '@bgd-labs/[email protected]';
inputs[4] = 'governance';
inputs[5] = 'getStorageRoots';
inputs[6] = '--proposalId';
inputs[7] = vm.toString(proposalId);
inputs[1] = '@bgd-labs/[email protected]';
inputs[2] = 'governance';
inputs[3] = 'getStorageRoots';
inputs[4] = '--proposalId';
inputs[5] = vm.toString(proposalId);
Vm.FfiResult memory f = vm.tryFfi(inputs);
if (f.exitCode != 0) {
console2.logString(string(f.stderr));
12 changes: 5 additions & 7 deletions src/IpfsUtils.sol
Original file line number Diff line number Diff line change
@@ -7,15 +7,13 @@ library IpfsUtils {
error FfiFailed();

function ipfsHashFile(Vm vm, string memory filePath, bool upload) internal returns (bytes32) {
string[] memory inputs = new string[](7);
string[] memory inputs = new string[](5);
inputs[0] = 'npx';
inputs[1] = '--yes';
inputs[2] = '-s';
inputs[3] = '@bgd-labs/[email protected]';
inputs[4] = 'ipfs';
inputs[5] = filePath;
inputs[1] = '@bgd-labs/[email protected]';
inputs[2] = 'ipfs';
inputs[3] = filePath;
if (upload) {
inputs[6] = '-u';
inputs[4] = '-u';
}
Vm.FfiResult memory f = vm.tryFfi(inputs);
if (f.exitCode != 0) {
Loading

0 comments on commit 2111f26

Please sign in to comment.