4 RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')
5 HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
7 # Some crates require pinning to meet our MSRV even for our downstream users,
9 # Further crates which appear only as dev-dependencies are pinned further down.
10 function PIN_RELEASE_DEPS {
11 return 0 # Don't fail the script if our rustc is higher than the last check
14 # The tests of `lightning-transaction-sync` require `electrs` and `bitcoind`
15 # binaries. Here, we download the binaries, validate them, and export their
16 # location via `ELECTRS_EXE`/`BITCOIND_EXE` which will be used by the
17 # `electrsd`/`bitcoind` crates in our tests.
18 function DOWNLOAD_ELECTRS_AND_BITCOIND {
19 ELECTRS_DL_ENDPOINT="https://github.com/RCasatta/electrsd/releases/download/electrs_releases"
20 ELECTRS_VERSION="esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254"
21 BITCOIND_DL_ENDPOINT="https://bitcoincore.org/bin/"
22 BITCOIND_VERSION="25.1"
23 if [[ "$HOST_PLATFORM" == *linux* ]]; then
24 ELECTRS_DL_FILE_NAME=electrs_linux_"$ELECTRS_VERSION".zip
25 ELECTRS_DL_HASH="865e26a96e8df77df01d96f2f569dcf9622fc87a8d99a9b8fe30861a4db9ddf1"
26 BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-linux-gnu.tar.gz
27 BITCOIND_DL_HASH="a978c407b497a727f0444156e397b50491ce862d1f906fef9b521415b3611c8b"
28 elif [[ "$HOST_PLATFORM" == *darwin* ]]; then
29 ELECTRS_DL_FILE_NAME=electrs_macos_"$ELECTRS_VERSION".zip
30 ELECTRS_DL_HASH="2d5ff149e8a2482d3658e9b386830dfc40c8fbd7c175ca7cbac58240a9505bcd"
31 BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-apple-darwin.tar.gz
32 BITCOIND_DL_HASH="1acfde0ec3128381b83e3e5f54d1c7907871d324549129592144dd12a821eff1"
34 echo -e "\n\nUnsupported platform. Exiting.."
38 DL_TMP_DIR=$(mktemp -d)
39 trap 'rm -rf -- "$DL_TMP_DIR"' EXIT
42 ELECTRS_DL_URL="$ELECTRS_DL_ENDPOINT"/"$ELECTRS_DL_FILE_NAME"
43 curl -L -o "$ELECTRS_DL_FILE_NAME" "$ELECTRS_DL_URL"
44 echo "$ELECTRS_DL_HASH $ELECTRS_DL_FILE_NAME"|shasum -a 256 -c
45 unzip "$ELECTRS_DL_FILE_NAME"
46 export ELECTRS_EXE="$DL_TMP_DIR"/electrs
47 chmod +x "$ELECTRS_EXE"
49 BITCOIND_DL_URL="$BITCOIND_DL_ENDPOINT"/bitcoin-core-"$BITCOIND_VERSION"/"$BITCOIND_DL_FILE_NAME"
50 curl -L -o "$BITCOIND_DL_FILE_NAME" "$BITCOIND_DL_URL"
51 echo "$BITCOIND_DL_HASH $BITCOIND_DL_FILE_NAME"|shasum -a 256 -c
52 tar xzf "$BITCOIND_DL_FILE_NAME"
53 export BITCOIND_EXE="$DL_TMP_DIR"/bitcoin-"$BITCOIND_VERSION"/bin/bitcoind
54 chmod +x "$BITCOIND_EXE"
58 PIN_RELEASE_DEPS # pin the release dependencies in our main workspace
60 # Starting with version 1.10.0, the `regex` crate has an MSRV of rustc 1.65.0.
61 [ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p regex --precise "1.9.6" --verbose
63 # The addr2line v0.21 crate (a dependency of `backtrace` starting with 0.3.69) relies on rustc 1.65
64 [ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p backtrace --precise "0.3.68" --verbose
66 export RUST_BACKTRACE=1
68 echo -e "\n\nBuilding and testing all workspace crates..."
69 cargo test --verbose --color always
70 cargo check --verbose --color always
72 echo -e "\n\nBuilding and testing Block Sync Clients with features"
73 pushd lightning-block-sync
74 cargo test --verbose --color always --features rest-client
75 cargo check --verbose --color always --features rest-client
76 cargo test --verbose --color always --features rpc-client
77 cargo check --verbose --color always --features rpc-client
78 cargo test --verbose --color always --features rpc-client,rest-client
79 cargo check --verbose --color always --features rpc-client,rest-client
80 cargo test --verbose --color always --features rpc-client,rest-client,tokio
81 cargo check --verbose --color always --features rpc-client,rest-client,tokio
84 if [[ "$HOST_PLATFORM" != *windows* ]]; then
85 echo -e "\n\nBuilding and testing Transaction Sync Clients with features"
86 pushd lightning-transaction-sync
88 # reqwest 0.11.21 had a regression that broke its 1.63.0 MSRV
89 [ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p reqwest --precise "0.11.20" --verbose
90 # Starting with version 1.10.0, the `regex` crate has an MSRV of rustc 1.65.0.
91 [ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p regex --precise "1.9.6" --verbose
92 # Starting with version 0.5.9 (there is no .6-.8), the `home` crate has an MSRV of rustc 1.70.0.
93 [ "$RUSTC_MINOR_VERSION" -lt 70 ] && cargo update -p home --precise "0.5.5" --verbose
95 DOWNLOAD_ELECTRS_AND_BITCOIND
97 RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo test --verbose --color always --features esplora-blocking
98 RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo check --verbose --color always --features esplora-blocking
99 RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo test --verbose --color always --features esplora-async
100 RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo check --verbose --color always --features esplora-async
101 RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo test --verbose --color always --features esplora-async-https
102 RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo check --verbose --color always --features esplora-async-https
103 RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo test --verbose --color always --features electrum
104 RUSTFLAGS="$RUSTFLAGS --cfg no_download" cargo check --verbose --color always --features electrum
109 echo -e "\n\nTest futures builds"
110 pushd lightning-background-processor
111 cargo test --verbose --color always --features futures
114 echo -e "\n\nTest Custom Message Macros"
115 pushd lightning-custom-message
116 cargo test --verbose --color always
117 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
120 echo -e "\n\nTest backtrace-debug builds"
122 cargo test --verbose --color always --features backtrace
125 echo -e "\n\nBuilding with all Log-Limiting features"
127 grep '^max_level_' Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
128 RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check --verbose --color always --features "$FEATURE"
132 echo -e "\n\nTesting no-std flags in various combinations"
133 for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
134 cargo test -p $DIR --verbose --color always --no-default-features --features no-std
135 # check if there is a conflict between no-std and the default std feature
136 cargo test -p $DIR --verbose --color always --features no-std
139 for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
140 # check if there is a conflict between no-std and the c_bindings cfg
141 RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features --features=no-std
143 RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always
145 # Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
147 cargo test --verbose --color always --no-default-features --features=std,_test_vectors
149 # This one only works for lightning-invoice
150 pushd lightning-invoice
151 # check that compile with no-std and serde works in lightning-invoice
152 cargo test --verbose --color always --no-default-features --features no-std --features serde
155 echo -e "\n\nTesting no-std build on a downstream no-std crate"
156 # check no-std compatibility across dependencies
158 cargo check --verbose --color always --features lightning-transaction-sync
159 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
162 # Test that we can build downstream code with only the "release pins".
163 pushd msrv-no-dev-deps-check
166 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
169 if [ -f "$(which arm-none-eabi-gcc)" ]; then
171 cargo build --target=thumbv7m-none-eabi
172 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
176 echo -e "\n\nTest cfg-flag builds"
177 RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
178 RUSTFLAGS="--cfg=async_signing" cargo test --verbose --color always -p lightning