Skip to content

Commit 2ce5479

Browse files
committed
Correct comments and flow in test_peer_storage
This cleans up `test_peer_storage` a bit to clarify what messages are actually being exchanged.
1 parent 9d9cfe6 commit 2ce5479

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17634,36 +17634,36 @@ mod tests {
1763417634
let node_1_events = nodes[1].node.get_and_clear_pending_msg_events();
1763517635
assert_eq!(node_1_events.len(), 2);
1763617636

17637-
// Since, node-0 does not have any memory it would not send any message.
1763817637
let node_0_events = nodes[0].node.get_and_clear_pending_msg_events();
1763917638
assert_eq!(node_0_events.len(), 1);
1764017639

1764117640
match node_0_events[0] {
1764217641
MessageSendEvent::SendChannelReestablish { ref node_id, .. } => {
1764317642
assert_eq!(*node_id, nodes[1].node.get_our_node_id());
17644-
// nodes[0] would send a bogus channel reestablish, so there's no need to handle this.
17643+
// nodes[0] would send a stale channel reestablish, so there's no need to handle this.
1764517644
},
1764617645
_ => panic!("Unexpected event"),
1764717646
}
1764817647

17649-
for msg in node_1_events {
17650-
if let MessageSendEvent::SendChannelReestablish { ref node_id, ref msg } = msg {
17651-
nodes[0].node.handle_channel_reestablish(nodes[1].node.get_our_node_id(), msg);
17652-
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
17653-
} else if let MessageSendEvent::SendPeerStorageRetrieval { ref node_id, ref msg } = msg
17654-
{
17655-
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
17656-
// Should Panic here!
17657-
let res = std::panic::catch_unwind(|| {
17658-
nodes[0]
17659-
.node
17660-
.handle_peer_storage_retrieval(nodes[1].node.get_our_node_id(), msg.clone())
17661-
});
17662-
assert!(res.is_err());
17663-
break;
17664-
} else {
17665-
panic!("Unexpected event")
17666-
}
17648+
if let MessageSendEvent::SendPeerStorageRetrieval { node_id, msg } = &node_1_events[0] {
17649+
assert_eq!(*node_id, nodes[0].node.get_our_node_id());
17650+
// Should Panic here!
17651+
let res = std::panic::catch_unwind(|| {
17652+
nodes[0]
17653+
.node
17654+
.handle_peer_storage_retrieval(nodes[1].node.get_our_node_id(), msg.clone())
17655+
});
17656+
assert!(res.is_err());
17657+
} else {
17658+
panic!("Unexpected event {node_1_events:?}")
17659+
}
17660+
17661+
if let MessageSendEvent::SendChannelReestablish { .. } = &node_1_events[1] {
17662+
// After the `peer_storage_retreival` message would come a `channel_reestablish` (which
17663+
// would also cause nodes[0] to panic) but it already went down due to lost state so
17664+
// there's nothing to deliver.
17665+
} else {
17666+
panic!("Unexpected event {node_1_events:?}")
1766717667
}
1766817668
// When we panic'd, we expect to panic on `Drop`.
1766917669
let res = std::panic::catch_unwind(|| drop(nodes));

0 commit comments

Comments
 (0)