-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
executable file
·115 lines (78 loc) · 3.51 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env just --justfile
bt := '0'
export RUST_BACKTRACE := bt
log := "warn"
export JUST_LOG := log
# load .env file
set dotenv-load
# pass recipe args as positional arguments to commands
set positional-arguments
##<><><>< Environment ----
HEX_18 := "0x0000000000000000000000000000000000000000000000000000000000000012"
HEX_12 := "0x000000000000000000000000000000000000000000000000000000000000000c"
HEX_8 := "0x0000000000000000000000000000000000000000000000000000000000000008"
HEX_6 := "0x0000000000000000000000000000000000000000000000000000000000000006"
# set mock target to 18 decimals by default
FORGE_MOCK_TARGET_DECIMALS := env_var_or_default("FORGE_MOCK_TARGET_DECIMALS", HEX_18)
FORGE_MOCK_UNDERLYING_DECIMALS := env_var_or_default("FORGE_MOCK_UNDERLYING_DECIMALS", HEX_18)
DAPP_BUILD_OPTIMIZE := "1"
DAPP_COVERAGE := "1"
DAPP_REMAPPINGS := remappings-from-pkg-deps
# when developing we only want to fuzz briefly
DAPP_TEST_FUZZ_RUNS := "100"
ALCHEMY_KEY := env_var("ALCHEMY_KEY")
MAINNET_RPC := "https://eth-mainnet.alchemyapi.io/v2/" + ALCHEMY_KEY
MNEMONIC := env_var_or_default("MNEMONIC", "")
ETHERSCAN_API_KEY := env_var_or_default("ETHERSCAN_API_KEY", "")
# export just vars as env vars
set export
_default:
just --list
size:
forge build --sizes --force
# build using forge
build: && _timer
cd {{ invocation_directory() }}; forge build
# default test scripts
test: test-local
# run local forge test using --match <PATTERN>
test-local *commands="": && _timer
cd {{ invocation_directory() }}; forge test -m ".t.sol" {{ commands }}
# run mainnet fork forge tests (all files with the extension .debug.sol)
test-mainnet *commands="": && _timer
cd {{ invocation_directory() }}; forge test --rpc-url {{ MAINNET_RPC }} -m ".debug.sol" {{ commands }}
turbo-test-mainnet: && _timer
@cd {{ invocation_directory() }}; forge test --match-path "*.t*" --fork-url {{ MAINNET_RPC }}
turbo-test-mainnet-match *exp="": && _timer
@cd {{ invocation_directory() }}; forge test --match-path "*.t*" --fork-url {{ MAINNET_RPC }} --match-test {{ exp }}
gas-snapshot: gas-snapshot-local
# get gas snapshot from local tests and save it to file
gas-snapshot-local:
cd {{ invocation_directory() }}; \
just test-local | grep 'gas:' | cut -d " " -f 2-4 | sort > \
{{ justfile_directory() }}/gas-snapshots/.$( \
cat {{ invocation_directory() }}/package.json | jq .name | tr -d '"' | cut -d"/" -f2- \
)
forge-gas-snapshot: && _timer
@cd {{ invocation_directory() }}; forge snapshot --no-match-path ".*t.*"
forge-gas-snapshot-diff: && _timer
@cd {{ invocation_directory() }}; forge snapshot --no-match-path ".*t.*" --diff
# utility functions
start_time := `date +%s`
_timer:
@echo "Task executed in $(($(date +%s) - {{ start_time }})) seconds"
# Solidity test ffi callback to get Target decimals for the base Mock Target token
_forge_mock_target_decimals:
@printf {{ FORGE_MOCK_TARGET_DECIMALS }}
_forge_mock_underlying_decimals:
@printf {{ FORGE_MOCK_UNDERLYING_DECIMALS }}
remappings-from-pkg-deps := ```
cat pkg/*/package.json |
jq 'select(.dependencies != null) | .dependencies | to_entries | map([.key + "/", "../../node_modules/" + .key + "/"] | join("="))' |
tr -d '[],"' | xargs | tr ' ' '\n' | sort | uniq
```
lib-paths-from-pkg-deps := ```
cat pkg/*/package.json |
jq 'select(.dependencies != null) | .dependencies | to_entries | map("../../node_modules/" + .key + "/")' |
tr -d '[],"' | xargs | tr ' ' '\n' | sort | uniq | awk '{print "--lib-paths " $0}' | tr '\n' ' '
```