assert_eq!(txn_a, txn_b);
assert_eq!(txn_a.len(), 1);
check_spends!(txn_a[0], funding_tx);
+ check_closed_event!(nodes[1], 1);
+ check_closed_event!(nodes[0], 1);
}
#[test]
assert!(nodes[0].node.close_channel(&channel_id).is_ok());
check_closed_broadcast!(nodes[0], true);
check_added_monitors!(nodes[0], 2);
+ check_closed_event!(nodes[0], 1);
}
#[test]
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &InitFeatures::known(), &shutdown);
check_closed_broadcast!(nodes[1], true);
check_added_monitors!(nodes[1], 2);
+ check_closed_event!(nodes[1], 1);
}
#[test]
added_monitors.clear();
}
let forwarded_events = nodes[1].node.get_and_clear_pending_events();
- assert_eq!(forwarded_events.len(), 2);
- if let Event::PaymentForwarded { fee_earned_msat: Some(1000), claim_from_onchain_tx: true } = forwarded_events[0] {
- } else { panic!(); }
+ assert_eq!(forwarded_events.len(), 3);
+ match forwarded_events[0] {
+ Event::ChannelClosed { .. } => {}
+ _ => panic!("Unexpected event"),
+ }
if let Event::PaymentForwarded { fee_earned_msat: Some(1000), claim_from_onchain_tx: true } = forwarded_events[1] {
} else { panic!(); }
+ if let Event::PaymentForwarded { fee_earned_msat: Some(1000), claim_from_onchain_tx: true } = forwarded_events[2] {
+ } else { panic!(); }
let events = nodes[1].node.get_and_clear_pending_msg_events();
{
let mut added_monitors = nodes[1].chain_monitor.added_monitors.lock().unwrap();
mine_transaction(&nodes[1], &node_a_commitment_tx[0]);
check_closed_broadcast!(nodes[1], true);
check_added_monitors!(nodes[1], 1);
- check_closed_event!(nodes[1], 2);
+ check_closed_event!(nodes[1], 1);
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().clone();
assert_eq!(node_txn.len(), 6); // ChannelManager : 3 (commitment tx + HTLC-Sucess * 2), ChannelMonitor : 3 (HTLC-Success, 2* RBF bumps of above HTLC txn)
let commitment_spend =
let header = BlockHeader { version: 0x20000000, prev_blockhash: nodes[1].best_block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42};
connect_block(&nodes[1], &Block { header, txdata: vec![c_txn[1].clone(), c_txn[2].clone()]});
check_added_monitors!(nodes[1], 1);
- expect_payment_forwarded!(nodes[1], Some(1000), true);
+ let events = nodes[1].node.get_and_clear_pending_events();
+ assert_eq!(events.len(), 2);
+ match events[0] {
+ Event::ChannelClosed { .. } => {}
+ _ => panic!("Unexpected event"),
+ }
+ match events[1] {
+ Event::PaymentForwarded { fee_earned_msat, claim_from_onchain_tx } => {
+ assert_eq!(fee_earned_msat, Some(1000));
+ assert_eq!(claim_from_onchain_tx, true);
+ },
+ _ => panic!("Unexpected event"),
+ }
{
let mut b_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
// ChannelMonitor: claim tx
b_txn.clear();
}
check_added_monitors!(nodes[1], 1);
- check_closed_event!(nodes[1], 1);
let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
assert_eq!(msg_events.len(), 3);
- check_added_monitors!(nodes[1], 1);
match msg_events[0] {
MessageSendEvent::BroadcastChannelUpdate { .. } => {},
_ => panic!("Unexpected event"),
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &updates.update_add_htlcs[0]);
commitment_signed_dance!(nodes[1], nodes[0], updates.commitment_signed, false);
- let events = nodes[0].node.get_and_clear_pending_events();
+ let events = nodes[1].node.get_and_clear_pending_events();
expect_pending_htlcs_forwardable!(nodes[1], events);
get_htlc_update_msgs!(nodes[1], nodes[2].node.get_our_node_id());
check_added_monitors!(nodes[1], 1);
mine_transaction(&nodes[1], &bs_txn[0]);
check_added_monitors!(nodes[1], 1);
check_closed_broadcast!(nodes[1], true);
+ check_closed_event!(nodes[1], 1);
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1);
- let events = nodes[0].node.get_and_clear_pending_events();
+ let events = nodes[1].node.get_and_clear_pending_events();
expect_pending_htlcs_forwardable!(nodes[1], events);
check_added_monitors!(nodes[1], 1);
let fail_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
assert!(nodes[0].node.list_channels().is_empty());
check_closed_broadcast!(nodes[0], true);
check_added_monitors!(nodes[0], 1);
+ check_closed_event!(nodes[0], 1);
assert!(nodes[1].node.list_channels().is_empty());
check_closed_broadcast!(nodes[1], true);
check_added_monitors!(nodes[1], 1);
+ check_closed_event!(nodes[1], 1);
// Drop transactions broadcasted in response to the first commitment transaction (we have good
// test coverage of these things already elsewhere).
assert!(nodes[0].node.list_channels().is_empty());
assert!(nodes[1].node.list_channels().is_empty());
+ check_closed_event!(nodes[0], 1);
+ check_closed_event!(nodes[1], 1);
}
#[test]
nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
let (_, node_1_none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(node_1_none.is_none());
+ check_closed_event!(nodes[0], 1);
+ check_closed_event!(nodes[1], 1);
assert!(nodes[0].node.list_channels().is_empty());
close_channel(&nodes[1], &nodes[2], &chan_2.2, chan_2.3, true);
assert!(nodes[1].node.list_channels().is_empty());
assert!(nodes[2].node.list_channels().is_empty());
+ check_closed_event!(nodes[1], 1);
+ check_closed_event!(nodes[2], 1);
}
#[test]
close_channel(&nodes[1], &nodes[2], &chan_2.2, chan_2.3, true);
assert!(nodes[1].node.list_channels().is_empty());
assert!(nodes[2].node.list_channels().is_empty());
+ check_closed_event!(nodes[0], 1);
+ check_closed_event!(nodes[1], 2);
+ check_closed_event!(nodes[2], 1);
}
fn do_test_shutdown_rebroadcast(recv_count: u8) {
nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.unwrap());
let (_, node_1_none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
assert!(node_1_none.is_none());
+ check_closed_event!(nodes[1], 1);
} else {
// If one node, however, received + responded with an identical closing_signed we end
// up erroring and node[0] will try to broadcast its own latest commitment transaction.
// closing_signed so we do it ourselves
check_closed_broadcast!(nodes[1], false);
check_added_monitors!(nodes[1], 1);
+ check_closed_event!(nodes[1], 1);
}
assert!(nodes[0].node.list_channels().is_empty());
close_channel(&nodes[1], &nodes[2], &chan_2.2, chan_2.3, true);
assert!(nodes[1].node.list_channels().is_empty());
assert!(nodes[2].node.list_channels().is_empty());
+ check_closed_event!(nodes[0], 1);
+ check_closed_event!(nodes[1], 1);
+ check_closed_event!(nodes[2], 1);
}
#[test]
MessageSendEvent::SendClosingSigned { node_id, .. } => { assert_eq!(node_id, nodes[1].node.get_our_node_id()) }
_ => panic!("Unexpected event"),
}
+ check_closed_event!(nodes[2], 1);
}
#[test]
},
_ => panic!("Unexpected event"),
}
+ check_closed_event!(nodes[0], 1);
}
#[test]
_ => panic!("Unexpected event"),
}
check_added_monitors!(nodes[0], 1);
+ check_closed_event!(nodes[0], 1);
}
#[test]
_ => panic!("Unexpected event"),
}
check_added_monitors!(nodes[0], 1);
+ check_closed_event!(nodes[0], 1);
}
#[derive(PartialEq)]
let node_0_2nd_closing_signed = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
if timeout_step == TimeoutStep::NoTimeout {
nodes[1].node.handle_closing_signed(&nodes[0].node.get_our_node_id(), &node_0_2nd_closing_signed.1.unwrap());
+ check_closed_event!(nodes[1], 1);
}
+ check_closed_event!(nodes[0], 1);
}
if timeout_step != TimeoutStep::NoTimeout {
txn[0].output[0].script_pubkey.is_v0_p2wsh()));
check_closed_broadcast!(nodes[1], true);
check_added_monitors!(nodes[1], 1);
+ check_closed_event!(nodes[1], 1);
} else {
assert!(txn[0].output[0].script_pubkey.is_v0_p2wpkh());
assert!(txn[0].output[1].script_pubkey.is_v0_p2wpkh());
nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed.unwrap());
let (_, node_0_none) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
assert!(node_0_none.is_none());
+ check_closed_event!(nodes[0], 1);
+ check_closed_event!(nodes[1], 1);
}
#[test]
nodes[0].node.handle_closing_signed(&nodes[1].node.get_our_node_id(), &node_1_closing_signed);
let (_, node_0_none) = get_closing_signed_broadcast!(nodes[0].node, nodes[1].node.get_our_node_id());
assert!(node_0_none.is_none());
+ check_closed_event!(nodes[0], 1);
+ check_closed_event!(nodes[1], 1);
}