@@ -26,13 +26,14 @@ use {
26
26
crate :: sign:: ChannelSigner as _,
27
27
crate :: util:: ser:: TransactionU16LenLimited ,
28
28
crate :: util:: test_utils,
29
- bitcoin:: { Weight , Witness } ,
29
+ bitcoin:: Witness ,
30
30
} ;
31
31
32
32
// Dual-funding: V2 Channel Establishment Tests
33
33
struct V2ChannelEstablishmentTestSession {
34
34
funding_input_sats : u64 ,
35
35
initiator_input_value_satoshis : u64 ,
36
+ steps : u64 ,
36
37
}
37
38
38
39
// TODO(dual_funding): Use real node and API for creating V2 channels as initiator when available,
@@ -85,6 +86,12 @@ fn do_test_v2_channel_establishment(session: V2ChannelEstablishmentTestSession)
85
86
& RevocationBasepoint :: from ( open_channel_v2_msg. common_fields . revocation_basepoint ) ,
86
87
) ;
87
88
89
+ if session. steps == 1 {
90
+ // We return early in this step which will lead to a round-trip serialization when nodes[1]
91
+ // is dropped.
92
+ return ;
93
+ }
94
+
88
95
let tx_add_input_msg = TxAddInput {
89
96
channel_id,
90
97
serial_id : 2 , // Even serial_id from initiator.
@@ -102,6 +109,12 @@ fn do_test_v2_channel_establishment(session: V2ChannelEstablishmentTestSession)
102
109
let _tx_complete_msg =
103
110
get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendTxComplete , nodes[ 0 ] . node. get_our_node_id( ) ) ;
104
111
112
+ if session. steps == 2 {
113
+ // We return early in this step which will lead to a round-trip serialization when nodes[1]
114
+ // is dropped.
115
+ return ;
116
+ }
117
+
105
118
let tx_add_output_msg = TxAddOutput {
106
119
channel_id,
107
120
serial_id : 4 ,
@@ -130,6 +143,12 @@ fn do_test_v2_channel_establishment(session: V2ChannelEstablishmentTestSession)
130
143
_ => panic ! ( "Unexpected event" ) ,
131
144
} ;
132
145
146
+ if session. steps == 3 {
147
+ // We return early in this step which will lead to a round-trip serialization when nodes[1]
148
+ // is dropped.
149
+ return ;
150
+ }
151
+
133
152
let ( funding_outpoint, channel_type_features) = {
134
153
let per_peer_state = nodes[ 1 ] . node . per_peer_state . read ( ) . unwrap ( ) ;
135
154
let peer_state =
@@ -227,6 +246,12 @@ fn do_test_v2_channel_establishment(session: V2ChannelEstablishmentTestSession)
227
246
228
247
assert_eq ! ( tx_signatures_msg. channel_id, channel_id) ;
229
248
249
+ if session. steps == 4 {
250
+ // We return early in this step which will lead to a round-trip serialization when nodes[1]
251
+ // is dropped.
252
+ return ;
253
+ }
254
+
230
255
let mut witness = Witness :: new ( ) ;
231
256
witness. push ( [ 0x0 ] ) ;
232
257
// Receive tx_signatures from channel initiator.
@@ -250,6 +275,27 @@ fn do_test_v2_channel_establishment(session: V2ChannelEstablishmentTestSession)
250
275
fn test_v2_channel_establishment ( ) {
251
276
do_test_v2_channel_establishment ( V2ChannelEstablishmentTestSession {
252
277
funding_input_sats : 100_00 ,
253
- initiator_input_value_satoshis : 150_000 ,
278
+ initiator_input_value_satoshis : 100_000 ,
279
+ steps : 1 ,
280
+ } ) ;
281
+ do_test_v2_channel_establishment ( V2ChannelEstablishmentTestSession {
282
+ funding_input_sats : 100_00 ,
283
+ initiator_input_value_satoshis : 100_000 ,
284
+ steps : 2 ,
285
+ } ) ;
286
+ do_test_v2_channel_establishment ( V2ChannelEstablishmentTestSession {
287
+ funding_input_sats : 100_00 ,
288
+ initiator_input_value_satoshis : 100_000 ,
289
+ steps : 3 ,
290
+ } ) ;
291
+ do_test_v2_channel_establishment ( V2ChannelEstablishmentTestSession {
292
+ funding_input_sats : 100_00 ,
293
+ initiator_input_value_satoshis : 100_000 ,
294
+ steps : 4 ,
295
+ } ) ;
296
+ do_test_v2_channel_establishment ( V2ChannelEstablishmentTestSession {
297
+ funding_input_sats : 100_00 ,
298
+ initiator_input_value_satoshis : 100_000 ,
299
+ steps : 5 ,
254
300
} ) ;
255
301
}
0 commit comments