From d47b73aee5b559c78bfd76343f0c854a68be3145 Mon Sep 17 00:00:00 2001 From: shortdoom Date: Thu, 1 Feb 2024 22:37:05 +0100 Subject: [PATCH] test: ci_test_etherscan.sh, chore: lint/refactor --- crytic_compile/platform/etherscan.py | 16 ++++++++++---- scripts/ci_test_etherscan.sh | 31 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/crytic_compile/platform/etherscan.py b/crytic_compile/platform/etherscan.py index 23bb0a7d..004600e1 100644 --- a/crytic_compile/platform/etherscan.py +++ b/crytic_compile/platform/etherscan.py @@ -423,18 +423,26 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None: evm_version=evm_version, via_ir=via_ir_enabled, ) - + metadata_config = { "solc_remaps": remappings if remappings else {}, "solc_solcs_select": compiler_version, - "solc_args": ("--via-ir" if via_ir_enabled else "") - + ("--optimize --optimize-runs " + str(optimize_runs) if optimize_runs else "") - + ("--evm-version " + evm_version if evm_version else ""), + "solc_args": " ".join( + filter( + None, + [ + "--via-ir" if via_ir_enabled else "", + "--optimize --optimize-runs " + str(optimize_runs) if optimize_runs else "", + "--evm-version " + evm_version if evm_version else "", + ], + ) + ), } with open( os.path.join(working_dir if working_dir else export_dir, "crytic_compile.config.json"), "w", + encoding="utf-8", ) as f: json.dump(metadata_config, f) diff --git a/scripts/ci_test_etherscan.sh b/scripts/ci_test_etherscan.sh index 7adcef2c..5da40197 100755 --- a/scripts/ci_test_etherscan.sh +++ b/scripts/ci_test_etherscan.sh @@ -99,3 +99,34 @@ then exit 255 fi echo "::endgroup::" + +# From crytic/crytic-compile#544 +echo "::group::Etherscan #8" +crytic-compile 0x9AB6b21cDF116f611110b048987E58894786C244 --etherscan-apikey "$GITHUB_ETHERSCAN" + +if [ $? -ne 0 ] +then + echo "Etherscan #8 test failed" + exit 255 +fi + +dir_name=$(ls crytic-export/etherscan-contracts/ | grep 0x9AB6b21cDF116f611110b048987E58894786C244) +cd crytic-export/etherscan-contracts/$dir_name + +if [ ! -f crytic_compile.config.json ]; then + echo "crytic_compile.config.json does not exist" + exit 255 +fi + +# TODO: Globbing at crytic_compile.py:720 to run with '.' +crytic-compile 'contracts/InterestRates/InterestRatePositionManager.f.sol' --config-file crytic_compile.config.json + +if [ $? -ne 0 ] +then + echo "crytic-compile command failed" + exit 255 +fi + +cd ../../../ + +echo "::endgroup::" \ No newline at end of file