Skip to content

Commit 3715410

Browse files
authored
Merge pull request #3249 from TheBlueMatt/2024-08-feature-cleanup-1
bitcoin 0.32 upgrade followups
2 parents bad5e32 + 8049f99 commit 3715410

File tree

15 files changed

+83
-87
lines changed

15 files changed

+83
-87
lines changed

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ opt-level = 3
4141
lto = true
4242
panic = "abort"
4343

44-
[patch.crates-io.possiblyrandom]
45-
path = "possiblyrandom"
46-
4744
[workspace.lints.rust.unexpected_cfgs]
4845
level = "forbid"
4946
# When adding a new cfg attribute, ensure that it is added to this list.
@@ -58,6 +55,7 @@ check-cfg = [
5855
"cfg(debug_assertions)",
5956
"cfg(c_bindings)",
6057
"cfg(ldk_bench)",
58+
"cfg(ldk_test_vectors)",
6159
"cfg(taproot)",
6260
"cfg(async_signing)",
6361
"cfg(require_route_graph_test)",

ci/ci-tests.sh

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -32,83 +32,79 @@ cargo test --verbose --color always
3232
cargo check --verbose --color always
3333

3434
echo -e "\n\nBuilding and testing Block Sync Clients with features"
35-
pushd lightning-block-sync
36-
cargo test --verbose --color always --features rest-client
37-
cargo check --verbose --color always --features rest-client
38-
cargo test --verbose --color always --features rpc-client
39-
cargo check --verbose --color always --features rpc-client
40-
cargo test --verbose --color always --features rpc-client,rest-client
41-
cargo check --verbose --color always --features rpc-client,rest-client
42-
cargo test --verbose --color always --features rpc-client,rest-client,tokio
43-
cargo check --verbose --color always --features rpc-client,rest-client,tokio
44-
popd
35+
36+
cargo test -p lightning-block-sync --verbose --color always --features rest-client
37+
cargo check -p lightning-block-sync --verbose --color always --features rest-client
38+
cargo test -p lightning-block-sync --verbose --color always --features rpc-client
39+
cargo check -p lightning-block-sync --verbose --color always --features rpc-client
40+
cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
41+
cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client
42+
cargo test -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
43+
cargo check -p lightning-block-sync --verbose --color always --features rpc-client,rest-client,tokio
4544

4645
if [[ "$HOST_PLATFORM" != *windows* ]]; then
47-
pushd lightning-transaction-sync
4846
echo -e "\n\nChecking Transaction Sync Clients with features."
49-
cargo check --verbose --color always --features esplora-blocking
50-
cargo check --verbose --color always --features esplora-async
51-
cargo check --verbose --color always --features esplora-async-https
52-
cargo check --verbose --color always --features electrum
47+
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-blocking
48+
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async
49+
cargo check -p lightning-transaction-sync --verbose --color always --features esplora-async-https
50+
cargo check -p lightning-transaction-sync --verbose --color always --features electrum
5351

5452
if [ -z "$CI_ENV" ] && [[ -z "$BITCOIND_EXE" || -z "$ELECTRS_EXE" ]]; then
5553
echo -e "\n\nSkipping testing Transaction Sync Clients due to BITCOIND_EXE or ELECTRS_EXE being unset."
56-
cargo check --tests
54+
cargo check -p lightning-transaction-sync --tests
5755
else
5856
echo -e "\n\nTesting Transaction Sync Clients with features."
59-
cargo test --verbose --color always --features esplora-blocking
60-
cargo test --verbose --color always --features esplora-async
61-
cargo test --verbose --color always --features esplora-async-https
62-
cargo test --verbose --color always --features electrum
57+
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-blocking
58+
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async
59+
cargo test -p lightning-transaction-sync --verbose --color always --features esplora-async-https
60+
cargo test -p lightning-transaction-sync --verbose --color always --features electrum
6361
fi
64-
popd
6562
fi
6663

6764
echo -e "\n\nTest futures builds"
68-
pushd lightning-background-processor
69-
cargo test --verbose --color always --features futures
70-
popd
65+
cargo test -p lightning-background-processor --verbose --color always --features futures
66+
cargo test -p lightning-background-processor --verbose --color always --features futures --no-default-features
7167

7268
echo -e "\n\nTest Custom Message Macros"
73-
pushd lightning-custom-message
74-
cargo test --verbose --color always
69+
cargo test -p lightning-custom-message --verbose --color always
7570
[ "$CI_MINIMIZE_DISK_USAGE" != "" ] && cargo clean
76-
popd
7771

7872
echo -e "\n\nTest backtrace-debug builds"
79-
pushd lightning
80-
cargo test --verbose --color always --features backtrace
81-
popd
73+
cargo test -p lightning --verbose --color always --features backtrace
8274

8375
echo -e "\n\nBuilding with all Log-Limiting features"
84-
pushd lightning
85-
grep '^max_level_' Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
86-
RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check --verbose --color always --features "$FEATURE"
76+
grep '^max_level_' lightning/Cargo.toml | awk '{ print $1 }'| while read -r FEATURE; do
77+
RUSTFLAGS="$RUSTFLAGS -A unused_variables -A unused_macros -A unused_imports -A dead_code" cargo check -p lightning --verbose --color always --features "$FEATURE"
8778
done
88-
popd
8979

90-
echo -e "\n\nTesting no-std flags in various combinations"
91-
for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
92-
cargo test -p $DIR --verbose --color always --no-default-features --features no-std
93-
# check if there is a conflict between no-std and the default std feature
94-
cargo test -p $DIR --verbose --color always --features no-std
80+
echo -e "\n\nTesting no-std builds"
81+
for DIR in lightning-invoice lightning-rapid-gossip-sync; do
82+
cargo test -p $DIR --verbose --color always --no-default-features
9583
done
9684

97-
for DIR in lightning lightning-invoice lightning-rapid-gossip-sync; do
85+
cargo test -p lightning --verbose --color always --no-default-features --features no-std
86+
# check if there is a conflict between no-std and the default std feature
87+
cargo test -p lightning --verbose --color always --features no-std
88+
89+
echo -e "\n\nTesting c_bindings builds"
90+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always
91+
92+
for DIR in lightning-invoice lightning-rapid-gossip-sync; do
9893
# check if there is a conflict between no-std and the c_bindings cfg
99-
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features --features=no-std
94+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p $DIR --verbose --color always --no-default-features
10095
done
101-
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test --verbose --color always
10296

97+
# Note that because `$RUSTFLAGS` is not passed through to doctest builds we cannot selectively
98+
# disable tests in `c_bindings` so we skip doctests entirely here.
99+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning-background-processor --verbose --color always --features futures --no-default-features --lib --bins --tests
100+
RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning --verbose --color always --no-default-features --features=no-std
101+
102+
echo -e "\n\nTesting other crate-specific builds"
103103
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
104-
pushd lightning
105-
cargo test --verbose --color always --no-default-features --features=std,_test_vectors
106-
popd
104+
RUSTFLAGS="$RUSTFLAGS --cfg=ldk_test_vectors" cargo test -p lightning --verbose --color always --no-default-features --features=std
107105
# This one only works for lightning-invoice
108-
pushd lightning-invoice
109106
# check that compile with no-std and serde works in lightning-invoice
110-
cargo test --verbose --color always --no-default-features --features no-std --features serde
111-
popd
107+
cargo test -p lightning-invoice --verbose --color always --no-default-features --features serde
112108

113109
echo -e "\n\nTesting no-std build on a downstream no-std crate"
114110
# check no-std compatibility across dependencies

lightning-background-processor/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ rustdoc-args = ["--cfg", "docsrs"]
1515

1616
[features]
1717
futures = [ ]
18-
std = ["bitcoin/std", "lightning/std", "lightning-rapid-gossip-sync/std"]
19-
no-std = ["lightning/no-std", "lightning-rapid-gossip-sync/no-std"]
18+
std = []
2019

2120
default = ["std"]
2221

lightning-invoice/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ all-features = true
1515
rustdoc-args = ["--cfg", "docsrs"]
1616

1717
[features]
18-
default = ["std"]
19-
no-std = []
20-
std = ["bech32/std"]
18+
std = []
2119

2220
[dependencies]
2321
bech32 = { version = "0.9.1", default-features = false }

lightning-invoice/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
//!
2323
//! [`Bolt11Invoice::from_str`]: crate::Bolt11Invoice#impl-FromStr
2424
25-
#[cfg(not(any(feature = "std", feature = "no-std")))]
26-
compile_error!("at least one of the `std` or `no-std` features must be enabled");
27-
2825
extern crate bech32;
2926
extern crate lightning_types;
3027
extern crate alloc;

lightning-rapid-gossip-sync/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ Utility to process gossip routing data from Rapid Gossip Sync Server.
1111

1212
[features]
1313
default = ["std"]
14-
no-std = ["lightning/no-std"]
15-
std = ["lightning/std"]
14+
std = []
1615

1716
[dependencies]
1817
lightning = { version = "0.0.123-beta", path = "../lightning", default-features = false }

lightning-rapid-gossip-sync/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ where
143143
///
144144
/// `sync_path`: Path to the file where the gossip update data is located
145145
///
146-
#[cfg(all(feature = "std", not(feature = "no-std")))]
146+
#[cfg(feature = "std")]
147147
pub fn sync_network_graph_with_file_path(
148148
&self, sync_path: &str,
149149
) -> Result<u32, GraphSyncError> {
@@ -191,7 +191,7 @@ where
191191
}
192192
}
193193

