Skip to content

Commit 2e4480f

Browse files
committed
Drop the _test_vectors feature in favor of a cfg flag
This exists just for tests, so there's no reason for it to be publicly visible.
1 parent d48caa4 commit 2e4480f

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

ci/ci-tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ RUSTFLAGS="$RUSTFLAGS --cfg=c_bindings" cargo test -p lightning --verbose --colo
9696

9797
echo -e "\n\nTesting other crate-specific builds"
9898
# Note that outbound_commitment_test only runs in this mode because of hardcoded signature values
99-
cargo test -p lightning --verbose --color always --no-default-features --features=std,_test_vectors
99+
RUSTFLAGS="$RUSTFLAGS --cfg=ldk_test_vectors" cargo test -p lightning --verbose --color always --no-default-features --features=std
100100
# This one only works for lightning-invoice
101101
# check that compile with no-std and serde works in lightning-invoice
102102
cargo test -p lightning-invoice --verbose --color always --no-default-features --features serde

lightning/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ 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

3432
no-std = ["hashbrown", "possiblyrandom", "libm"]
3533
std = ["lightning-invoice/std", "bech32/std"]

lightning/src/crypto/utils.rs

+2-2
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/channel.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -9659,8 +9659,9 @@ mod tests {
96599659
}
96609660
}
96619661

9662-
#[cfg(all(feature = "_test_vectors", not(feature = "grind_signatures")))]
9662+
#[cfg(ldk_test_vectors)]
96639663
fn public_from_secret_hex(secp_ctx: &Secp256k1<bitcoin::secp256k1::All>, hex: &str) -> PublicKey {
9664+
assert!(cfg!(not(feature = "grind_signatures")));
96649665
PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&<Vec<u8>>::from_hex(hex).unwrap()[..]).unwrap())
96659666
}
96669667

@@ -10237,9 +10238,11 @@ mod tests {
1023710238
assert_eq!(decoded_chan.context.holding_cell_htlc_updates, holding_cell_htlc_updates);
1023810239
}
1023910240

10240-
#[cfg(all(feature = "_test_vectors", not(feature = "grind_signatures")))]
10241+
#[cfg(ldk_test_vectors)]
1024110242
#[test]
1024210243
fn outbound_commitment_test() {
10244+
assert!(cfg!(not(feature = "grind_signatures")));
10245+
1024310246
use bitcoin::sighash;
1024410247
use bitcoin::consensus::encode::serialize;
1024510248
use bitcoin::sighash::EcdsaSighashType;

lightning/src/ln/channelmanager.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,9 @@ impl core::hash::Hash for HTLCSource {
515515
}
516516
}
517517
impl HTLCSource {
518-
#[cfg(all(feature = "_test_vectors", not(feature = "grind_signatures")))]
519-
#[cfg(test)]
518+
#[cfg(all(ldk_test_vectors, test))]
520519
pub fn dummy() -> Self {
520+
assert!(cfg!(not(feature = "grind_signatures")));
521521
HTLCSource::OutboundRoute {
522522
path: Path { hops: Vec::new(), blinded_tail: None },
523523
session_priv: SecretKey::from_slice(&[1; 32]).unwrap(),

lightning/src/ln/monitor_tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2990,7 +2990,7 @@ fn test_anchors_monitor_fixes_counterparty_payment_script_on_reload() {
29902990
do_test_anchors_monitor_fixes_counterparty_payment_script_on_reload(true);
29912991
}
29922992

2993-
#[cfg(not(feature = "_test_vectors"))]
2993+
#[cfg(not(ldk_test_vectors))]
29942994
fn do_test_monitor_claims_with_random_signatures(anchors: bool, confirm_counterparty_commitment: bool) {
29952995
// Tests that our monitor claims will always use fresh random signatures (ensuring a unique
29962996
// wtxid) to prevent certain classes of transaction replacement at the bitcoin P2P layer.
@@ -3089,7 +3089,7 @@ fn do_test_monitor_claims_with_random_signatures(anchors: bool, confirm_counterp
30893089
}
30903090
}
30913091

3092-
#[cfg(not(feature = "_test_vectors"))]
3092+
#[cfg(not(ldk_test_vectors))]
30933093
#[test]
30943094
fn test_monitor_claims_with_random_signatures() {
30953095
do_test_monitor_claims_with_random_signatures(false, false);

0 commit comments

Comments
 (0)