use std::rc::Rc;
use std::sync::{Arc, Mutex};
use core::mem;
-use std::collections::HashMap;
pub const CHAN_CONFIRM_DEPTH: u32 = 10;
pub fn best_block_info(&self) -> (BlockHash, u32) {
self.blocks.lock().unwrap().last().map(|(a, b)| (a.block_hash(), *b)).unwrap()
}
+ pub fn get_block_header(&self, height: u32) -> BlockHeader {
+ self.blocks.lock().unwrap()[height as usize].0
+ }
}
impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
}
}
+#[cfg(test)]
+macro_rules! expect_payment_failure_chan_update {
+ ($node: expr, $scid: expr, $chan_closed: expr) => {
+ let events = $node.node.get_and_clear_pending_msg_events();
+ assert_eq!(events.len(), 1);
+ match events[0] {
+ MessageSendEvent::PaymentFailureNetworkUpdate { ref update } => {
+ match update {
+ &HTLCFailChannelUpdate::ChannelUpdateMessage { ref msg } if !$chan_closed => {
+ assert_eq!(msg.contents.short_channel_id, $scid);
+ assert_eq!(msg.contents.flags & 2, 0);
+ },
+ &HTLCFailChannelUpdate::ChannelClosed { short_channel_id, is_permanent } if $chan_closed => {
+ assert_eq!(short_channel_id, $scid);
+ assert!(is_permanent);
+ },
+ _ => panic!("Unexpected update type"),
+ }
+ },
+ _ => panic!("Unexpected event"),
+ }
+ }
+}
+
#[cfg(test)]
macro_rules! expect_payment_failed {
($node: expr, $expected_payment_hash: expr, $rejected_by_dest: expr $(, $expected_error_code: expr, $expected_error_data: expr)*) => {