Skip to content

Commit 963f8d9

Browse files
authored
Merge pull request #1301 from TheBlueMatt/2022-02-router-no-test
Work around rustc bug on nightly and make benchmarks not run test code
2 parents 482d718 + c8e3078 commit 963f8d9

File tree

10 files changed

+18
-18
lines changed

10 files changed

+18
-18
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ jobs:
231231
cd ..
232232
- name: Run benchmarks on Rust ${{ matrix.toolchain }}
233233
run: |
234-
cargo bench --features unstable
234+
cargo bench --features _bench_unstable
235235
236236
check_commits:
237237
runs-on: ubuntu-latest

lightning-persister/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Utilities to manage Rust-Lightning channel data persistence and retrieval.
99
"""
1010

1111
[features]
12-
unstable = ["lightning/unstable"]
12+
_bench_unstable = ["lightning/_bench_unstable"]
1313

1414
[dependencies]
1515
bitcoin = "0.27"

lightning-persister/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#![deny(broken_intra_doc_links)]
44
#![deny(missing_docs)]
55

6-
#![cfg_attr(all(test, feature = "unstable"), feature(test))]
7-
#[cfg(all(test, feature = "unstable"))] extern crate test;
6+
#![cfg_attr(all(test, feature = "_bench_unstable"), feature(test))]
7+
#[cfg(all(test, feature = "_bench_unstable"))] extern crate test;
88

99
mod util;
1010

@@ -362,7 +362,7 @@ mod tests {
362362
}
363363
}
364364

365-
#[cfg(all(test, feature = "unstable"))]
365+
#[cfg(all(test, feature = "_bench_unstable"))]
366366
pub mod bench {
367367
use test::Bencher;
368368

lightning/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ max_level_trace = []
2424
# Allow signing of local transactions that may have been revoked or will be revoked, for functional testing (e.g. justice tx handling).
2525
# This is unsafe to use in production because it may result in the counterparty publishing taking our funds.
2626
unsafe_revoked_tx_signing = []
27-
unstable = []
27+
_bench_unstable = []
2828

2929
no-std = ["hashbrown", "bitcoin/no-std", "core2/alloc"]
3030
std = ["bitcoin/std"]

lightning/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
3232

33-
#![cfg_attr(all(any(test, feature = "_test_utils"), feature = "unstable"), feature(test))]
34-
#[cfg(all(any(test, feature = "_test_utils"), feature = "unstable"))] extern crate test;
33+
#![cfg_attr(all(any(test, feature = "_test_utils"), feature = "_bench_unstable"), feature(test))]
34+
#[cfg(all(any(test, feature = "_test_utils"), feature = "_bench_unstable"))] extern crate test;
3535

3636
#[cfg(not(any(feature = "std", feature = "no-std")))]
3737
compile_error!("at least one of the `std` or `no-std` features must be enabled");

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7173,7 +7173,7 @@ mod tests {
71737173
}
71747174
}
71757175

7176-
#[cfg(all(any(test, feature = "_test_utils"), feature = "unstable"))]
7176+
#[cfg(all(any(test, feature = "_test_utils"), feature = "_bench_unstable"))]
71777177
pub mod bench {
71787178
use chain::Listen;
71797179
use chain::chainmonitor::{ChainMonitor, Persist};

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ macro_rules! expect_pending_htlcs_forwardable_from_events {
11371137
}}
11381138
}
11391139

1140-
#[cfg(any(test, feature = "unstable"))]
1140+
#[cfg(any(test, feature = "_bench_unstable"))]
11411141
macro_rules! expect_payment_received {
11421142
($node: expr, $expected_payment_hash: expr, $expected_payment_secret: expr, $expected_recv_value: expr) => {
11431143
let events = $node.node.get_and_clear_pending_events();

lightning/src/ln/msgs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ impl fmt::Display for DecodeError {
985985
DecodeError::InvalidValue => f.write_str("Nonsense bytes didn't map to the type they were interpreted as"),
986986
DecodeError::ShortRead => f.write_str("Packet extended beyond the provided bytes"),
987987
DecodeError::BadLengthDescriptor => f.write_str("A length descriptor in the packet didn't describe the later data correctly"),
988-
DecodeError::Io(ref e) => e.fmt(f),
988+
DecodeError::Io(ref e) => fmt::Debug::fmt(e, f),
989989
DecodeError::UnsupportedCompression => f.write_str("We don't support receiving messages with zlib-compressed fields"),
990990
}
991991
}

lightning/src/routing/network_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2687,7 +2687,7 @@ mod tests {
26872687
}
26882688
}
26892689

2690-
#[cfg(all(test, feature = "unstable"))]
2690+
#[cfg(all(test, feature = "_bench_unstable"))]
26912691
mod benches {
26922692
use super::*;
26932693

lightning/src/routing/router.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ struct PathBuildingHop<'a> {
455455
/// decrease as well. Thus, we have to explicitly track which nodes have been processed and
456456
/// avoid processing them again.
457457
was_processed: bool,
458-
#[cfg(any(test, feature = "fuzztarget"))]
458+
#[cfg(all(not(feature = "_bench_unstable"), any(test, feature = "fuzztarget")))]
459459
// In tests, we apply further sanity checks on cases where we skip nodes we already processed
460460
// to ensure it is specifically in cases where the fee has gone down because of a decrease in
461461
// value_contribution_msat, which requires tracking it here. See comments below where it is
@@ -896,14 +896,14 @@ where L::Target: Logger {
896896
path_htlc_minimum_msat,
897897
path_penalty_msat: u64::max_value(),
898898
was_processed: false,
899-
#[cfg(any(test, feature = "fuzztarget"))]
899+
#[cfg(all(not(feature = "_bench_unstable"), any(test, feature = "fuzztarget")))]
900900
value_contribution_msat,
901901
}
902902
});
903903

904904
#[allow(unused_mut)] // We only use the mut in cfg(test)
905905
let mut should_process = !old_entry.was_processed;
906-
#[cfg(any(test, feature = "fuzztarget"))]
906+
#[cfg(all(not(feature = "_bench_unstable"), any(test, feature = "fuzztarget")))]
907907
{
908908
// In test/fuzzing builds, we do extra checks to make sure the skipping
909909
// of already-seen nodes only happens in cases we expect (see below).
@@ -992,13 +992,13 @@ where L::Target: Logger {
992992
old_entry.fee_msat = 0; // This value will be later filled with hop_use_fee_msat of the following channel
993993
old_entry.path_htlc_minimum_msat = path_htlc_minimum_msat;
994994
old_entry.path_penalty_msat = path_penalty_msat;
995-
#[cfg(any(test, feature = "fuzztarget"))]
995+
#[cfg(all(not(feature = "_bench_unstable"), any(test, feature = "fuzztarget")))]
996996
{
997997
old_entry.value_contribution_msat = value_contribution_msat;
998998
}
999999
did_add_update_path_to_src_node = true;
10001000
} else if old_entry.was_processed && new_cost < old_cost {
1001-
#[cfg(any(test, feature = "fuzztarget"))]
1001+
#[cfg(all(not(feature = "_bench_unstable"), any(test, feature = "fuzztarget")))]
10021002
{
10031003
// If we're skipping processing a node which was previously
10041004
// processed even though we found another path to it with a
@@ -4976,7 +4976,7 @@ pub(crate) mod test_utils {
49764976
}
49774977
}
49784978

4979-
#[cfg(all(test, feature = "unstable", not(feature = "no-std")))]
4979+
#[cfg(all(test, feature = "_bench_unstable", not(feature = "no-std")))]
49804980
mod benches {
49814981
use super::*;
49824982
use bitcoin::hashes::Hash;

0 commit comments

Comments
 (0)