Skip to content

Commit e777ec9

Browse files
authored
Merge pull request #12580 from ethereum/chainlink-ext-test
External test for Chainlink
2 parents bbfef2d + 5c76d8e commit e777ec9

File tree

3 files changed

+130
-0
lines changed

3 files changed

+130
-0
lines changed

.circleci/config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,13 @@ defaults:
606606
project: brink
607607
binary_type: native
608608
nodejs_version: '16'
609+
- job_native_test_ext_chainlink: &job_native_test_ext_chainlink
610+
<<: *workflow_ubuntu2004_static
611+
name: t_native_test_ext_chainlink
612+
project: chainlink
613+
binary_type: native
614+
nodejs_version: '16'
615+
resource_class: large # Tests run out of memory on a smaller machine
609616
- job_ems_test_ext_colony: &job_ems_test_ext_colony
610617
<<: *workflow_emscripten
611618
name: t_ems_test_ext_colony
@@ -1596,6 +1603,7 @@ workflows:
15961603
- t_ems_ext: *job_native_test_ext_prb_math
15971604
- t_ems_ext: *job_native_test_ext_elementfi
15981605
- t_ems_ext: *job_native_test_ext_brink
1606+
- t_ems_ext: *job_native_test_ext_chainlink
15991607

16001608
- c_ext_benchmarks:
16011609
<<: *workflow_trigger_on_tags
@@ -1614,6 +1622,7 @@ workflows:
16141622
- t_native_test_ext_prb_math
16151623
- t_native_test_ext_elementfi
16161624
- t_native_test_ext_brink
1625+
- t_native_test_ext_chainlink
16171626

16181627
# Windows build and tests
16191628
- b_win: *workflow_trigger_on_tags

test/externalTests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ printTask "Running external tests..."
5151
"${REPO_ROOT}/test/externalTests/prb-math.sh" "$@"
5252
"${REPO_ROOT}/test/externalTests/elementfi.sh" "$@"
5353
"${REPO_ROOT}/test/externalTests/brink.sh" "$@"
54+
"${REPO_ROOT}/test/externalTests/chainlink.sh" "$@"

