Skip to content

Commit e9f3f93

Browse files
committed
Re-enable running tests in external tests via IR in cases where they don't pass due to Hardhat heuristics
1 parent 2b201f2 commit e9f3f93

File tree

4 files changed

+53
-12
lines changed

4 files changed

+53
-12
lines changed

test/externalTests/elementfi.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ function elementfi_test
4242
local config_file="hardhat.config.ts"
4343
local config_var=config
4444

45-
local compile_only_presets=(
46-
ir-optimize-evm+yul # Compiles but tests fail. See https://github.com/nomiclabs/hardhat/issues/2115
47-
)
45+
local compile_only_presets=()
4846
local settings_presets=(
4947
"${compile_only_presets[@]}"
5048
#ir-no-optimize # Compilation fails with "YulException: Variable var_amount_9311 is 10 slot(s) too deep inside the stack."
5149
#ir-optimize-evm-only # Compilation fails with "YulException: Variable var_amount_9311 is 10 slot(s) too deep inside the stack."
50+
ir-optimize-evm+yul
5251
legacy-no-optimize
5352
legacy-optimize-evm-only
5453
legacy-optimize-evm+yul
@@ -89,6 +88,13 @@ function elementfi_test
8988
# TODO: Remove when https://github.com/element-fi/elf-contracts/issues/243 is fixed.
9089
sed -i 's|^\s*require(_expiration - block\.timestamp < _unitSeconds);\s*$||g' contracts/ConvergentCurvePool.sol
9190

91+
# Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables
92+
# them for other presets but that's fine - we want same code run for benchmarks to be comparable.
93+
# TODO: Remove this when Hardhat adjusts heuristics for IR (https://github.com/nomiclabs/hardhat/issues/2115).
94+
sed -i 's|it(\("fails to withdraw more shares than in balance"\)|it.skip(\1|g' test/compoundAssetProxyTest.ts
95+
sed -i 's|it(\("should prevent withdrawal of Principal Tokens and Interest Tokens before the tranche expires "\)|it.skip(\1|g' test/trancheTest.ts
96+
sed -i 's|it(\("should prevent withdrawal of more Principal Tokens and Interest Tokens than the user has"\)|it.skip(\1|g' test/trancheTest.ts
97+
9298
# This test file is very flaky. There's one particular cases that fails randomly (see
9399
# https://github.com/element-fi/elf-contracts/issues/240) but some others also depends on an external
94100
# service which makes tests time out when that service is down.

test/externalTests/gnosis.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ function gnosis_safe_test
4242
local config_file="hardhat.config.ts"
4343
local config_var=userConfig
4444

45-
local compile_only_presets=(
46-
ir-optimize-evm+yul # Compiles but tests fail. See https://github.com/nomiclabs/hardhat/issues/2115
47-
)
45+
local compile_only_presets=()
4846
local settings_presets=(
4947
"${compile_only_presets[@]}"
5048
#ir-no-optimize # Compilation fails with "YulException: Variable var_call_430_mpos is 1 slot(s) too deep inside the stack."
5149
#ir-optimize-evm-only # Compilation fails with "YulException: Variable var_call_430_mpos is 1 slot(s) too deep inside the stack."
50+
ir-optimize-evm+yul
5251
legacy-no-optimize
5352
legacy-optimize-evm-only
5453
legacy-optimize-evm+yul
@@ -70,6 +69,11 @@ function gnosis_safe_test
7069
# TODO: Remove this when Hardhat implements them (https://github.com/nomiclabs/hardhat/issues/2051).
7170
sed -i "s|\(it\)\(('should revert if called directly', async () => {\)|\1.skip\2|g" test/handlers/CompatibilityFallbackHandler.spec.ts
7271

72+
# Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables
73+
# them for other presets but that's fine - we want same code run for benchmarks to be comparable.
74+
# TODO: Remove this when Hardhat adjusts heuristics for IR (https://github.com/nomiclabs/hardhat/issues/2115).
75+
sed -i "s|\(it\)\(('should not allow to call setup on singleton'\)|\1.skip\2|g" test/core/GnosisSafe.Setup.spec.ts
76+
7377
neutralize_package_lock
7478
neutralize_package_json_hooks
7579
force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH"

test/externalTests/prb-math.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ function prb_math_test
4343
local config_file="hardhat.config.ts"
4444
local config_var="config"
4545

46-
local compile_only_presets=(
47-
ir-optimize-evm+yul # Compiles but tests fail. See https://github.com/nomiclabs/hardhat/issues/2115
48-
)
46+
local compile_only_presets=()
4947
local settings_presets=(
5048
"${compile_only_presets[@]}"
5149
#ir-no-optimize # Compilation fails with "YulException: Variable var_y_1960 is 8 slot(s) too deep inside the stack."
5250
#ir-optimize-evm-only # Compilation fails with "YulException: Variable var_y_1960 is 8 slot(s) too deep inside the stack."
51+
ir-optimize-evm+yul
5352
legacy-optimize-evm-only
5453
legacy-optimize-evm+yul
5554
legacy-no-optimize
@@ -68,6 +67,26 @@ function prb_math_test
6867
# yarn.lock. Remove the config to restore Yarn 1.x.
6968
rm .yarnrc.yml
7069

70+
# Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables
71+
# them for other presets but that's fine - we want same code run for benchmarks to be comparable.
72+
# TODO: Remove this when Hardhat adjusts heuristics for IR (https://github.com/nomiclabs/hardhat/issues/2115).
73+
pushd test/contracts/prbMathUd60x18/pure/
74+
sed -i 's|context(\("when the sum overflows"\)|context.skip(\1|g' add.test.ts
75+
sed -i 's|context(\("when the sum does not overflow"\)|context.skip(\1|g' add.test.ts
76+
sed -i 's|context(\("when both operands are zero"\)|context.skip(\1|g' avg.test.ts
77+
sed -i 's|context(\("when one operand is zero and the other is not zero"\)|context.skip(\1|g' avg.test.ts
78+
sed -i 's|context(\("when the denominator is zero"\)|context.skip(\1|g' div.test.ts
79+
sed -i 's|context(\("when x is zero"\)|context.skip(\1|g' inv.test.ts
80+
popd
81+
pushd test/contracts/prbMathSd59x18/pure/
82+
sed -i 's|context(\("when the sum overflows"\)|context.skip(\1|g' add.test.ts
83+
sed -i 's|context(\("when the sum underflows"\)|context.skip(\1|g' add.test.ts
84+
sed -i 's|context(\("when the denominator is zero"\)|context.skip(\1|g' div.test.ts
85+
sed -i 's|context(\("when x is zero"\)|context.skip(\1|g' inv.test.ts
86+
sed -i 's|context(\("when the difference underflows"\)|context.skip(\1|g' sub.test.ts
87+
sed -i 's|context(\("when the difference overflows"\)|context.skip(\1|g' sub.test.ts
88+
popd
89+
7190
neutralize_package_lock
7291
neutralize_package_json_hooks
7392
force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH"

test/externalTests/zeppelin.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@ function zeppelin_test
4141
local ref="master"
4242
local config_file="hardhat.config.js"
4343

44-
local compile_only_presets=(
45-
ir-optimize-evm+yul # Compiles but tests fail. See https://github.com/nomiclabs/hardhat/issues/2115
46-
)
44+
local compile_only_presets=()
4745
local settings_presets=(
4846
"${compile_only_presets[@]}"
4947
#ir-no-optimize # Compilation fails with "YulException: Variable var_account_852 is 4 slot(s) too deep inside the stack."
5048
#ir-optimize-evm-only # Compilation fails with "YulException: Variable var_account_852 is 4 slot(s) too deep inside the stack."
49+
ir-optimize-evm+yul
5150
legacy-no-optimize
5251
legacy-optimize-evm-only
5352
legacy-optimize-evm+yul
@@ -59,6 +58,19 @@ function zeppelin_test
5958
setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH"
6059
download_project "$repo" "$ref_type" "$ref" "$DIR"
6160

61+
# Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables
62+
# them for other presets but that's fine - we want same code run for benchmarks to be comparable.
63+
# TODO: Remove this when Hardhat adjusts heuristics for IR (https://github.com/nomiclabs/hardhat/issues/2115).
64+
pushd test/utils/
65+
sed -i "s|it(\('reverts \)|it.skip(\1|g" math/SafeMath.test.js
66+
sed -i "s|it(\('reverts \)|it.skip(\1|g" math/SignedSafeMath.test.js
67+
sed -i "s|it(\('reverts \)|it.skip(\1|g" structs/EnumerableSet.behavior.js
68+
popd
69+
70+
# In some cases Hardhat does not detect revert reasons properly via IR.
71+
# TODO: Remove this when https://github.com/NomicFoundation/hardhat/issues/2453 gets fixed.
72+
sed -i "s|it(\('reverts if the current value is 0'\)|it.skip(\1|g" test/utils/Counters.test.js
73+
6274
neutralize_package_json_hooks
6375
force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH"
6476
force_hardhat_compiler_settings "$config_file" "$(first_word "$SELECTED_PRESETS")"

0 commit comments

Comments
 (0)