Skip to content

Commit

Permalink
update functional test and check warn message instead of a close channel
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
  • Loading branch information
vincenzopalazzo committed Apr 22, 2022
1 parent 8c7dca8 commit c70e6d3
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7380,12 +7380,23 @@ fn test_data_loss_protect() {
}

// Check we close channel detecting A is fallen-behind
nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &reestablish_1[0]);
check_closed_event!(nodes[1], 1, ClosureReason::ProcessingError { err: "Peer attempted to reestablish channel with a very old local commitment transaction".to_string() });
assert_eq!(check_closed_broadcast!(nodes[1], true).unwrap().data, "Peer attempted to reestablish channel with a very old local commitment transaction");
check_added_monitors!(nodes[1], 1);
// Check if we sent the warning message when we detecting that A is fallen-behind,
// and we give the possibility to A to be able to recover from error.
for msg in nodes[1].node.get_and_clear_pending_msg_events() {
if let MessageSendEvent::HandleError { ref action, .. } = msg {
match action {
&ErrorAction::SendWarningMessage { ref msg, .. } => {
assert!(msg.data.contains(&"Peer attempted to reestablish channel with a very old local commitment transaction".to_owned()));
},
_ => panic!("Unexpected event!"),
}
} else {
panic!("Unexpected event")
}
}

// Check A is able to claim to_remote output
// FIXME: On the A side, check how we need to manage the warning message received.
/*
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().clone();
assert_eq!(node_txn.len(), 1);
check_spends!(node_txn[0], chan.3);
Expand All @@ -7396,6 +7407,7 @@ fn test_data_loss_protect() {
let spend_txn = check_spendable_outputs!(nodes[0], node_cfgs[0].keys_manager);
assert_eq!(spend_txn.len(), 1);
check_spends!(spend_txn[0], node_txn[0]);
*/
}

#[test]
Expand Down

0 comments on commit c70e6d3

Please sign in to comment.