Use new feature to gate test vectors behind
[rust-lightning] / ci / ci-tests.sh
1 #!/bin/bash
2 set -eox pipefail
3
4 RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')
5 HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
6
7 # Tokio MSRV on versions 1.17 through 1.26 is rustc 1.49. Above 1.26 MSRV is 1.56.
8 [ "$RUSTC_MINOR_VERSION" -lt 49 ] && cargo update -p tokio --precise "1.14.0" --verbose
9 [[ "$RUSTC_MINOR_VERSION" -gt 48  &&  "$RUSTC_MINOR_VERSION" -lt 56 ]] && cargo update -p tokio --precise "1.26.0" --verbose
10 [ "$LDK_COVERAGE_BUILD" != "" ] && export RUSTFLAGS="-C link-dead-code"
11
12 export RUST_BACKTRACE=1
13
14 echo -e "\n\nBuilding and testing all workspace crates..."
15 cargo build --verbose --color always
16 cargo test --verbose --color always
17
18 echo -e "\n\nBuilding with all Log-Limiting features"
19 pushd lightning
20 grep '^max_level_' Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
21         cargo build --verbose --color always --features "$FEATURE"
22 done
23 popd
24
25 if [ "$RUSTC_MINOR_VERSION" -gt 51 ]; then # Current `object` MSRV, subject to change
26         echo -e "\n\nTest backtrace-debug builds"
27         pushd lightning
28         cargo test --verbose --color always --features backtrace
29         popd
30 fi
31
32 echo -e "\n\nTesting no-std flags in various combinations"
33 for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
34         pushd $DIR
35         cargo test --verbose --color always --no-default-features --features no-std
36         # check if there is a conflict between no-std and the default std feature
37         cargo test --verbose --color always --features no-std
38         # check if there is a conflict between no-std and the c_bindings cfg
39         RUSTFLAGS="--cfg=c_bindings" cargo test --verbose --color always --no-default-features --features=no-std
40         popd
41 done
42 # Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
43 pushd lightning
44 cargo test --verbose --color always --no-default-features --features=std,_test_vectors
45 popd
46 # This one only works for lightning-invoice
47 pushd lightning-invoice
48 # check that compile with no-std and serde works in lightning-invoice
49 cargo test --verbose --color always --no-default-features --features no-std --features serde
50 popd
51
52 echo -e "\n\nTesting no-std build on a downstream no-std crate"
53 # check no-std compatibility across dependencies
54 pushd no-std-check
55 cargo check --verbose --color always --features lightning-transaction-sync
56 popd
57
58 if [ -f "$(which arm-none-eabi-gcc)" ]; then
59         pushd no-std-check
60         cargo build --target=thumbv7m-none-eabi
61         popd
62 fi
63
64 echo -e "\n\nBuilding and testing Block Sync Clients with features"
65 pushd lightning-block-sync
66 cargo build --verbose --color always --features rest-client
67 cargo test --verbose --color always --features rest-client
68 cargo build --verbose --color always --features rpc-client
69 cargo test --verbose --color always --features rpc-client
70 cargo build --verbose --color always --features rpc-client,rest-client
71 cargo test --verbose --color always --features rpc-client,rest-client
72 cargo build --verbose --color always --features rpc-client,rest-client,tokio
73 cargo test --verbose --color always --features rpc-client,rest-client,tokio
74 popd
75
76 if [[ $RUSTC_MINOR_VERSION -gt 67 && "$HOST_PLATFORM" != *windows* ]]; then
77         echo -e "\n\nBuilding and testing Transaction Sync Clients with features"
78         pushd lightning-transaction-sync
79         cargo build --verbose --color always --features esplora-blocking
80         cargo test --verbose --color always --features esplora-blocking
81         cargo build --verbose --color always --features esplora-async
82         cargo test --verbose --color always --features esplora-async
83         cargo build --verbose --color always --features esplora-async-https
84         cargo test --verbose --color always --features esplora-async-https
85         popd
86 fi
87
88 echo -e "\n\nTest futures builds"
89 pushd lightning-background-processor
90 cargo test --verbose --color always --no-default-features --features futures
91 popd
92
93 if [ "$RUSTC_MINOR_VERSION" -gt 55 ]; then
94         echo -e "\n\nTest Custom Message Macros"
95         pushd lightning-custom-message
96         cargo test --verbose --color always
97         popd
98 fi
99
100 echo -e "\n\nTest anchors builds"
101 pushd lightning
102 RUSTFLAGS="$RUSTFLAGS --cfg=anchors" cargo test --verbose --color always -p lightning
103 echo -e "\n\nTest Taproot builds"
104 RUSTFLAGS="$RUSTFLAGS --cfg=anchors --cfg=taproot" cargo test --verbose --color always -p lightning
105 popd