-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from charlesndalton/migrate-foundry
Migrate test suite to foundry
- Loading branch information
Showing
39 changed files
with
809 additions
and
2,293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,53 +12,13 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Cache compiler installations | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.solcx | ||
~/.vvm | ||
key: ${{ runner.os }}-compiler-cache | ||
|
||
- name: Setup node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12.x' | ||
|
||
- name: Install ganache | ||
run: npm install -g [email protected] | ||
|
||
- name: Set up python 3.9 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Set pip cache directory path | ||
id: pip-cache-dir-path | ||
run: | | ||
echo "::set-output name=dir::$(pip cache dir)" | ||
- name: Restore pip cache | ||
uses: actions/cache@v2 | ||
id: pip-cache | ||
- uses: actions/checkout@v3 | ||
with: | ||
path: | | ||
${{ steps.pip-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-dev.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip-${{ hashFiles('**/requirements-dev.txt') }} | ||
${{ runner.os }}-pip- | ||
submodules: recursive | ||
|
||
- name: Install python dependencies | ||
run: pip install -r requirements-dev.txt | ||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
|
||
- name: Compile Code | ||
run: brownie compile --size | ||
- name: Run tests | ||
run: forge test -vv --fork-url "https://mainnet.infura.io/v3/e74132f416d346308763252779d7df22" --etherscan-api-key "MW5CQA6QK5YMJXP2WP3RA36HM5A7RA1IHA" --ffi | ||
|
||
- name: Run Tests | ||
env: | ||
ETHERSCAN_TOKEN: MW5CQA6QK5YMJXP2WP3RA36HM5A7RA1IHA | ||
WEB3_INFURA_PROJECT_ID: b7821200399e4be2b4e5dbdf06fbe85b | ||
run: brownie test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ build/ | |
reports/ | ||
node_modules/ | ||
.DS_Store | ||
cache | ||
out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[submodule "lib/openzeppelin-contracts"] | ||
path = lib/openzeppelin-contracts | ||
url = https://github.com/openzeppelin/openzeppelin-contracts | ||
[submodule "lib/contracts"] | ||
path = lib/contracts | ||
url = https://github.com/cowprotocol/contracts | ||
[submodule "lib/balancer-v2-monorepo"] | ||
path = lib/balancer-v2-monorepo | ||
url = https://github.com/balancer/balancer-v2-monorepo | ||
[submodule "lib/forge-std"] | ||
path = lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
[submodule "lib/surl-0.7"] | ||
path = lib/surl-0.7 | ||
url = https://github.com/charlesndalton/surl-0.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# include .env file and export its env vars | ||
# (-include to ignore error if it does not exist) | ||
-include .env | ||
|
||
# deps | ||
update:; forge update | ||
|
||
# Build & test | ||
# change ETH_RPC_URL to another one (e.g., FTM_RPC_URL) for different chains | ||
FORK_URL := ${ETH_RPC_URL} | ||
|
||
.PHONY: build test test-operation test-all-operation trace test-contract trace-contract deploy test-local trace-local clean snapshot | ||
|
||
# For deployments. Add all args without a comma | ||
# ex: 0x316..FB5 "Name" 10 | ||
constructor-args := | ||
|
||
build :; forge build | ||
test :; forge test -vv --fork-url ${FORK_URL} --etherscan-api-key ${ETHERSCAN_API_KEY} --ffi | ||
test-operation :; forge test -vvv --fork-url ${FORK_URL} --etherscan-api-key ${ETHERSCAN_API_KEY} --match-test "testProfitableHarvest_AngleFarmingProfit" | ||
test-all-operation :; forge test -vv --fork-url ${FORK_URL} --etherscan-api-key ${ETHERSCAN_API_KEY} --match-contract "StrategyOperation" | ||
trace :; forge test -vvv --fork-url ${FORK_URL} --etherscan-api-key ${ETHERSCAN_API_KEY} | ||
test-contract :; forge test -vv --fork-url ${FORK_URL} --match-contract $(contract) --etherscan-api-key ${ETHERSCAN_API_KEY} | ||
trace-contract :; forge test -vvv --fork-url ${FORK_URL} --match-contract $(contract) --etherscan-api-key ${ETHERSCAN_API_KEY} | ||
deploy :; forge create --rpc-url ${FORK_URL} --constructor-args ${constructor-args} --private-key ${PRIV_KEY} src/Strategy.sol:Strategy --etherscan-api-key ${ETHERSCAN_API_KEY} --verify | ||
# local tests without fork | ||
test-local :; forge test | ||
trace-local :; forge test -vvv | ||
clean :; forge clean | ||
snapshot :; forge snapshot |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
profile = { default = { libs = ["node_modules", "lib"] } } |
Submodule balancer-v2-monorepo
added at
c5b42e
Submodule openzeppelin-contracts
added at
5c8746
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@openzeppelin/=lib/openzeppelin-contracts/ | ||
@cow-protocol/=lib/contracts/src | ||
@balancer=lib/balancer-v2-monorepo/contracts | ||
surl=lib/surl-0.7/src |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 6 additions & 8 deletions
14
contracts/periphery/GasChecker.sol → src/periphery/GasChecker.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
pragma solidity ^0.7.6; | ||
|
||
pragma abicoder v2; | ||
|
||
interface EIP1271 { | ||
function isValidSignature(bytes32, bytes calldata) | ||
external | ||
returns (bytes4); | ||
function isValidSignature(bytes32, bytes calldata) external returns (bytes4); | ||
} | ||
|
||
/// Check that `isValidSignature` doesn't take up too much gas | ||
contract GasChecker { | ||
function isValidSignatureCheck( | ||
address milkman, | ||
bytes32 orderDigest, | ||
bytes calldata encodedOrder | ||
) external returns (bytes4) { | ||
function isValidSignatureCheck(address milkman, bytes32 orderDigest, bytes calldata encodedOrder) | ||
external | ||
returns (bytes4) | ||
{ | ||
return EIP1271(milkman).isValidSignature(orderDigest, encodedOrder); | ||
} | ||
} |
Oops, something went wrong.