Skip to content

Commit 215cad6

Browse files
committed
Manually download bitcoind/electrs for CI tests
Previously, we used the auto-download feature of the `electrsd`/`bitcoind` crates. While convenient, they unnecessarily introduced a lot of dependecies (`zip`, `zstd`, `time`, etc.) to our test environment which needed pinning for the MSRV of 1.63. Here, we introduce a new `no_download` config flag to the `lightning-transaction-sync` crate allowing us to disable this auto-download feature in CI, where we now opt to download the corresponding binaries manually. We keep the default-auto-download as a convenience feature for running tests locally though.
1 parent 7301ff0 commit 215cad6

File tree

2 files changed

+52
-13
lines changed

2 files changed

+52
-13
lines changed

ci/ci-tests.sh

+46-12
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,57 @@ if [[ "$HOST_PLATFORM" != *windows* ]]; then
4141
echo -e "\n\nBuilding and testing Transaction Sync Clients with features"
4242
pushd lightning-transaction-sync
4343

44-
# zstd-sys 2.0.9+zstd.1.5.5 requires rustc 1.64.0
45-
[ "$RUSTC_MINOR_VERSION" -lt 64 ] && cargo update -p zstd-sys --precise "2.0.8+zstd.1.5.5" --verbose
4644
# reqwest 0.11.21 had a regression that broke its 1.63.0 MSRV
4745
[ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p reqwest --precise "0.11.20" --verbose
48-
# jobserver 0.1.27 requires rustc 1.66.0
49-
[ "$RUSTC_MINOR_VERSION" -lt 66 ] && cargo update -p jobserver --precise "0.1.26" --verbose
5046
# Starting with version 1.10.0, the `regex` crate has an MSRV of rustc 1.65.0.
5147
[ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p regex --precise "1.9.6" --verbose
5248

53-
cargo test --verbose --color always --features esplora-blocking
54-
cargo check --verbose --color always --features esplora-blocking
55-
cargo test --verbose --color always --features esplora-async
56-
cargo check --verbose --color always --features esplora-async
57-
cargo test --verbose --color always --features esplora-async-https
58-
cargo check --verbose --color always --features esplora-async-https
59-
cargo test --verbose --color always --features electrum
60-
cargo check --verbose --color always --features electrum
49+
ELECTRS_DL_ENDPOINT="https://github.com/RCasatta/electrsd/releases/download/electrs_releases"
50+
ELECTRS_VERSION="esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254"
51+
BITCOIND_DL_ENDPOINT="https://bitcoincore.org/bin/"
52+
BITCOIND_VERSION="25.1"
53+
if [[ "$HOST_PLATFORM" == *linux* ]]; then
54+
ELECTRS_DL_FILE_NAME=electrs_linux_"$ELECTRS_VERSION".zip
55+
ELECTRS_EXP_HASH="865e26a96e8df77df01d96f2f569dcf9622fc87a8d99a9b8fe30861a4db9ddf1"
56+
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-linux-gnu.tar.gz
57+
BITCOIND_EXP_HASH="a978c407b497a727f0444156e397b50491ce862d1f906fef9b521415b3611c8b"
58+
elif [[ "$HOST_PLATFORM" == *darwin* ]]; then
59+
ELECTRS_DL_FILE_NAME=electrs_macos_"$ELECTRS_VERSION".zip
60+
ELECTRS_EXP_HASH="2d5ff149e8a2482d3658e9b386830dfc40c8fbd7c175ca7cbac58240a9505bcd"
61+
BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-apple-darwin.tar.gz
62+
BITCOIND_EXP_HASH="1acfde0ec3128381b83e3e5f54d1c7907871d324549129592144dd12a821eff1"
63+
else
64+
echo -e "\n\nUnsupported platform. Exiting.."
65+
return 1
66+
fi
67+
68+
DL_TMP_DIR=$(mktemp -d)
69+
trap 'rm -rf -- "$DL_TMP_DIR"' EXIT
70+
71+
pushd "$DL_TMP_DIR"
72+
ELECTRS_DL_URL="$ELECTRS_DL_ENDPOINT/$ELECTRS_DL_FILE_NAME"
73+
curl -L -o "$ELECTRS_DL_FILE_NAME" "$ELECTRS_DL_URL"
74+
echo "$ELECTRS_EXP_HASH $ELECTRS_DL_FILE_NAME"|shasum -a 256 -c
75+
unzip $ELECTRS_DL_FILE_NAME
76+
export ELECTRS_EXE="$DL_TMP_DIR/electrs"
77+
chmod +x "$ELECTRS_EXE"
78+
79+
BITCOIND_DL_URL="$BITCOIND_DL_ENDPOINT"/bitcoin-core-"$BITCOIND_VERSION"/"$BITCOIND_DL_FILE_NAME"
80+
curl -L -o "$BITCOIND_DL_FILE_NAME" "$BITCOIND_DL_URL"
81+
echo "$BITCOIND_EXP_HASH $BITCOIND_DL_FILE_NAME"|shasum -a 256 -c
82+
tar xzf $BITCOIND_DL_FILE_NAME
83+
export BITCOIND_EXE="$DL_TMP_DIR"/bitcoin-"$BITCOIND_VERSION"/bin/bitcoind
84+
chmod +x "$BITCOIND_EXE"
85+
popd
86+
87+
RUSTFLAGS="--cfg no_download" cargo test --verbose --color always --features esplora-blocking
88+
RUSTFLAGS="--cfg no_download" cargo check --verbose --color always --features esplora-blocking
89+
RUSTFLAGS="--cfg no_download" cargo test --verbose --color always --features esplora-async
90+
RUSTFLAGS="--cfg no_download" cargo check --verbose --color always --features esplora-async
91+
RUSTFLAGS="--cfg no_download" cargo test --verbose --color always --features esplora-async-https
92+
RUSTFLAGS="--cfg no_download" cargo check --verbose --color always --features esplora-async-https
93+
RUSTFLAGS="--cfg no_download" cargo test --verbose --color always --features electrum
94+
RUSTFLAGS="--cfg no_download" cargo check --verbose --color always --features electrum
6195

6296
popd
6397
fi

lightning-transaction-sync/Cargo.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,10 @@ electrum-client = { version = "0.18.0", optional = true }
3131

3232
[dev-dependencies]
3333
lightning = { version = "0.0.118", path = "../lightning", default-features = false, features = ["std", "_test_utils"] }
34-
electrsd = { version = "0.26.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
3534
tokio = { version = "1.14.0", features = ["full"] }
35+
36+
[target.'cfg(not(no_download))'.dev-dependencies]
37+
electrsd = { version = "0.26.0", default-features = false, features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
38+
39+
[target.'cfg(no_download)'.dev-dependencies]
40+
electrsd = { version = "0.26.0", default-features = false, features = ["legacy"] }

0 commit comments

Comments
 (0)