test/externalTests/chainlink.sh

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/usr/bin/env bash
2+
3+
# ------------------------------------------------------------------------------
4+
# This file is part of solidity.
5+
#
6+
# solidity is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# solidity is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with solidity. If not, see <http://www.gnu.org/licenses/>
18+
#
19+
# (c) 2022 solidity contributors.
20+
#------------------------------------------------------------------------------
21+
22+
set -e
23+
24+
source scripts/common.sh
25+
source test/externalTests/common.sh
26+
27+
REPO_ROOT=$(realpath "$(dirname "$0")/../..")
28+
29+
verify_input "$@"
30+
BINARY_TYPE="$1"
31+
BINARY_PATH="$2"
32+
SELECTED_PRESETS="$3"
33+
34+
function compile_fn { yarn compile; }
35+
function test_fn { yarn test; }
36+
37+
function chainlink_test
38+
{
39+
local repo="https://github.com/solidity-external-tests/chainlink"
40+
local ref_type=branch
41+
local ref=develop_080
42+
local config_file="hardhat.config.ts"
43+
local config_var=config
44+
45+
local compile_only_presets=(
46+
legacy-no-optimize # Tests crash on a machine with 8 GB of RAM in CI "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory"
47+
)
48+
local settings_presets=(
49+
"${compile_only_presets[@]}"
50+
#ir-no-optimize # Compilation fails with "YulException: Variable var__value_775 is 1 slot(s) too deep inside the stack."
51+
#ir-optimize-evm-only # Compilation fails with "YulException: Variable var__value_10 is 1 slot(s) too deep inside the stack"
52+
ir-optimize-evm+yul
53+
legacy-optimize-evm-only # NOTE: This requires >= 4 GB RAM in CI not to crash
54+
legacy-optimize-evm+yul # NOTE: This requires >= 4 GB RAM in CI not to crash
55+
)
56+
57+
[[ $SELECTED_PRESETS != "" ]] || SELECTED_PRESETS=$(circleci_select_steps_multiarg "${settings_presets[@]}")
58+
print_presets_or_exit "$SELECTED_PRESETS"
59+
60+
setup_solc "$DIR" "$BINARY_TYPE" "$BINARY_PATH"
61+
download_project "$repo" "$ref_type" "$ref" "$DIR"
62+
63+
cd "contracts/"
64+
65+
# Disable tests that won't pass on the ir presets due to Hardhat heuristics. Note that this also disables
66+
# them for other presets but that's fine - we want same code run for benchmarks to be comparable.
67+
# TODO: Remove this when Hardhat adjusts heuristics for IR (https://github.com/nomiclabs/hardhat/issues/2115).
68+
sed -i "s|\(it\)\(('reverts'\)|\1.skip\2|g" test/v0.6/BasicConsumer.test.ts
69+
sed -i "s|\(it\)\(('has a reasonable gas cost \[ @skip-coverage \]'\)|\1.skip\2|g" test/v0.6/BasicConsumer.test.ts
70+
sed -i "s|\(describe\)\(('#add[^']*'\)|\1.skip\2|g" test/v0.6/Chainlink.test.ts
71+
sed -i "s|\(it\)\(('throws'\)|\1.skip\2|g" test/v0.6/SignedSafeMath.test.ts
72+
sed -i "s|\(it\)\(('reverts when not enough LINK in the contract'\)|\1.skip\2|g" test/v0.*/VRFD20.test.ts
73+
sed -i "s|\(it\)\(('errors while parsing invalid cron strings'\)|\1.skip\2|g" test/v0.8/Cron.test.ts
74+
sed -i "s|\(it\)\(('reverts if the amount passed in data mismatches actual amount sent'\)|\1.skip\2|g" test/v0.8/KeeperRegistrar.test.ts
75+
sed -i "s|\(it\)\(('reverts if the sender passed in data mismatches actual sender'\)|\1.skip\2|g" test/v0.8/KeeperRegistrar.test.ts
76+
sed -i "s|\(it\)\(('reverts if the admin address is 0x0000...'\)|\1.skip\2|g" test/v0.8/KeeperRegistrar.test.ts
77+
sed -i "s|\(it\)\(('reverts if not called with more or less than 32 bytes'\)|\1.skip\2|g" test/v0.8/KeeperRegistry.test.ts
78+
sed -i "s|\(context\)\(('when permissions are not set'\)|\1.skip\2|g" test/v0.8/KeeperRegistry.test.ts
79+
80+
# In some cases Hardhat does not detect revert reasons properly via IR.
81+
# TODO: Remove this when https://github.com/NomicFoundation/hardhat/issues/2453 gets fixed.
82+
sed -i "s|\(it\)\(('does not allow the specified address to start new rounds'\)|\1.skip\2|g" test/v0.6/FluxAggregator.test.ts
83+
sed -i "s|\(describe\)\(('when called by a stranger'\)|\1.skip\2|g" test/v0.6/FluxAggregator.test.ts
84+
sed -i "s|\(describe\)\(('if the access control is turned on'\)|\1.skip\2|g" test/v0.*/Flags.test.ts
85+
sed -i "s|\(it\)\(('respects the access controls of #getFlag'\)|\1.skip\2|g" test/v0.*/Flags.test.ts
86+
sed -i "s|\(describe\)\(('setting 0 authorized senders'\)|\1.skip\2|g" test/v0.7/AuthorizedForwarder.test.ts
87+
sed -i "s|\(it\)\(('cannot add an authorized node'\)|\1.skip\2|g" test/v0.7/AuthorizedForwarder.test.ts
88+
sed -i "s|\(it\)\(('should disallow reads on AggregatorV2V3Interface functions when consuming contract is not whitelisted'\)|\1.skip\2|g" test/v0.8/dev/ArbitrumSequencerUptimeFeed.test.ts
89+
sed -i "s|\(it\)\(('should not be callable by non-owners'\)|\1.skip\2|g" test/v0.8/dev/CrossDomainOwnable.test.ts
90+
sed -i "s|\(it\)\(('should not be callable by non pending-owners'\)|\1.skip\2|g" test/v0.8/dev/CrossDomainOwnable.test.ts
91+
sed -i "s|\(it\)\(('cannot add a consumer to a nonexistent subscription'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts
92+
sed -i "s|\(it\)\(('cannot remove a consumer from a nonexistent subscription'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts
93+
sed -i "s|\(it\)\(('cannot remove a consumer after it is already removed'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts
94+
sed -i "s|\(it\)\(('fails to fulfill without being a valid consumer'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts
95+
96+
# Disable tests with hard-coded gas expectations.
97+
sed -i "s|\(it\)\(('not use too much gas \[ @skip-coverage \]'\)|\1.skip\2|g" test/v0.6/FluxAggregator.test.ts
98+
sed -i "s|\(it\)\(('has a large enough gas overhead to cover upkeeps that use all their gas \[ @skip-coverage \]'\)|\1.skip\2|g" test/v0.*/KeeperRegistry*.test.ts
99+
sed -i "s|\(it\)\(('only pays .\+'\)|\1.skip\2|g" test/v0.*/KeeperRegistry*.test.ts
100+
sed -i "s|\(it\)\(('uses a specific amount of gas \[ @skip-coverage \]'\)|\1.skip\2|g" test/v0.8/ValidatorProxy.test.ts
101+
sed -i "s|\(describe\)\(('Gas costs'\)|\1.skip\2|g" test/v0.8/dev/ArbitrumSequencerUptimeFeed.test.ts
102+
103+
neutralize_package_lock
104+
neutralize_package_json_hooks
105+
name_hardhat_default_export "$config_file" "$config_var"
106+
force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH"
107+
force_hardhat_compiler_settings "$config_file" "$(first_word "$SELECTED_PRESETS")" "$config_var"
108+
force_hardhat_unlimited_contract_size "$config_file" "$config_var"
109+
yarn install
110+
yarn add hardhat-gas-reporter
111+
112+
replace_version_pragmas
113+
114+
for preset in $SELECTED_PRESETS; do
115+
hardhat_run_test "$config_file" "$preset" "${compile_only_presets[*]}" compile_fn test_fn "$config_var"
116+
store_benchmark_report hardhat chainlink "$repo" "$preset"
117+
done
118+
}
119+
120+
external_test Chainlink chainlink_test

0 commit comments

Comments
 (0)