Skip to content

Commit 7a7c56b

Browse files
committed
ci: etherscan: sleep briefly when the API key is not available
Etherscan performs a 1/5s rate limit when using no API key, so this adds a small random sleep to avoid the second test failing if it executes fast enough.
1 parent ba44500 commit 7a7c56b

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

scripts/ci_test_etherscan.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,44 @@ cd "$DIR" || exit 255
77

88
solc-select use 0.4.25 --always-install
99

10+
delay_no_key () {
11+
# Perform a small sleep when API key is not available (e.g. on PR CI from external contributor)
12+
if [ "$GITHUB_ETHERSCAN" = "" ]; then
13+
sleep $(( ( RANDOM % 5 ) + 1 ))s
14+
fi
15+
}
16+
17+
echo "::group::Etherscan mainnet"
1018
crytic-compile 0x7F37f78cBD74481E593F9C737776F7113d76B315 --compile-remove-metadata --etherscan-apikey "$GITHUB_ETHERSCAN"
1119

1220
if [ $? -ne 0 ]
1321
then
14-
echo "Etherscan test failed"
22+
echo "Etherscan mainnet test failed"
1523
exit 255
1624
fi
25+
echo "::endgroup::"
1726

27+
delay_no_key
28+
29+
echo "::group::Etherscan rinkeby"
1830
crytic-compile rinkeby:0xFe05820C5A92D9bc906D4A46F662dbeba794d3b7 --compile-remove-metadata --etherscan-apikey "$GITHUB_ETHERSCAN"
1931

2032
if [ $? -ne 0 ]
2133
then
22-
echo "Etherscan test failed"
34+
echo "Etherscan rinkeby test failed"
2335
exit 255
2436
fi
37+
echo "::endgroup::"
38+
39+
delay_no_key
2540

2641
# From crytic/slither#1154
42+
echo "::group::Etherscan #3"
2743
crytic-compile 0xcfc1E0968CA08aEe88CbF664D4A1f8B881d90f37 --compile-remove-metadata --etherscan-apikey "$GITHUB_ETHERSCAN"
2844

2945
if [ $? -ne 0 ]
3046
then
31-
echo "Etherscan test failed"
47+
echo "Etherscan #3 test failed"
3248
exit 255
3349
fi
50+
echo "::endgroup::"

0 commit comments

Comments
 (0)