@@ -15463,9 +15463,26 @@ mod tests {
1546315463
1546415464 create_announced_chan_between_nodes(&nodes, 0, 1);
1546515465
15466- // Since we do not send peer storage, we manually simulate receiving a dummy
15467- // `PeerStorage` from the channel partner.
15468- nodes[0].node.handle_peer_storage(nodes[1].node.get_our_node_id(), msgs::PeerStorage{data: vec![0; 100]});
15466+ let peer_storage_msg_events_node0 = nodes[0].chain_monitor.chain_monitor.get_and_clear_pending_msg_events();
15467+ let peer_storage_msg_events_node1 = nodes[1].chain_monitor.chain_monitor.get_and_clear_pending_msg_events();
15468+ assert_ne!(peer_storage_msg_events_node0.len(), 0);
15469+ assert_ne!(peer_storage_msg_events_node1.len(), 0);
15470+
15471+ match peer_storage_msg_events_node0[0] {
15472+ MessageSendEvent::SendPeerStorage { ref node_id, ref msg } => {
15473+ assert_eq!(*node_id, nodes[1].node.get_our_node_id());
15474+ nodes[1].node.handle_peer_storage(nodes[0].node.get_our_node_id(), msg.clone());
15475+ }
15476+ _ => panic!("Unexpected event"),
15477+ }
15478+
15479+ match peer_storage_msg_events_node1[0] {
15480+ MessageSendEvent::SendPeerStorage { ref node_id, ref msg } => {
15481+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
15482+ nodes[0].node.handle_peer_storage(nodes[1].node.get_our_node_id(), msg.clone());
15483+ }
15484+ _ => panic!("Unexpected event"),
15485+ }
1546915486
1547015487 nodes[0].node.peer_disconnected(nodes[1].node.get_our_node_id());
1547115488 nodes[1].node.peer_disconnected(nodes[0].node.get_our_node_id());
@@ -15477,9 +15494,24 @@ mod tests {
1547715494 features: nodes[0].node.init_features(), networks: None, remote_network_address: None
1547815495 }, false).unwrap();
1547915496
15497+ let node_1_events = nodes[1].node.get_and_clear_pending_msg_events();
15498+ assert_eq!(node_1_events.len(), 2);
15499+
1548015500 let node_0_events = nodes[0].node.get_and_clear_pending_msg_events();
1548115501 assert_eq!(node_0_events.len(), 2);
1548215502
15503+ for msg in node_1_events{
15504+ if let MessageSendEvent::SendChannelReestablish { ref node_id, ref msg } = msg {
15505+ nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), msg);
15506+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
15507+ } else if let MessageSendEvent::SendPeerStorageRetrieval { ref node_id, ref msg } = msg {
15508+ nodes[0].node.handle_peer_storage_retrieval(nodes[1].node.get_our_node_id(), msg.clone());
15509+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
15510+ } else {
15511+ panic!("Unexpected event")
15512+ }
15513+ }
15514+
1548315515 for msg in node_0_events{
1548415516 if let MessageSendEvent::SendChannelReestablish { ref node_id, ref msg } = msg {
1548515517 nodes[1].node.handle_channel_reestablish(nodes[0].node.get_our_node_id(), msg);
@@ -15492,29 +15524,34 @@ mod tests {
1549215524 }
1549315525 }
1549415526
15495- let msg_events_after_peer_storage_retrieval = nodes[1].node.get_and_clear_pending_msg_events();
15527+ let node_1_msg_events = nodes[1].node.get_and_clear_pending_msg_events();
15528+ let node_0_msg_events = nodes[0].node.get_and_clear_pending_msg_events();
1549615529
15497- // Check if we receive a warning message.
15498- let peer_storage_warning: Vec<&MessageSendEvent> = msg_events_after_peer_storage_retrieval
15499- .iter()
15500- .filter(|event| match event {
15501- MessageSendEvent::HandleError { .. } => true,
15502- _ => false,
15503- })
15504- .collect();
15505-
15506- assert_eq!(peer_storage_warning.len(), 1);
15530+ assert_eq!(node_1_msg_events.len(), 3);
15531+ assert_eq!(node_0_msg_events.len(), 3);
1550715532
15508- match peer_storage_warning[0] {
15509- MessageSendEvent::HandleError { node_id, action } => {
15533+ for msg in node_1_msg_events {
15534+ if let MessageSendEvent::SendChannelReady { ref node_id, .. } = msg {
1551015535 assert_eq!(*node_id, nodes[0].node.get_our_node_id());
15511- match action {
15512- ErrorAction::SendWarningMessage { msg, .. } =>
15513- assert_eq!(msg.data, "Invalid peer_storage_retrieval message received.".to_owned()),
15514- _ => panic!("Unexpected error action"),
15515- }
15536+ } else if let MessageSendEvent::SendAnnouncementSignatures { ref node_id, .. } = msg {
15537+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
15538+ } else if let MessageSendEvent::SendChannelUpdate { ref node_id, .. } = msg {
15539+ assert_eq!(*node_id, nodes[0].node.get_our_node_id());
15540+ } else {
15541+ panic!("Unexpected event")
15542+ }
15543+ }
15544+
15545+ for msg in node_0_msg_events {
15546+ if let MessageSendEvent::SendChannelReady { ref node_id, .. } = msg {
15547+ assert_eq!(*node_id, nodes[1].node.get_our_node_id());
15548+ } else if let MessageSendEvent::SendAnnouncementSignatures { ref node_id, .. } = msg {
15549+ assert_eq!(*node_id, nodes[1].node.get_our_node_id());
15550+ } else if let MessageSendEvent::SendChannelUpdate { ref node_id, .. } = msg {
15551+ assert_eq!(*node_id, nodes[1].node.get_our_node_id());
15552+ } else {
15553+ panic!("Unexpected event")
1551615554 }
15517- _ => panic!("Unexpected event"),
1551815555 }
1551915556 }
1552015557
0 commit comments