X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Ffunctional_test_utils.rs;h=92aaee100f6e87121354511c139baef16d99a2ba;hb=1955008d6d1322733039cea486691fe00af094e7;hp=5690c834e73860d37729934c38c507bb648b3299;hpb=4d42284d2a575c45ab9496897685b996ed9c2ac7;p=rust-lightning diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 5690c834..92aaee10 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -763,21 +763,29 @@ macro_rules! check_closed_broadcast { }} } -/// Check that a channel's closing channel event has been issued +/// Check that a channel's closing channel events has been issued #[macro_export] macro_rules! check_closed_event { - ($node: expr, $events: expr, $reason: expr) => {{ + ($node: expr, $events: expr, $reason: expr) => { + check_closed_event!($node, $events, $reason, false); + }; + ($node: expr, $events: expr, $reason: expr, $is_check_discard_funding: expr) => {{ let events = $node.node.get_and_clear_pending_events(); assert_eq!(events.len(), $events); let expected_reason = $reason; + let mut issues_discard_funding = false; for event in events { match event { Event::ChannelClosed { ref reason, .. } => { assert_eq!(*reason, expected_reason); }, + Event::DiscardFunding { .. } => { + issues_discard_funding = true; + } _ => panic!("Unexpected event"), } } + assert_eq!($is_check_discard_funding, issues_discard_funding); }} } @@ -1073,7 +1081,7 @@ macro_rules! expect_payment_failed_with_update { let events = $node.node.get_and_clear_pending_events(); assert_eq!(events.len(), 1); match events[0] { - Event::PaymentFailed { ref payment_hash, rejected_by_dest, ref network_update, ref error_code, ref error_data, .. } => { + Event::PaymentPathFailed { ref payment_hash, rejected_by_dest, ref network_update, ref error_code, ref error_data, .. } => { assert_eq!(*payment_hash, $expected_payment_hash, "unexpected payment_hash"); assert_eq!(rejected_by_dest, $rejected_by_dest, "unexpected rejected_by_dest value"); assert!(error_code.is_some(), "expected error_code.is_some() = true"); @@ -1102,7 +1110,7 @@ macro_rules! expect_payment_failed { let events = $node.node.get_and_clear_pending_events(); assert_eq!(events.len(), 1); match events[0] { - Event::PaymentFailed { ref payment_hash, rejected_by_dest, network_update: _, ref error_code, ref error_data, .. } => { + Event::PaymentPathFailed { ref payment_hash, rejected_by_dest, network_update: _, ref error_code, ref error_data, .. } => { assert_eq!(*payment_hash, $expected_payment_hash, "unexpected payment_hash"); assert_eq!(rejected_by_dest, $rejected_by_dest, "unexpected rejected_by_dest value"); assert!(error_code.is_some(), "expected error_code.is_some() = true"); @@ -1399,10 +1407,13 @@ pub fn fail_payment_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expe let events = origin_node.node.get_and_clear_pending_events(); assert_eq!(events.len(), 1); match events[0] { - Event::PaymentFailed { payment_hash, rejected_by_dest, all_paths_failed, .. } => { + Event::PaymentPathFailed { payment_hash, rejected_by_dest, all_paths_failed, ref path, .. } => { assert_eq!(payment_hash, our_payment_hash); assert!(rejected_by_dest); assert_eq!(all_paths_failed, i == expected_paths.len() - 1); + for (idx, hop) in expected_route.iter().enumerate() { + assert_eq!(hop.node.get_our_node_id(), path[idx].pubkey); + } }, _ => panic!("Unexpected event"), }