fn drop(&mut self) {
if !panicking() {
// Check that we processed all pending events
- assert!(self.node.get_and_clear_pending_msg_events().is_empty());
- assert!(self.node.get_and_clear_pending_events().is_empty());
- assert!(self.chain_monitor.added_monitors.lock().unwrap().is_empty());
+ let msg_events = self.node.get_and_clear_pending_msg_events();
+ if !msg_events.is_empty() {
+ panic!("Had excess message events on node {}: {:?}", self.logger.id, msg_events);
+ }
+ let events = self.node.get_and_clear_pending_events();
+ if !events.is_empty() {
+ panic!("Had excess events on node {}: {:?}", self.logger.id, events);
+ }
+ let added_monitors = self.chain_monitor.added_monitors.lock().unwrap().split_off(0);
+ if !added_monitors.is_empty() {
+ panic!("Had {} excess added monitors on node {}", added_monitors.len(), self.logger.id);
+ }
// Check that if we serialize the Router, we can deserialize it again.
{
}
pub fn update_nodes_with_chan_announce<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, 'c, 'd>>, a: usize, b: usize, ann: &msgs::ChannelAnnouncement, upd_1: &msgs::ChannelUpdate, upd_2: &msgs::ChannelUpdate) {
- nodes[a].node.broadcast_node_announcement([0, 0, 0], [0; 32], Vec::new());
- let a_events = nodes[a].node.get_and_clear_pending_msg_events();
- assert!(a_events.len() >= 2);
-
- // ann should be re-generated by broadcast_node_announcement - check that we have it.
- let mut found_ann_1 = false;
- for event in a_events.iter() {
- match event {
- MessageSendEvent::BroadcastChannelAnnouncement { ref msg, .. } => {
- if msg == ann { found_ann_1 = true; }
- },
- MessageSendEvent::BroadcastNodeAnnouncement { .. } => {},
- _ => panic!("Unexpected event {:?}", event),
- }
- }
- assert!(found_ann_1);
-
- let a_node_announcement = match a_events.last().unwrap() {
- MessageSendEvent::BroadcastNodeAnnouncement { ref msg } => {
- (*msg).clone()
- },
- _ => panic!("Unexpected event"),
- };
-
- nodes[b].node.broadcast_node_announcement([1, 1, 1], [1; 32], Vec::new());
- let b_events = nodes[b].node.get_and_clear_pending_msg_events();
- assert!(b_events.len() >= 2);
-
- // ann should be re-generated by broadcast_node_announcement - check that we have it.
- let mut found_ann_2 = false;
- for event in b_events.iter() {
- match event {
- MessageSendEvent::BroadcastChannelAnnouncement { ref msg, .. } => {
- if msg == ann { found_ann_2 = true; }
- },
- MessageSendEvent::BroadcastNodeAnnouncement { .. } => {},
- _ => panic!("Unexpected event"),
- }
- }
- assert!(found_ann_2);
-
- let b_node_announcement = match b_events.last().unwrap() {
- MessageSendEvent::BroadcastNodeAnnouncement { ref msg } => {
- (*msg).clone()
- },
- _ => panic!("Unexpected event"),
- };
-
for node in nodes {
assert!(node.gossip_sync.handle_channel_announcement(ann).unwrap());
node.gossip_sync.handle_channel_update(upd_1).unwrap();
node.gossip_sync.handle_channel_update(upd_2).unwrap();
- node.gossip_sync.handle_node_announcement(&a_node_announcement).unwrap();
- node.gossip_sync.handle_node_announcement(&b_node_announcement).unwrap();
// Note that channel_updates are also delivered to ChannelManagers to ensure we have
// forwarding info for local channels even if its not accepted in the network graph.
// Note that the following only works for CLTV values up to 128
pub const ACCEPTED_HTLC_SCRIPT_WEIGHT: usize = 137; //Here we have a diff due to HTLC CLTV expiry being < 2^15 in test
-pub const OFFERED_HTLC_SCRIPT_WEIGHT: usize = 133;
#[derive(PartialEq)]
pub enum HTLCType { NONE, TIMEOUT, SUCCESS }
macro_rules! get_chan_reestablish_msgs {
($src_node: expr, $dst_node: expr) => {
{
+ let mut announcements = $crate::prelude::HashSet::new();
let mut res = Vec::with_capacity(1);
for msg in $src_node.node.get_and_clear_pending_msg_events() {
if let MessageSendEvent::SendChannelReestablish { ref node_id, ref msg } = msg {
assert_eq!(*node_id, $dst_node.node.get_our_node_id());
res.push(msg.clone());
+ } else if let MessageSendEvent::SendChannelAnnouncement { ref node_id, ref msg, .. } = msg {
+ assert_eq!(*node_id, $dst_node.node.get_our_node_id());
+ announcements.insert(msg.contents.short_channel_id);
} else {
panic!("Unexpected event")
}
}
+ for chan in $src_node.node.list_channels() {
+ if chan.is_public && chan.counterparty.node_id != $dst_node.node.get_our_node_id() {
+ if let Some(scid) = chan.short_channel_id {
+ assert!(announcements.remove(&scid));
+ }
+ }
+ }
+ assert!(announcements.is_empty());
res
}
}