194-
#[cfg(all(feature = "std", not(feature = "no-std")))]
194+
#[cfg(feature = "std")]
195195
#[cfg(test)]
196196
mod tests {
197197
use std::fs;

lightning/Cargo.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ max_level_trace = []
2828
# Allow signing of local transactions that may have been revoked or will be revoked, for functional testing (e.g. justice tx handling).
2929
# This is unsafe to use in production because it may result in the counterparty publishing taking our funds.
3030
unsafe_revoked_tx_signing = []
31-
# Override signing to not include randomness when generating signatures for test vectors.
32-
_test_vectors = []
3331

34-
no-std = ["hashbrown", "possiblyrandom", "lightning-invoice/no-std", "libm"]
35-
std = ["lightning-invoice/std", "bech32/std"]
32+
no-std = ["hashbrown", "possiblyrandom", "libm"]
33+
std = []
3634

3735
# Generates low-r bitcoin signatures, which saves 1 byte in 50% of the cases
3836
grind_signatures = []
@@ -47,7 +45,7 @@ bech32 = { version = "0.9.1", default-features = false }
4745
bitcoin = { version = "0.32.2", default-features = false, features = ["secp-recovery"] }
4846

4947
hashbrown = { version = "0.13", optional = true, default-features = false }
50-
possiblyrandom = { version = "0.2", optional = true, default-features = false }
48+
possiblyrandom = { version = "0.2", path = "../possiblyrandom", optional = true, default-features = false }
5149
regex = { version = "1.5.6", optional = true }
5250
backtrace = { version = "0.3", optional = true }
5351

lightning/src/crypto/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ pub fn sign_with_aux_rand<C: Signing, ES: Deref>(
7575
break sig;
7676
}
7777
};
78-
#[cfg(all(not(feature = "grind_signatures"), not(feature = "_test_vectors")))]
78+
#[cfg(all(not(feature = "grind_signatures"), not(ldk_test_vectors)))]
7979
let sig = ctx.sign_ecdsa_with_noncedata(msg, sk, &entropy_source.get_secure_random_bytes());
80-
#[cfg(all(not(feature = "grind_signatures"), feature = "_test_vectors"))]
80+
#[cfg(all(not(feature = "grind_signatures"), ldk_test_vectors))]
8181
let sig = sign(ctx, msg, sk);
8282
sig
8383
}

lightning/src/ln/bolt11_payment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,12 @@ mod tests {
188188

189189
let secp_ctx = Secp256k1::new();
190190
let node_secret = nodes[1].keys_manager.backing.get_node_secret_key();
191+
let time = std::time::SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap();
191192
let invoice = InvoiceBuilder::new(Currency::Bitcoin)
192193
.description("test".into())
193194
.payment_hash(Sha256::from_slice(&payment_hash.0).unwrap())
194195
.payment_secret(payment_secret)
195-
.current_timestamp()
196+
.duration_since_epoch(time)
196197
.min_final_cltv_expiry_delta(144)
197198
.amount_milli_satoshis(50_000)
198199
.payment_metadata(payment_metadata.clone())

0 commit comments

Comments
 (0)