@@ -52,7 +52,8 @@ use lightning::ln::channelmanager::{
52
52
use lightning:: ln:: functional_test_utils:: * ;
53
53
use lightning:: ln:: inbound_payment:: ExpandedKey ;
54
54
use lightning:: ln:: msgs:: {
55
- BaseMessageHandler , ChannelMessageHandler , CommitmentUpdate , Init , UpdateAddHTLC ,
55
+ BaseMessageHandler , ChannelMessageHandler , CommitmentUpdate , Init , MessageSendEvent ,
56
+ UpdateAddHTLC ,
56
57
} ;
57
58
use lightning:: ln:: script:: ShutdownScript ;
58
59
use lightning:: ln:: types:: ChannelId ;
@@ -769,7 +770,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
769
770
let open_channel = {
770
771
let events = $source. get_and_clear_pending_msg_events( ) ;
771
772
assert_eq!( events. len( ) , 1 ) ;
772
- if let events :: MessageSendEvent :: SendOpenChannel { ref msg, .. } = events[ 0 ] {
773
+ if let MessageSendEvent :: SendOpenChannel { ref msg, .. } = events[ 0 ] {
773
774
msg. clone( )
774
775
} else {
775
776
panic!( "Wrong event type" ) ;
@@ -805,7 +806,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
805
806
}
806
807
let events = $dest. get_and_clear_pending_msg_events( ) ;
807
808
assert_eq!( events. len( ) , 1 ) ;
808
- if let events :: MessageSendEvent :: SendAcceptChannel { ref msg, .. } = events[ 0 ] {
809
+ if let MessageSendEvent :: SendAcceptChannel { ref msg, .. } = events[ 0 ] {
809
810
msg. clone( )
810
811
} else {
811
812
panic!( "Wrong event type" ) ;
@@ -848,7 +849,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
848
849
let funding_created = {
849
850
let events = $source. get_and_clear_pending_msg_events( ) ;
850
851
assert_eq!( events. len( ) , 1 ) ;
851
- if let events :: MessageSendEvent :: SendFundingCreated { ref msg, .. } = events[ 0 ] {
852
+ if let MessageSendEvent :: SendFundingCreated { ref msg, .. } = events[ 0 ] {
852
853
msg. clone( )
853
854
} else {
854
855
panic!( "Wrong event type" ) ;
@@ -859,7 +860,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
859
860
let funding_signed = {
860
861
let events = $dest. get_and_clear_pending_msg_events( ) ;
861
862
assert_eq!( events. len( ) , 1 ) ;
862
- if let events :: MessageSendEvent :: SendFundingSigned { ref msg, .. } = events[ 0 ] {
863
+ if let MessageSendEvent :: SendFundingSigned { ref msg, .. } = events[ 0 ] {
863
864
msg. clone( )
864
865
} else {
865
866
panic!( "Wrong event type" ) ;
@@ -914,9 +915,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
914
915
}
915
916
for ( idx, node_event) in node_events. iter( ) . enumerate( ) {
916
917
for event in node_event {
917
- if let events:: MessageSendEvent :: SendChannelReady { ref node_id, ref msg } =
918
- event
919
- {
918
+ if let MessageSendEvent :: SendChannelReady { ref node_id, ref msg } = event {
920
919
for node in $nodes. iter( ) {
921
920
if node. get_our_node_id( ) == * node_id {
922
921
node. handle_channel_ready( $nodes[ idx] . get_our_node_id( ) , msg) ;
@@ -931,7 +930,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
931
930
for node in $nodes. iter( ) {
932
931
let events = node. get_and_clear_pending_msg_events( ) ;
933
932
for event in events {
934
- if let events :: MessageSendEvent :: SendAnnouncementSignatures { .. } = event {
933
+ if let MessageSendEvent :: SendAnnouncementSignatures { .. } = event {
935
934
} else {
936
935
panic!( "Wrong event type" ) ;
937
936
}
@@ -1016,25 +1015,25 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
1016
1015
let expect_drop_id = if let Some ( id) = expect_drop_node { Some ( nodes[ id] . get_our_node_id( ) ) } else { None } ;
1017
1016
for event in $excess_events {
1018
1017
let push_a = match event {
1019
- events :: MessageSendEvent :: UpdateHTLCs { ref node_id, .. } => {
1018
+ MessageSendEvent :: UpdateHTLCs { ref node_id, .. } => {
1020
1019
if Some ( * node_id) == expect_drop_id { panic!( "peer_disconnected should drop msgs bound for the disconnected peer" ) ; }
1021
1020
* node_id == a_id
1022
1021
} ,
1023
- events :: MessageSendEvent :: SendRevokeAndACK { ref node_id, .. } => {
1022
+ MessageSendEvent :: SendRevokeAndACK { ref node_id, .. } => {
1024
1023
if Some ( * node_id) == expect_drop_id { panic!( "peer_disconnected should drop msgs bound for the disconnected peer" ) ; }
1025
1024
* node_id == a_id
1026
1025
} ,
1027
- events :: MessageSendEvent :: SendChannelReestablish { ref node_id, .. } => {
1026
+ MessageSendEvent :: SendChannelReestablish { ref node_id, .. } => {
1028
1027
if Some ( * node_id) == expect_drop_id { panic!( "peer_disconnected should drop msgs bound for the disconnected peer" ) ; }
1029
1028
* node_id == a_id
1030
1029
} ,
1031
- events :: MessageSendEvent :: SendStfu { ref node_id, .. } => {
1030
+ MessageSendEvent :: SendStfu { ref node_id, .. } => {
1032
1031
if Some ( * node_id) == expect_drop_id { panic!( "peer_disconnected should drop msgs bound for the disconnected peer" ) ; }
1033
1032
* node_id == a_id
1034
1033
} ,
1035
- events :: MessageSendEvent :: SendChannelReady { .. } => continue ,
1036
- events :: MessageSendEvent :: SendAnnouncementSignatures { .. } => continue ,
1037
- events :: MessageSendEvent :: SendChannelUpdate { ref node_id, ref msg } => {
1034
+ MessageSendEvent :: SendChannelReady { .. } => continue ,
1035
+ MessageSendEvent :: SendAnnouncementSignatures { .. } => continue ,
1036
+ MessageSendEvent :: SendChannelUpdate { ref node_id, ref msg } => {
1038
1037
assert_eq!( msg. contents. channel_flags & 2 , 0 ) ; // The disable bit must never be set!
1039
1038
if Some ( * node_id) == expect_drop_id { panic!( "peer_disconnected should drop msgs bound for the disconnected peer" ) ; }
1040
1039
* node_id == a_id
@@ -1090,7 +1089,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
1090
1089
for event in & mut events_iter {
1091
1090
had_events = true ;
1092
1091
match event {
1093
- events :: MessageSendEvent :: UpdateHTLCs { node_id, updates: CommitmentUpdate { update_add_htlcs, update_fail_htlcs, update_fulfill_htlcs, update_fail_malformed_htlcs, update_fee, commitment_signed } } => {
1092
+ MessageSendEvent :: UpdateHTLCs { node_id, updates: CommitmentUpdate { update_add_htlcs, update_fail_htlcs, update_fulfill_htlcs, update_fail_malformed_htlcs, update_fee, commitment_signed } } => {
1094
1093
for ( idx, dest) in nodes. iter( ) . enumerate( ) {
1095
1094
if dest. get_our_node_id( ) == node_id {
1096
1095
for update_add in update_add_htlcs. iter( ) {
@@ -1128,7 +1127,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
1128
1127
!update_fail_htlcs. is_empty( ) || !update_fail_malformed_htlcs. is_empty( ) ;
1129
1128
if $limit_events != ProcessMessages :: AllMessages && processed_change {
1130
1129
// If we only want to process some messages, don't deliver the CS until later.
1131
- extra_ev = Some ( events :: MessageSendEvent :: UpdateHTLCs { node_id, updates: CommitmentUpdate {
1130
+ extra_ev = Some ( MessageSendEvent :: UpdateHTLCs { node_id, updates: CommitmentUpdate {
1132
1131
update_add_htlcs: Vec :: new( ) ,
1133
1132
update_fail_htlcs: Vec :: new( ) ,
1134
1133
update_fulfill_htlcs: Vec :: new( ) ,
@@ -1144,37 +1143,37 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
1144
1143
}
1145
1144
}
1146
1145
} ,
1147
- events :: MessageSendEvent :: SendRevokeAndACK { ref node_id, ref msg } => {
1146
+ MessageSendEvent :: SendRevokeAndACK { ref node_id, ref msg } => {
1148
1147
for ( idx, dest) in nodes. iter( ) . enumerate( ) {
1149
1148
if dest. get_our_node_id( ) == * node_id {
1150
1149
out. locked_write( format!( "Delivering revoke_and_ack from node {} to node {}.\n " , $node, idx) . as_bytes( ) ) ;
1151
1150
dest. handle_revoke_and_ack( nodes[ $node] . get_our_node_id( ) , msg) ;
1152
1151
}
1153
1152
}
1154
1153
} ,
1155
- events :: MessageSendEvent :: SendChannelReestablish { ref node_id, ref msg } => {
1154
+ MessageSendEvent :: SendChannelReestablish { ref node_id, ref msg } => {
1156
1155
for ( idx, dest) in nodes. iter( ) . enumerate( ) {
1157
1156
if dest. get_our_node_id( ) == * node_id {
1158
1157
out. locked_write( format!( "Delivering channel_reestablish from node {} to node {}.\n " , $node, idx) . as_bytes( ) ) ;
1159
1158
dest. handle_channel_reestablish( nodes[ $node] . get_our_node_id( ) , msg) ;
1160
1159
}
1161
1160
}
1162
1161
} ,
1163
- events :: MessageSendEvent :: SendStfu { ref node_id, ref msg } => {
1162
+ MessageSendEvent :: SendStfu { ref node_id, ref msg } => {
1164
1163
for ( idx, dest) in nodes. iter( ) . enumerate( ) {
1165
1164
if dest. get_our_node_id( ) == * node_id {
1166
1165
out. locked_write( format!( "Delivering stfu from node {} to node {}.\n " , $node, idx) . as_bytes( ) ) ;
1167
1166
dest. handle_stfu( nodes[ $node] . get_our_node_id( ) , msg) ;
1168
1167
}
1169
1168
}
1170
1169
}
1171
- events :: MessageSendEvent :: SendChannelReady { .. } => {
1170
+ MessageSendEvent :: SendChannelReady { .. } => {
1172
1171
// Can be generated as a reestablish response
1173
1172
} ,
1174
- events :: MessageSendEvent :: SendAnnouncementSignatures { .. } => {
1173
+ MessageSendEvent :: SendAnnouncementSignatures { .. } => {
1175
1174
// Can be generated as a reestablish response
1176
1175
} ,
1177
- events :: MessageSendEvent :: SendChannelUpdate { ref msg, .. } => {
1176
+ MessageSendEvent :: SendChannelUpdate { ref msg, .. } => {
1178
1177
// When we reconnect we will resend a channel_update to make sure our
1179
1178
// counterparty has the latest parameters for receiving payments
1180
1179
// through us. We do, however, check that the message does not include
@@ -1217,13 +1216,13 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
1217
1216
if $counterparty_id == 0 {
1218
1217
for event in nodes[ 0 ] . get_and_clear_pending_msg_events( ) {
1219
1218
match event {
1220
- events :: MessageSendEvent :: UpdateHTLCs { .. } => { } ,
1221
- events :: MessageSendEvent :: SendRevokeAndACK { .. } => { } ,
1222
- events :: MessageSendEvent :: SendChannelReestablish { .. } => { } ,
1223
- events :: MessageSendEvent :: SendStfu { .. } => { } ,
1224
- events :: MessageSendEvent :: SendChannelReady { .. } => { } ,
1225
- events :: MessageSendEvent :: SendAnnouncementSignatures { .. } => { } ,
1226
- events :: MessageSendEvent :: SendChannelUpdate { ref msg, .. } => {
1219
+ MessageSendEvent :: UpdateHTLCs { .. } => { } ,
1220
+ MessageSendEvent :: SendRevokeAndACK { .. } => { } ,
1221
+ MessageSendEvent :: SendChannelReestablish { .. } => { } ,
1222
+ MessageSendEvent :: SendStfu { .. } => { } ,
1223
+ MessageSendEvent :: SendChannelReady { .. } => { } ,
1224
+ MessageSendEvent :: SendAnnouncementSignatures { .. } => { } ,
1225
+ MessageSendEvent :: SendChannelUpdate { ref msg, .. } => {
1227
1226
assert_eq!( msg. contents. channel_flags & 2 , 0 ) ; // The disable bit must never be set!
1228
1227
} ,
1229
1228
_ => {
@@ -1244,13 +1243,13 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
1244
1243
} else {
1245
1244
for event in nodes[ 2 ] . get_and_clear_pending_msg_events( ) {
1246
1245
match event {
1247
- events :: MessageSendEvent :: UpdateHTLCs { .. } => { } ,
1248
- events :: MessageSendEvent :: SendRevokeAndACK { .. } => { } ,
1249
- events :: MessageSendEvent :: SendChannelReestablish { .. } => { } ,
1250
- events :: MessageSendEvent :: SendStfu { .. } => { } ,
1251
- events :: MessageSendEvent :: SendChannelReady { .. } => { } ,
1252
- events :: MessageSendEvent :: SendAnnouncementSignatures { .. } => { } ,
1253
- events :: MessageSendEvent :: SendChannelUpdate { ref msg, .. } => {
1246
+ MessageSendEvent :: UpdateHTLCs { .. } => { } ,
1247
+ MessageSendEvent :: SendRevokeAndACK { .. } => { } ,
1248
+ MessageSendEvent :: SendChannelReestablish { .. } => { } ,
1249
+ MessageSendEvent :: SendStfu { .. } => { } ,
1250
+ MessageSendEvent :: SendChannelReady { .. } => { } ,
1251
+ MessageSendEvent :: SendAnnouncementSignatures { .. } => { } ,
1252
+ MessageSendEvent :: SendChannelUpdate { ref msg, .. } => {
1254
1253
assert_eq!( msg. contents. channel_flags & 2 , 0 ) ; // The disable bit must never be set!
1255
1254
} ,
1256
1255
_ => {
0 commit comments