@@ -15099,10 +15099,27 @@ mod tests {
1509915099 let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
1510015100
1510115101 create_announced_chan_between_nodes(&nodes, 0, 1);
15102-
15103- // Since we do not send peer storage, we manually simulate receiving a dummy
15104- // `PeerStorage` from the channel partner.
15105- nodes[0].node.handle_peer_storage(nodes[1].node.get_our_node_id(), msgs::PeerStorage{data: vec![0; 100]});
15102+
15103+ let peer_storage_msg_events_node0 = nodes[0].chain_monitor.chain_monitor.get_and_clear_pending_msg_events();
15104+ let peer_storage_msg_events_node1 = nodes[1].chain_monitor.chain_monitor.get_and_clear_pending_msg_events();
15105+ assert_ne!(peer_storage_msg_events_node0.len(), 0);
15106+ assert_ne!(peer_storage_msg_events_node1.len(), 0);
15107+
15108+ match peer_storage_msg_events_node0[0] {
15109+ MessageSendEvent::SendPeerStorage { ref node_id, ref msg } => {
15110+ assert_eq!(*node_id, nodes[1].node.get_our_node_id());
15111+ nodes[1].node.handle_peer_storage(nodes[0].node.get_our_node_id(), msg.clone());
15112+ }
15113+ _ => panic!("Unexpected event"),
15114+ }
15115+
15116+ match peer_storage_msg_events_node1[0] {
15117+ MessageSendEvent::SendPeerStorage { ref node_id, ref msg } => {
15118+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
15119+ nodes[0].node.handle_peer_storage(nodes[1].node.get_our_node_id(), msg.clone());
15120+ }
15121+ _ => panic!("Unexpected event"),
15122+ }
1510615123
1510715124 nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
1510815125 nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
@@ -15114,9 +15131,24 @@ mod tests {
1511415131 features: nodes[0].node.init_features(), networks: None, remote_network_address: None
1511515132 }, false).unwrap();
1511615133
15134+ let node_1_events = nodes[1].node.get_and_clear_pending_msg_events();
15135+ assert_eq!(node_1_events.len(), 2);
15136+
1511715137 let node_0_events = nodes[0].node.get_and_clear_pending_msg_events();
1511815138 assert_eq!(node_0_events.len(), 2);
1511915139
15140+ for msg in node_1_events{
15141+ if let MessageSendEvent::SendChannelReestablish { ref node_id, ref msg } = msg {
15142+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), msg);
15143+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
15144+ } else if let MessageSendEvent::SendPeerStorageRetrieval { ref node_id, ref msg } = msg {
15145+ nodes[0].node.handle_peer_storage_retrieval(nodes[1].node.get_our_node_id(), msg.clone());
15146+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
15147+ } else {
15148+ panic!("Unexpected event")
15149+ }
15150+ }
15151+
1512015152 for msg in node_0_events{
1512115153 if let MessageSendEvent::SendChannelReestablish { ref node_id, ref msg } = msg {
1512215154 nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), msg);
@@ -15129,30 +15161,9 @@ mod tests {
1512915161 }
1513015162 }
1513115163
15132- let msg_events_after_peer_storage_retrieval = nodes[1].node.get_and_clear_pending_msg_events();
15133-
15134- // Check if we receive a warning message.
15135- let peer_storage_warning: Vec<&MessageSendEvent> = msg_events_after_peer_storage_retrieval
15136- .iter()
15137- .filter(|event| match event {
15138- MessageSendEvent::HandleError { .. } => true,
15139- _ => false,
15140- })
15141- .collect();
15142-
15143- assert_eq!(peer_storage_warning.len(), 1);
15144-
15145- match peer_storage_warning[0] {
15146- MessageSendEvent::HandleError { node_id, action } => {
15147- assert_eq!(*node_id, nodes[0].node.get_our_node_id());
15148- match action {
15149- ErrorAction::SendWarningMessage { msg, .. } =>
15150- assert_eq!(msg.data, "Invalid peer_storage_retrieval message received.".to_owned()),
15151- _ => panic!("Unexpected error action"),
15152- }
15153- }
15154- _ => panic!("Unexpected event"),
15155- }
15164+ // Clear all other messages.
15165+ nodes[1].node.get_and_clear_pending_msg_events();
15166+ nodes[0].node.get_and_clear_pending_msg_events();
1515615167 }
1515715168
1515815169 #[test]
0 commit comments