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 # Starting with version 0.5.9 (there is no .6-.8), the `home` crate has an MSRV of rustc 1.70.0.
67 [ "$RUSTC_MINOR_VERSION" -lt 70 ] && cargo update -p home --precise "0.5.5" --verbose
69 export RUST_BACKTRACE=1
71 # Build `lightning-transaction-sync` in no_download mode.
72 export RUSTFLAGS="$RUSTFLAGS --cfg no_download"
74 echo -e "\n\nBuilding and testing all workspace crates..."
75 cargo test --verbose --color always
76 cargo check --verbose --color always
78 echo -e "\n\nBuilding and testing Block Sync Clients with features"
79 pushd lightning-block-sync
80 cargo test --verbose --color always --features rest-client
81 cargo check --verbose --color always --features rest-client
82 cargo test --verbose --color always --features rpc-client
83 cargo check --verbose --color always --features rpc-client
84 cargo test --verbose --color always --features rpc-client,rest-client
85 cargo check --verbose --color always --features rpc-client,rest-client
86 cargo test --verbose --color always --features rpc-client,rest-client,tokio
87 cargo check --verbose --color always --features rpc-client,rest-client,tokio
90 if [[ "$HOST_PLATFORM" != *windows* ]]; then
91 echo -e "\n\nBuilding and testing Transaction Sync Clients with features"
92 pushd lightning-transaction-sync
94 DOWNLOAD_ELECTRS_AND_BITCOIND
96 cargo test --verbose --color always --features esplora-blocking
97 cargo check --verbose --color always --features esplora-blocking
98 cargo test --verbose --color always --features esplora-async
99 cargo check --verbose --color always --features esplora-async
100 cargo test --verbose --color always --features esplora-async-https
101 cargo check --verbose --color always --features esplora-async-https
102 cargo test --verbose --color always --features electrum
103 cargo check --verbose --color always --features electrum
107 echo -e "\n\nTest futures builds"
108 pushd lightning-background-processor
109 cargo test --verbose --color always --features futures
112 echo -e "\n\nTest Custom Message Macros"
113 pushd lightning-custom-message
114 cargo test --verbose --color always
115 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
118 echo -e "\n\nTest backtrace-debug builds"
120 cargo test --verbose --color always --features backtrace
123 echo -e "\n\nBuilding with all Log-Limiting features"
125 grep '^max_level_' Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
126 RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check --verbose --color always --features "$FEATURE"
130 echo -e "\n\nTesting no-std flags in various combinations"
131 for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
132 cargo test -p $DIR --verbose --color always --no-default-features --features no-std
133 # check if there is a conflict between no-std and the default std feature
134 cargo test -p $DIR --verbose --color always --features no-std
137 for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
138 # check if there is a conflict between no-std and the c_bindings cfg
139 RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features --features=no-std
141 RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always
143 # Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
145 cargo test --verbose --color always --no-default-features --features=std,_test_vectors
147 # This one only works for lightning-invoice
148 pushd lightning-invoice
149 # check that compile with no-std and serde works in lightning-invoice
150 cargo test --verbose --color always --no-default-features --features no-std --features serde
153 echo -e "\n\nTesting no-std build on a downstream no-std crate"
154 # check no-std compatibility across dependencies
156 cargo check --verbose --color always --features lightning-transaction-sync
157 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
160 # Test that we can build downstream code with only the "release pins".
161 pushd msrv-no-dev-deps-check
164 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
167 if [ -f "$(which arm-none-eabi-gcc)" ]; then
169 cargo build --target=thumbv7m-none-eabi
170 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
174 echo -e "\n\nTest cfg-flag builds"
175 RUSTFLAGS="--cfg=taproot" cargo test --verbose --color always -p lightning
176 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
177 RUSTFLAGS="--cfg=async_signing" cargo test --verbose --color always -p lightning
178 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
179 RUSTFLAGS="--cfg=dual_funding" cargo test --verbose --color always -p lightning
180 [ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
181 RUSTFLAGS="--cfg=splicing" cargo test --verbose --color always -p lightning