X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fpeer_handler.rs;h=709437052db712d9aceca3ae82a6f8c2ead727b9;hb=4cbea8bef846e0fa220e1b650476896a386a57f7;hp=7215db8f6b57547b6c7156825504dba244c0380a;hpb=da26ede7e226fcdfbc6e8ea257bcd9e05d5075d8;p=rust-lightning diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 7215db8f..70943705 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -1729,11 +1729,20 @@ mod tests { // Make each peer to read the messages that the other peer just wrote to them. Note that // due to the max-messagse-before-bing limits this may take a few iterations to complete. - for _ in 0..10 { + for _ in 0..150/super::BUFFER_DRAIN_MSGS_PER_TICK + 1 { peers[0].process_events(); - peers[1].read_event(&mut fd_b, &fd_a.outbound_data.lock().unwrap().split_off(0)).unwrap(); + let b_read_data = fd_a.outbound_data.lock().unwrap().split_off(0); + assert!(!b_read_data.is_empty()); + + peers[1].read_event(&mut fd_b, &b_read_data).unwrap(); + peers[1].process_events(); + + let a_read_data = fd_b.outbound_data.lock().unwrap().split_off(0); + assert!(!a_read_data.is_empty()); + peers[0].read_event(&mut fd_a, &a_read_data).unwrap(); + peers[1].process_events(); - peers[0].read_event(&mut fd_a, &fd_b.outbound_data.lock().unwrap().split_off(0)).unwrap(); + assert_eq!(fd_b.outbound_data.lock().unwrap().len(), 0, "Until B receives data, it shouldn't send more messages"); } // Check that each peer has received the expected number of channel updates and channel