@@ -50,8 +50,7 @@ use lightning::util::events::MessageSendEventsProvider;
50
50
use lightning:: util:: ser:: { Readable , ReadableArgs , Writeable , Writer } ;
51
51
use lightning:: routing:: router:: { Route , RouteHop } ;
52
52
53
-
54
- use utils:: test_logger;
53
+ use utils:: test_logger:: { self , Output } ;
55
54
use utils:: test_persister:: TestPersister ;
56
55
57
56
use bitcoin:: secp256k1:: key:: { PublicKey , SecretKey } ;
@@ -339,7 +338,8 @@ fn send_hop_payment(source: &ChanMan, middle: &ChanMan, middle_chan_id: u64, des
339
338
}
340
339
341
340
#[ inline]
342
- pub fn do_test < Out : test_logger:: Output > ( data : & [ u8 ] , out : Out ) {
341
+ pub fn do_test < Out : Output > ( data : & [ u8 ] , underlying_out : Out ) {
342
+ let out = SearchingOutput :: new ( underlying_out) ;
343
343
let broadcast = Arc :: new ( TestBroadcaster { } ) ;
344
344
345
345
macro_rules! make_node {
@@ -734,7 +734,11 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
734
734
// force-close which we should detect as an error).
735
735
assert_eq!( msg. contents. flags & 2 , 0 ) ;
736
736
} ,
737
- _ => panic!( "Unhandled message event {:?}" , event) ,
737
+ _ => if out. may_fail. load( atomic:: Ordering :: Acquire ) {
738
+ return ;
739
+ } else {
740
+ panic!( "Unhandled message event {:?}" , event)
741
+ } ,
738
742
}
739
743
if $limit_events != ProcessMessages :: AllMessages {
740
744
break ;
@@ -766,7 +770,11 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
766
770
events:: MessageSendEvent :: SendChannelUpdate { ref msg, .. } => {
767
771
assert_eq!( msg. contents. flags & 2 , 0 ) ; // The disable bit must never be set!
768
772
} ,
769
- _ => panic!( "Unhandled message event" ) ,
773
+ _ => if out. may_fail. load( atomic:: Ordering :: Acquire ) {
774
+ return ;
775
+ } else {
776
+ panic!( "Unhandled message event" )
777
+ } ,
770
778
}
771
779
}
772
780
push_excess_b_events!( nodes[ 1 ] . get_and_clear_pending_msg_events( ) . drain( ..) , Some ( 0 ) ) ;
@@ -783,7 +791,11 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
783
791
events:: MessageSendEvent :: SendChannelUpdate { ref msg, .. } => {
784
792
assert_eq!( msg. contents. flags & 2 , 0 ) ; // The disable bit must never be set!
785
793
} ,
786
- _ => panic!( "Unhandled message event" ) ,
794
+ _ => if out. may_fail. load( atomic:: Ordering :: Acquire ) {
795
+ return ;
796
+ } else {
797
+ panic!( "Unhandled message event" )
798
+ } ,
787
799
}
788
800
}
789
801
push_excess_b_events!( nodes[ 1 ] . get_and_clear_pending_msg_events( ) . drain( ..) , Some ( 2 ) ) ;
@@ -834,7 +846,11 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
834
846
events:: Event :: PendingHTLCsForwardable { .. } => {
835
847
nodes[ $node] . process_pending_htlc_forwards( ) ;
836
848
} ,
837
- _ => panic!( "Unhandled event" ) ,
849
+ _ => if out. may_fail. load( atomic:: Ordering :: Acquire ) {
850
+ return ;
851
+ } else {
852
+ panic!( "Unhandled event" )
853
+ } ,
838
854
}
839
855
}
840
856
had_events
@@ -1125,7 +1141,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
1125
1141
break ;
1126
1142
}
1127
1143
1128
- // Finally, make sure that at least one end of each channel can make a substantial payment.
1144
+ // Finally, make sure that at least one end of each channel can make a substantial payment
1129
1145
assert ! (
1130
1146
send_payment( & nodes[ 0 ] , & nodes[ 1 ] , chan_a, 10_000_000 , & mut payment_id) ||
1131
1147
send_payment( & nodes[ 1 ] , & nodes[ 0 ] , chan_a, 10_000_000 , & mut payment_id) ) ;
@@ -1152,7 +1168,29 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
1152
1168
}
1153
1169
}
1154
1170
1155
- pub fn chanmon_consistency_test < Out : test_logger:: Output > ( data : & [ u8 ] , out : Out ) {
1171
+ /// We actually have different behavior based on if a certain log string has been seen, so we have
1172
+ /// to do a bit more tracking.
1173
+ #[ derive( Clone ) ]
1174
+ struct SearchingOutput < O : Output > {
1175
+ output : O ,
1176
+ may_fail : Arc < atomic:: AtomicBool > ,
1177
+ }
1178
+ impl < O : Output > Output for SearchingOutput < O > {
1179
+ fn locked_write ( & self , data : & [ u8 ] ) {
1180
+ // We hit a design limitation of LN state machine (see CONCURRENT_INBOUND_HTLC_FEE_BUFFER)
1181
+ if std:: str:: from_utf8 ( data) . unwrap ( ) . contains ( "Outbound update_fee HTLC buffer overflow - counterparty should force-close this channel" ) {
1182
+ self . may_fail . store ( true , atomic:: Ordering :: Release ) ;
1183
+ }
1184
+ self . output . locked_write ( data)
1185
+ }
1186
+ }
1187
+ impl < O : Output > SearchingOutput < O > {
1188
+ pub fn new ( output : O ) -> Self {
1189
+ Self { output, may_fail : Arc :: new ( atomic:: AtomicBool :: new ( false ) ) }
1190
+ }
1191
+ }
1192
+
1193
+ pub fn chanmon_consistency_test < Out : Output > ( data : & [ u8 ] , out : Out ) {
1156
1194
do_test ( data, out) ;
1157
1195
}
1158
1196
0 commit comments