Skip to content

Commit

Permalink
Re-enable running tests in external tests via IR in cases where they …
Browse files Browse the repository at this point in the history
…don't pass due to Hardhat heuristics
  • Loading branch information
cameel committed Mar 3, 2022
1 parent b9bde34 commit e4b2977
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 12 deletions.
12 changes: 9 additions & 3 deletions test/externalTests/elementfi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ function elementfi_test
local config_file="hardhat.config.ts"
local config_var=config

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

# Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables
# them for other presets but that's fine - we want same code run for benchmarks to be comparable.
# TODO: Remove this when Hardhat adjusts heuristics for IR (https://github.com/nomiclabs/hardhat/issues/2115).
sed -i 's|it(\("fails to withdraw more shares than in balance"\)|it.skip(\1|g' test/compoundAssetProxyTest.ts
sed -i 's|it(\("should prevent withdrawal of Principal Tokens and Interest Tokens before the tranche expires "\)|it.skip(\1|g' test/trancheTest.ts
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

# Several tests fail unless we use the exact versions hard-coded in package-lock.json
#neutralize_package_lock

Expand Down
10 changes: 7 additions & 3 deletions test/externalTests/gnosis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ function gnosis_safe_test
local config_file="hardhat.config.ts"
local config_var=userConfig

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

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

neutralize_package_lock
neutralize_package_json_hooks
force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH"
Expand Down
25 changes: 22 additions & 3 deletions test/externalTests/prb-math.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ function prb_math_test
local config_file="hardhat.config.ts"
local config_var="config"

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

# Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables
# them for other presets but that's fine - we want same code run for benchmarks to be comparable.
# TODO: Remove this when Hardhat adjusts heuristics for IR (https://github.com/nomiclabs/hardhat/issues/2115).
pushd test/contracts/prbMathUd60x18/pure/
sed -i 's|context(\("when the sum overflows"\)|context.skip(\1|g' add.test.ts
sed -i 's|context(\("when the sum does not overflow"\)|context.skip(\1|g' add.test.ts
sed -i 's|context(\("when both operands are zero"\)|context.skip(\1|g' avg.test.ts
sed -i 's|context(\("when one operand is zero and the other is not zero"\)|context.skip(\1|g' avg.test.ts
sed -i 's|context(\("when the denominator is zero"\)|context.skip(\1|g' div.test.ts
sed -i 's|context(\("when x is zero"\)|context.skip(\1|g' inv.test.ts
popd
pushd test/contracts/prbMathSd59x18/pure/
sed -i 's|context(\("when the sum overflows"\)|context.skip(\1|g' add.test.ts
sed -i 's|context(\("when the sum underflows"\)|context.skip(\1|g' add.test.ts
sed -i 's|context(\("when the denominator is zero"\)|context.skip(\1|g' div.test.ts
sed -i 's|context(\("when x is zero"\)|context.skip(\1|g' inv.test.ts
sed -i 's|context(\("when the difference underflows"\)|context.skip(\1|g' sub.test.ts
sed -i 's|context(\("when the difference overflows"\)|context.skip(\1|g' sub.test.ts
popd

neutralize_package_lock
neutralize_package_json_hooks
force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH"
Expand Down
16 changes: 13 additions & 3 deletions test/externalTests/zeppelin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ function zeppelin_test
local ref="master"
local config_file="hardhat.config.js"

local compile_only_presets=(
ir-optimize-evm+yul # Compiles but tests fail. See https://github.com/nomiclabs/hardhat/issues/2115
)
local compile_only_presets=()
local settings_presets=(
"${compile_only_presets[@]}"
#ir-no-optimize # Compilation fails with "YulException: Variable var_account_852 is 4 slot(s) too deep inside the stack."
#ir-optimize-evm-only # Compilation fails with "YulException: Variable var_account_852 is 4 slot(s) too deep inside the stack."
ir-optimize-evm+yul
legacy-no-optimize
legacy-optimize-evm-only
legacy-optimize-evm+yul
Expand All @@ -59,6 +58,17 @@ function zeppelin_test
setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH"
download_project "$repo" "$ref_type" "$ref" "$DIR"

# Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables
# them for other presets but that's fine - we want same code run for benchmarks to be comparable.
# TODO: Remove this when Hardhat adjusts heuristics for IR (https://github.com/nomiclabs/hardhat/issues/2115).
pushd test/utils/math/
sed -i "s|it(\('reverts on addition overflow'\)|it.skip(\1|g" SafeMath.test.js
sed -i "s|it(\('reverts if subtraction result would be negative'\)|it.skip(\1|g" SafeMath.test.js
sed -i "s|it(\('reverts on multiplication overflow'\)|it.skip(\1|g" SafeMath.test.js
sed -i "s|it(\('reverts on division by zero'\)|it.skip(\1|g" SafeMath.test.js
sed -i "s|it(\('reverts with a 0 divisor'\)|it.skip(\1|g" SafeMath.test.js
popd

neutralize_package_json_hooks
force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH"
force_hardhat_compiler_settings "$config_file" "$(first_word "$SELECTED_PRESETS")"
Expand Down

0 comments on commit e4b2977

Please sign in to comment.