Skip to content

Commit 3a05947

Browse files
committed
Remove incomplete dual funding tests
The tests have become a bit painful to maintain, and they don't even fully test the production code paths, so we opt to just remove them for now. In the future, we plan to unify the dual funding code paths with splicing.
1 parent 867f084 commit 3a05947

File tree

2 files changed

+0
-253
lines changed

2 files changed

+0
-253
lines changed

lightning/src/ln/channel.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6209,19 +6209,6 @@ where
62096209
}
62106210
}
62116211

6212-
#[cfg(all(test))]
6213-
pub fn get_initial_counterparty_commitment_signature_for_test<L: Deref>(
6214-
&mut self, funding: &mut FundingScope, logger: &L,
6215-
counterparty_next_commitment_point_override: PublicKey,
6216-
) -> Option<Signature>
6217-
where
6218-
SP::Target: SignerProvider,
6219-
L::Target: Logger,
6220-
{
6221-
self.counterparty_next_commitment_point = Some(counterparty_next_commitment_point_override);
6222-
self.get_initial_counterparty_commitment_signature(funding, logger)
6223-
}
6224-
62256212
fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
62266213
let minimum_depth = self
62276214
.minimum_depth(funding)

lightning/src/ln/dual_funding_tests.rs

Lines changed: 0 additions & 240 deletions
Original file line numberDiff line numberDiff line change
@@ -8,243 +8,3 @@
88
// licenses.
99

