Skip to content

Commit d47b73a

Browse files
committed
test: ci_test_etherscan.sh, chore: lint/refactor
1 parent b5f0d62 commit d47b73a

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

crytic_compile/platform/etherscan.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,18 +423,26 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
423423
evm_version=evm_version,
424424
via_ir=via_ir_enabled,
425425
)
426-
426+
427427
metadata_config = {
428428
"solc_remaps": remappings if remappings else {},
429429
"solc_solcs_select": compiler_version,
430-
"solc_args": ("--via-ir" if via_ir_enabled else "")
431-
+ ("--optimize --optimize-runs " + str(optimize_runs) if optimize_runs else "")
432-
+ ("--evm-version " + evm_version if evm_version else ""),
430+
"solc_args": " ".join(
431+
filter(
432+
None,
433+
[
434+
"--via-ir" if via_ir_enabled else "",
435+
"--optimize --optimize-runs " + str(optimize_runs) if optimize_runs else "",
436+
"--evm-version " + evm_version if evm_version else "",
437+
],
438+
)
439+
),
433440
}
434441

435442
with open(
436443
os.path.join(working_dir if working_dir else export_dir, "crytic_compile.config.json"),
437444
"w",
445+
encoding="utf-8",
438446
) as f:
439447
json.dump(metadata_config, f)
440448

scripts/ci_test_etherscan.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,34 @@ then
9999
exit 255
100100
fi
101101
echo "::endgroup::"
102+
103+
# From crytic/crytic-compile#544
104+
echo "::group::Etherscan #8"
105+
crytic-compile 0x9AB6b21cDF116f611110b048987E58894786C244 --etherscan-apikey "$GITHUB_ETHERSCAN"
106+
107+
if [ $? -ne 0 ]
108+
then
109+
echo "Etherscan #8 test failed"
110+
exit 255
111+
fi
112+
113+
dir_name=$(ls crytic-export/etherscan-contracts/ | grep 0x9AB6b21cDF116f611110b048987E58894786C244)
114+
cd crytic-export/etherscan-contracts/$dir_name
115+
116+
if [ ! -f crytic_compile.config.json ]; then
117+
echo "crytic_compile.config.json does not exist"
118+
exit 255
119+
fi
120+
121+
# TODO: Globbing at crytic_compile.py:720 to run with '.'
122+
crytic-compile 'contracts/InterestRates/InterestRatePositionManager.f.sol' --config-file crytic_compile.config.json
123+
124+
if [ $? -ne 0 ]
125+
then
126+
echo "crytic-compile command failed"
127+
exit 255
128+
fi
129+
130+
cd ../../../
131+
132+
echo "::endgroup::"

0 commit comments

Comments
 (0)