Skip to content

Commit a31362a

Browse files
committed
Cleaner fix for test loop.
1 parent 063aff4 commit a31362a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lightning/src/ln/peer_handler.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, L: Deref, CMH: Deref> P
12181218
},
12191219
wire::Message::GossipTimestampFilter(_msg) => {
12201220
// When supporting gossip messages, start inital gossip sync only after we receive
1221-
// a GossipTimestampFilter
1221+
// a GossipTimestampFilter
12221222
if peer.their_features.as_ref().unwrap().supports_gossip_queries() &&
12231223
!peer.sent_gossip_timestamp_filter {
12241224
peer.sent_gossip_timestamp_filter = true;
@@ -1817,6 +1817,8 @@ mod tests {
18171817
assert_eq!(peer_b.read_event(&mut fd_b, &fd_a.outbound_data.lock().unwrap().split_off(0)).unwrap(), false);
18181818
peer_b.process_events();
18191819
assert_eq!(peer_a.read_event(&mut fd_a, &fd_b.outbound_data.lock().unwrap().split_off(0)).unwrap(), false);
1820+
peer_a.process_events();
1821+
assert_eq!(peer_b.read_event(&mut fd_b, &fd_a.outbound_data.lock().unwrap().split_off(0)).unwrap(), false);
18201822
(fd_a.clone(), fd_b.clone())
18211823
}
18221824

@@ -1882,19 +1884,19 @@ mod tests {
18821884
// Make each peer to read the messages that the other peer just wrote to them. Note that
18831885
// due to the max-message-before-ping limits this may take a few iterations to complete.
18841886
for _ in 0..150/super::BUFFER_DRAIN_MSGS_PER_TICK + 1 {
1885-
peers[0].process_events();
1886-
let b_read_data = fd_a.outbound_data.lock().unwrap().split_off(0);
1887-
assert!(!b_read_data.is_empty());
1888-
1889-
peers[1].read_event(&mut fd_b, &b_read_data).unwrap();
18901887
peers[1].process_events();
1891-
18921888
let a_read_data = fd_b.outbound_data.lock().unwrap().split_off(0);
18931889
assert!(!a_read_data.is_empty());
1890+
18941891
peers[0].read_event(&mut fd_a, &a_read_data).unwrap();
1892+
peers[0].process_events();
18951893

1896-
peers[1].process_events();
1897-
assert_eq!(fd_b.outbound_data.lock().unwrap().len(), 0, "Until B receives data, it shouldn't send more messages");
1894+
let b_read_data = fd_a.outbound_data.lock().unwrap().split_off(0);
1895+
assert!(!b_read_data.is_empty());
1896+
peers[1].read_event(&mut fd_b, &b_read_data).unwrap();
1897+
1898+
peers[0].process_events();
1899+
assert_eq!(fd_a.outbound_data.lock().unwrap().len(), 0, "Until A receives data, it shouldn't send more messages");
18981900
}
18991901

19001902
// Check that each peer has received the expected number of channel updates and channel

0 commit comments

Comments
 (0)