1010
//! Tests that test the creation of dual-funded channels in ChannelManager.
11-
12-
use {
13-
crate::chain::chaininterface::{ConfirmationTarget, LowerBoundedFeeEstimator},
14-
crate::events::Event,
15-
crate::ln::chan_utils::{
16-
make_funding_redeemscript, ChannelPublicKeys, ChannelTransactionParameters,
17-
CounterpartyChannelTransactionParameters,
18-
},
19-
crate::ln::channel::PendingV2Channel,
20-
crate::ln::channel_keys::{DelayedPaymentBasepoint, HtlcBasepoint, RevocationBasepoint},
21-
crate::ln::functional_test_utils::*,
22-
crate::ln::funding::FundingTxInput,
23-
crate::ln::msgs::{BaseMessageHandler, ChannelMessageHandler, MessageSendEvent},
24-
crate::ln::msgs::{CommitmentSigned, TxAddInput, TxAddOutput, TxComplete, TxSignatures},
25-
crate::ln::types::ChannelId,
26-
crate::prelude::*,
27-
crate::util::test_utils,
28-
bitcoin::Witness,
29-
};
30-
31-
// Dual-funding: V2 Channel Establishment Tests
32-
struct V2ChannelEstablishmentTestSession {
33-
funding_input_sats: u64,
34-
initiator_input_value_satoshis: u64,
35-
}
36-
37-
// TODO(dual_funding): Use real node and API for creating V2 channels as initiator when available,
38-
// instead of manually constructing messages.
39-
fn do_test_v2_channel_establishment(session: V2ChannelEstablishmentTestSession) {
40-
let chanmon_cfgs = create_chanmon_cfgs(2);
41-
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
42-
let mut node_1_user_config = test_default_channel_config();
43-
node_1_user_config.enable_dual_funded_channels = true;
44-
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, Some(node_1_user_config)]);
45-
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
46-
let logger_a = test_utils::TestLogger::with_id("node a".to_owned());
47-
48-
// Create a funding input for the new channel along with its previous transaction.
49-
let initiator_funding_inputs: Vec<_> = create_dual_funding_utxos_with_prev_txs(
50-
&nodes[0],
51-
&[session.initiator_input_value_satoshis],
52-
);
53-
54-
// Alice creates a dual-funded channel as initiator.
55-
let funding_satoshis = session.funding_input_sats;
56-
let mut channel = PendingV2Channel::new_outbound(
57-
&LowerBoundedFeeEstimator(node_cfgs[0].fee_estimator),
58-
&nodes[0].node.entropy_source,
59-
&nodes[0].node.signer_provider,
60-
nodes[1].node.get_our_node_id(),
61-
&nodes[1].node.init_features(),
62-
funding_satoshis,
63-
initiator_funding_inputs.clone(),
64-
42, /* user_channel_id */
65-
&nodes[0].node.get_current_config(),
66-
nodes[0].best_block_info().1,
67-
nodes[0].node.create_and_insert_outbound_scid_alias_for_test(),
68-
ConfirmationTarget::NonAnchorChannelFee,
69-
&logger_a,
70-
)
71-
.unwrap();
72-
let open_channel_v2_msg = channel.get_open_channel_v2(nodes[0].chain_source.chain_hash);
73-
74-
nodes[1].node.handle_open_channel_v2(nodes[0].node.get_our_node_id(), &open_channel_v2_msg);
75-
76-
let accept_channel_v2_msg = get_event_msg!(
77-
nodes[1],
78-
MessageSendEvent::SendAcceptChannelV2,
79-
nodes[0].node.get_our_node_id()
80-
);
81-
let channel_id = ChannelId::v2_from_revocation_basepoints(
82-
&RevocationBasepoint::from(accept_channel_v2_msg.common_fields.revocation_basepoint),
83-
&RevocationBasepoint::from(open_channel_v2_msg.common_fields.revocation_basepoint),
84-
);
85-
86-
let FundingTxInput { sequence, prevtx, .. } = &initiator_funding_inputs[0];
87-
let tx_add_input_msg = TxAddInput {
88-
channel_id,
89-
serial_id: 2, // Even serial_id from initiator.
90-
prevtx: Some(prevtx.clone()),
91-
prevtx_out: 0,
92-
sequence: sequence.0,
93-
shared_input_txid: None,
94-
};
95-
let input_value = tx_add_input_msg.prevtx.as_ref().unwrap().output
96-
[tx_add_input_msg.prevtx_out as usize]
97-
.value;
98-
assert_eq!(input_value.to_sat(), session.initiator_input_value_satoshis);
99-
100-
nodes[1].node.handle_tx_add_input(nodes[0].node.get_our_node_id(), &tx_add_input_msg);
101-
102-
let _tx_complete_msg =
103-
get_event_msg!(nodes[1], MessageSendEvent::SendTxComplete, nodes[0].node.get_our_node_id());
104-
105-
let tx_add_output_msg = TxAddOutput {
106-
channel_id,
107-
serial_id: 4,
108-
sats: funding_satoshis,
109-
script: make_funding_redeemscript(
110-
&open_channel_v2_msg.common_fields.funding_pubkey,
111-
&accept_channel_v2_msg.common_fields.funding_pubkey,
112-
)
113-
.to_p2wsh(),
114-
};
115-
nodes[1].node.handle_tx_add_output(nodes[0].node.get_our_node_id(), &tx_add_output_msg);
116-
117-
let _tx_complete_msg =
118-
get_event_msg!(nodes[1], MessageSendEvent::SendTxComplete, nodes[0].node.get_our_node_id());
119-
120-
let tx_complete_msg = TxComplete { channel_id };
121-
122-
nodes[1].node.handle_tx_complete(nodes[0].node.get_our_node_id(), &tx_complete_msg);
123-
let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
124-
assert_eq!(msg_events.len(), 1);
125-
let _msg_commitment_signed_from_1 = match msg_events[0] {
126-
MessageSendEvent::UpdateHTLCs { ref node_id, channel_id: _, ref updates } => {
127-
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
128-
updates.commitment_signed.clone()
129-
},
130-
_ => panic!("Unexpected event"),
131-
};
132-
133-
let (funding_outpoint, channel_type_features) = {
134-
let per_peer_state = nodes[1].node.per_peer_state.read().unwrap();
135-
let peer_state =
136-
per_peer_state.get(&nodes[0].node.get_our_node_id()).unwrap().lock().unwrap();
137-
let channel_funding =
138-
peer_state.channel_by_id.get(&tx_complete_msg.channel_id).unwrap().funding();
139-
(channel_funding.get_funding_txo(), channel_funding.get_channel_type().clone())
140-
};
141-
142-
channel.funding.channel_transaction_parameters = ChannelTransactionParameters {
143-
counterparty_parameters: Some(CounterpartyChannelTransactionParameters {
144-
pubkeys: ChannelPublicKeys {
145-
funding_pubkey: accept_channel_v2_msg.common_fields.funding_pubkey,
146-
revocation_basepoint: RevocationBasepoint(
147-
accept_channel_v2_msg.common_fields.revocation_basepoint,
148-
),
149-
payment_point: accept_channel_v2_msg.common_fields.payment_basepoint,
150-
delayed_payment_basepoint: DelayedPaymentBasepoint(
151-
accept_channel_v2_msg.common_fields.delayed_payment_basepoint,
152-
),
153-
htlc_basepoint: HtlcBasepoint(accept_channel_v2_msg.common_fields.htlc_basepoint),
154-
},
155-
selected_contest_delay: accept_channel_v2_msg.common_fields.to_self_delay,
156-
}),
157-
holder_pubkeys: ChannelPublicKeys {
158-
funding_pubkey: open_channel_v2_msg.common_fields.funding_pubkey,
159-
revocation_basepoint: RevocationBasepoint(
160-
open_channel_v2_msg.common_fields.revocation_basepoint,
161-
),
162-
payment_point: open_channel_v2_msg.common_fields.payment_basepoint,
163-
delayed_payment_basepoint: DelayedPaymentBasepoint(
164-
open_channel_v2_msg.common_fields.delayed_payment_basepoint,
165-
),
166-
htlc_basepoint: HtlcBasepoint(open_channel_v2_msg.common_fields.htlc_basepoint),
167-
},
168-
holder_selected_contest_delay: open_channel_v2_msg.common_fields.to_self_delay,
169-
is_outbound_from_holder: true,
170-
funding_outpoint,
171-
splice_parent_funding_txid: None,
172-
channel_type_features,
173-
channel_value_satoshis: funding_satoshis,
174-
};
175-
176-
let msg_commitment_signed_from_0 = CommitmentSigned {
177-
channel_id,
178-
signature: channel
179-
.context
180-
.get_initial_counterparty_commitment_signature_for_test(
181-
&mut channel.funding,
182-
&&logger_a,
183-
accept_channel_v2_msg.common_fields.first_per_commitment_point,
184-
)
185-
.unwrap(),
186-
htlc_signatures: vec![],
187-
funding_txid: None,
188-
#[cfg(taproot)]
189-
partial_signature_with_nonce: None,
190-
};
191-
192-
chanmon_cfgs[1].persister.set_update_ret(crate::chain::ChannelMonitorUpdateStatus::InProgress);
193-
194-
// Handle the initial commitment_signed exchange. Order is not important here.
195-
nodes[1]
196-
.node
197-
.handle_commitment_signed(nodes[0].node.get_our_node_id(), &msg_commitment_signed_from_0);
198-
check_added_monitors(&nodes[1], 1);
199-
200-
// The funding transaction should not have been broadcast before persisting initial monitor has
201-
// been completed.
202-
assert_eq!(nodes[1].tx_broadcaster.txn_broadcast().len(), 0);
203-
assert_eq!(nodes[1].node.get_and_clear_pending_events().len(), 0);
204-
205-
// Complete the persistence of the monitor.
206-
let events = nodes[1].node.get_and_clear_pending_events();
207-
assert!(events.is_empty());
208-
nodes[1].chain_monitor.complete_sole_pending_chan_update(&channel_id);
209-
210-
let tx_signatures_msg = get_event_msg!(
211-
nodes[1],
212-
MessageSendEvent::SendTxSignatures,
213-
nodes[0].node.get_our_node_id()
214-
);
215-
216-
assert_eq!(tx_signatures_msg.channel_id, channel_id);
217-
218-
let mut witness = Witness::new();
219-
witness.push([0x0]);
220-
// Receive tx_signatures from channel initiator.
221-
nodes[1].node.handle_tx_signatures(
222-
nodes[0].node.get_our_node_id(),
223-
&TxSignatures {
224-
channel_id,
225-
tx_hash: funding_outpoint.unwrap().txid,
226-
witnesses: vec![witness],
227-
shared_input_signature: None,
228-
},
229-
);
230-
231-
let events = nodes[1].node.get_and_clear_pending_events();
232-
assert_eq!(events.len(), 1);
233-
match events[0] {
234-
Event::ChannelPending { channel_id: chan_id, .. } => assert_eq!(chan_id, channel_id),
235-
_ => panic!("Unexpected event"),
236-
};
237-
238-
// For an inbound channel V2 channel the transaction should be broadcast once receiving a
239-
// tx_signature and applying local tx_signatures:
240-
let broadcasted_txs = nodes[1].tx_broadcaster.txn_broadcast();
241-
assert_eq!(broadcasted_txs.len(), 1);
242-
}
243-
244-
#[test]
245-
fn test_v2_channel_establishment() {
246-
do_test_v2_channel_establishment(V2ChannelEstablishmentTestSession {
247-
funding_input_sats: 100_00,
248-
initiator_input_value_satoshis: 150_000,
249-
});
250-
}

0 commit comments

Comments
 (0)