Skip to content

Commit 4efd374

Browse files
committed
expose rest of functional tests
1 parent 4d7a64c commit 4efd374

9 files changed

+169
-184
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ where C::Target: chain::Filter,
511511
}
512512

513513

514-
#[cfg(test)]
514+
#[cfg(any(test, feature = "_test_utils"))]
515515
pub fn remove_monitor(&self, funding_txo: &OutPoint) -> ChannelMonitor<ChannelSigner> {
516516
self.monitors.write().unwrap().remove(funding_txo).unwrap().monitor
517517
}

lightning/src/chain/channelmonitor.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -775,10 +775,7 @@ impl Readable for IrrevocablyResolvedHTLC {
775775
/// returned block hash and the the current chain and then reconnecting blocks to get to the
776776
/// best chain) upon deserializing the object!
777777
pub struct ChannelMonitor<Signer: WriteableEcdsaChannelSigner> {
778-
#[cfg(test)]
779778
pub(crate) inner: Mutex<ChannelMonitorImpl<Signer>>,
780-
#[cfg(not(test))]
781-
pub(super) inner: Mutex<ChannelMonitorImpl<Signer>>,
782779
}
783780

784781
impl<Signer: WriteableEcdsaChannelSigner> Clone for ChannelMonitor<Signer> where Signer: Clone {
@@ -877,9 +874,9 @@ pub(crate) struct ChannelMonitorImpl<Signer: WriteableEcdsaChannelSigner> {
877874
// Obviously Correct (tm) if we just keep track of them explicitly.
878875
outputs_to_watch: HashMap<Txid, Vec<(u32, ScriptBuf)>>,
879876

880-
#[cfg(test)]
877+
#[cfg(any(test, feature = "_test_utils"))]
881878
pub onchain_tx_handler: OnchainTxHandler<Signer>,
882-
#[cfg(not(test))]
879+
#[cfg(not(any(test, feature = "_test_utils")))]
883880
onchain_tx_handler: OnchainTxHandler<Signer>,
884881

885882
// This is set when the Channel[Manager] generated a ChannelMonitorUpdate which indicated the
@@ -2498,7 +2495,7 @@ macro_rules! fail_unbroadcast_htlcs {
24982495
// witness length match (ie is 136 bytes long). We generate one here which we also use in some
24992496
// in-line tests later.
25002497

2501-
#[cfg(test)]
2498+
#[cfg(any(test, feature = "_test_utils"))]
25022499
pub fn deliberately_bogus_accepted_htlc_witness_program() -> Vec<u8> {
25032500
use bitcoin::blockdata::opcodes;
25042501
let mut ret = [opcodes::all::OP_NOP.to_u8(); 136];
@@ -2510,7 +2507,7 @@ pub fn deliberately_bogus_accepted_htlc_witness_program() -> Vec<u8> {
25102507
Vec::from(&ret[..])
25112508
}
25122509

2513-
#[cfg(test)]
2510+
#[cfg(any(test, feature = "_test_utils"))]
25142511
pub fn deliberately_bogus_accepted_htlc_witness() -> Vec<Vec<u8>> {
25152512
vec![Vec::new(), Vec::new(), Vec::new(), Vec::new(), deliberately_bogus_accepted_htlc_witness_program().into()].into()
25162513
}

lightning/src/chain/onchaintx.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,7 @@ pub struct OnchainTxHandler<ChannelSigner: WriteableEcdsaChannelSigner> {
246246
// Key is identifier of the pending claim request, i.e the txid of the initial claiming transaction generated by
247247
// us and is immutable until all outpoint of the claimable set are post-anti-reorg-delay solved.
248248
// Entry is cache of elements need to generate a bumped claiming transaction (see ClaimTxBumpMaterial)
249-
#[cfg(test)] // Used in functional_test to verify sanitization
250249
pub(crate) pending_claim_requests: HashMap<ClaimId, PackageTemplate>,
251-
#[cfg(not(test))]
252-
pending_claim_requests: HashMap<ClaimId, PackageTemplate>,
253250

254251
// Used to track external events that need to be forwarded to the `ChainMonitor`. This `Vec`
255252
// essentially acts as an insertion-ordered `HashMap` – there should only ever be one occurrence
@@ -269,10 +266,7 @@ pub struct OnchainTxHandler<ChannelSigner: WriteableEcdsaChannelSigner> {
269266
// block height, and are immutable until the outpoint has enough confirmations to meet our
270267
// [`ANTI_REORG_DELAY`]. The initial confirmation block height is used to remove the entry if
271268
// the block gets disconnected.
272-
#[cfg(test)] // Used in functional_test to verify sanitization
273-
pub claimable_outpoints: HashMap<BitcoinOutPoint, (ClaimId, u32)>,
274-
#[cfg(not(test))]
275-
claimable_outpoints: HashMap<BitcoinOutPoint, (ClaimId, u32)>,
269+
pub(crate) claimable_outpoints: HashMap<BitcoinOutPoint, (ClaimId, u32)>,
276270

277271
locktimed_packages: BTreeMap<u32, Vec<PackageTemplate>>,
278272

lightning/src/ln/channel.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use crate::sign::type_resolver::ChannelSignerType;
5757

5858
use super::channel_keys::{DelayedPaymentBasepoint, HtlcBasepoint, RevocationBasepoint};
5959

60-
#[cfg(test)]
60+
#[cfg(any(test, feature = "_test_utils"))]
6161
pub struct ChannelValueStat {
6262
pub value_to_self_msat: u64,
6363
pub channel_value_msat: u64,
@@ -6171,12 +6171,12 @@ impl<SP: Deref> Channel<SP> where
61716171
self.context.cur_counterparty_commitment_transaction_number + 2
61726172
}
61736173

6174-
#[cfg(test)]
6174+
#[cfg(any(test, feature = "_test_utils"))]
61756175
pub fn get_signer(&self) -> &ChannelSignerType<SP> {
61766176
&self.context.holder_signer
61776177
}
61786178

6179-
#[cfg(test)]
6179+
#[cfg(any(test, feature = "_test_utils"))]
61806180
pub fn get_value_stat(&self) -> ChannelValueStat {
61816181
ChannelValueStat {
61826182
value_to_self_msat: self.context.value_to_self_msat,

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,10 +1889,7 @@ where
18891889
router: R,
18901890

18911891
/// See `ChannelManager` struct-level documentation for lock order requirements.
1892-
#[cfg(test)]
18931892
pub(super) best_block: RwLock<BestBlock>,
1894-
#[cfg(not(test))]
1895-
best_block: RwLock<BestBlock>,
18961893
secp_ctx: Secp256k1<secp256k1::All>,
18971894

18981895
/// Storage for PaymentSecrets and any requirements on future inbound payments before we will
@@ -1981,9 +1978,6 @@ where
19811978
/// required to access the channel with the `counterparty_node_id`.
19821979
///
19831980
/// See `ChannelManager` struct-level documentation for lock order requirements.
1984-
#[cfg(not(test))]
1985-
outpoint_to_peer: Mutex<HashMap<OutPoint, PublicKey>>,
1986-
#[cfg(test)]
19871981
pub(crate) outpoint_to_peer: Mutex<HashMap<OutPoint, PublicKey>>,
19881982

19891983
/// SCIDs (and outbound SCID aliases) -> `counterparty_node_id`s and `channel_id`s.
@@ -4567,7 +4561,7 @@ where
45674561
Ok(())
45684562
}
45694563

4570-
#[cfg(test)]
4564+
#[cfg(any(test, feature = "_test_utils"))]
45714565
pub(crate) fn funding_transaction_generated_unchecked(&self, temporary_channel_id: &ChannelId, counterparty_node_id: &PublicKey, funding_transaction: Transaction, output_index: u16) -> Result<(), APIError> {
45724566
self.funding_transaction_generated_intern(temporary_channel_id, counterparty_node_id, funding_transaction, false, |_, tx| {
45734567
Ok(OutPoint { txid: tx.txid(), index: output_index })

lightning/src/ln/features.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ impl<T: sealed::ShutdownAnySegwit> Features<T> {
927927
}
928928

929929
impl<T: sealed::Wumbo> Features<T> {
930-
#[cfg(test)]
930+
#[cfg(any(test, feature = "_test_utils"))]
931931
pub(crate) fn clear_wumbo(mut self) -> Self {
932932
<T as sealed::Wumbo>::clear_bits(&mut self.flags);
933933
self

lightning/src/ln/functional_test_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ macro_rules! get_channel_ref {
937937
}
938938
}
939939

940-
#[cfg(test)]
940+
#[cfg(any(test, feature = "_test_utils"))]
941941
macro_rules! get_feerate {
942942
($node: expr, $counterparty_node: expr, $channel_id: expr) => {
943943
{
@@ -949,7 +949,7 @@ macro_rules! get_feerate {
949949
}
950950
}
951951

952-
#[cfg(test)]
952+
#[cfg(any(test, feature = "_test_utils"))]
953953
macro_rules! get_channel_type_features {
954954
($node: expr, $counterparty_node: expr, $channel_id: expr) => {
955955
{
@@ -3473,7 +3473,7 @@ pub fn get_announce_close_broadcast_events<'a, 'b, 'c>(nodes: &Vec<Node<'a, 'b,
34733473
handle_announce_close_broadcast_events(nodes, a, b, false, "Channel closed because commitment or closing transaction was confirmed on chain.");
34743474
}
34753475

3476-
#[cfg(test)]
3476+
#[cfg(any(test, feature = "_test_utils"))]
34773477
macro_rules! get_channel_value_stat {
34783478
($node: expr, $counterparty_node: expr, $channel_id: expr) => {{
34793479
let peer_state_lock = $node.node.per_peer_state.read().unwrap();

0 commit comments

Comments
 (0)