Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store channels per-peer #1507

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions lightning/src/ln/chanmon_update_fail_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ fn test_monitor_and_persister_update_fail() {
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert_eq!(updates.update_fulfill_htlcs.len(), 1);
nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]);
if let Some(ref mut channel) = nodes[0].node.channel_state.lock().unwrap().by_id.get_mut(&chan.2) {
{
let mut node_0_per_peer_lock;
let mut node_0_peer_state_lock;
let mut channel = get_channel_ref!(nodes[0], nodes[1], node_0_per_peer_lock, node_0_peer_state_lock, chan.2);
if let Ok((_, _, update)) = channel.commitment_signed(&updates.commitment_signed, &node_cfgs[0].logger) {
// Check that even though the persister is returning a InProgress,
// because the update is bogus, ultimately the error that's returned
Expand All @@ -148,7 +151,7 @@ fn test_monitor_and_persister_update_fail() {
logger.assert_log_regex("lightning::chain::chainmonitor".to_string(), regex::Regex::new("Persistence of ChannelMonitorUpdate for channel [0-9a-f]* in progress").unwrap(), 1);
assert_eq!(nodes[0].chain_monitor.update_channel(outpoint, update), ChannelMonitorUpdateStatus::Completed);
} else { assert!(false); }
} else { assert!(false); };
}

check_added_monitors!(nodes[0], 1);
let events = nodes[0].node.get_and_clear_pending_events();
Expand Down Expand Up @@ -932,7 +935,8 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {

// Note that the ordering of the events for different nodes is non-prescriptive, though the
// ordering of the two events that both go to nodes[2] have to stay in the same order.
let messages_a = match events_3.pop().unwrap() {
let (nodes_0_event, events_3) = remove_first_msg_event_to_node(&nodes[0].node.get_our_node_id(), &events_3);
let messages_a = match nodes_0_event {
MessageSendEvent::UpdateHTLCs { node_id, mut updates } => {
assert_eq!(node_id, nodes[0].node.get_our_node_id());
assert!(updates.update_fulfill_htlcs.is_empty());
Expand All @@ -944,17 +948,21 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
},
_ => panic!("Unexpected event type!"),
};

let (nodes_2_event, events_3) = remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &events_3);
let send_event_b = SendEvent::from_event(nodes_2_event);
assert_eq!(send_event_b.node_id, nodes[2].node.get_our_node_id());

let raa = if test_ignore_second_cs {
match events_3.remove(1) {
let (nodes_2_event, _events_3) = remove_first_msg_event_to_node(&nodes[2].node.get_our_node_id(), &events_3);
match nodes_2_event {
MessageSendEvent::SendRevokeAndACK { node_id, msg } => {
assert_eq!(node_id, nodes[2].node.get_our_node_id());
Some(msg.clone())
},
_ => panic!("Unexpected event"),
}
} else { None };
let send_event_b = SendEvent::from_event(events_3.remove(0));
assert_eq!(send_event_b.node_id, nodes[2].node.get_our_node_id());

// Now deliver the new messages...

Expand Down Expand Up @@ -988,6 +996,7 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
check_added_monitors!(nodes[2], 1);

let bs_revoke_and_commit = nodes[2].node.get_and_clear_pending_msg_events();
// As both messages are for nodes[1], they're in order.
assert_eq!(bs_revoke_and_commit.len(), 2);
match bs_revoke_and_commit[0] {
MessageSendEvent::SendRevokeAndACK { ref node_id, ref msg } => {
Expand Down Expand Up @@ -1415,9 +1424,12 @@ fn monitor_failed_no_reestablish_response() {
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, channelmanager::provided_init_features(), channelmanager::provided_init_features()).2;
{
let mut lock;
get_channel_ref!(nodes[0], lock, channel_id).announcement_sigs_state = AnnouncementSigsState::PeerReceived;
get_channel_ref!(nodes[1], lock, channel_id).announcement_sigs_state = AnnouncementSigsState::PeerReceived;
let mut node_0_per_peer_lock;
let mut node_0_peer_state_lock;
let mut node_1_per_peer_lock;
let mut node_1_peer_state_lock;
get_channel_ref!(nodes[0], nodes[1], node_0_per_peer_lock, node_0_peer_state_lock, channel_id).announcement_sigs_state = AnnouncementSigsState::PeerReceived;
get_channel_ref!(nodes[1], nodes[0], node_1_per_peer_lock, node_1_peer_state_lock, channel_id).announcement_sigs_state = AnnouncementSigsState::PeerReceived;
}

// Route the payment and deliver the initial commitment_signed (with a monitor update failure
Expand Down
Loading