use util::enforcing_trait_impls::EnforcingSigner;
use util::test_utils;
use util::test_utils::TestChainMonitor;
-use util::events::{Event, MessageSendEvent, MessageSendEventsProvider};
+use util::events::{Event, MessageSendEvent, MessageSendEventsProvider, PaymentPurpose};
use util::errors::APIError;
use util::config::UserConfig;
use util::ser::{ReadableArgs, Writeable, Readable};
use prelude::*;
use core::cell::RefCell;
use std::rc::Rc;
-use std::sync::{Arc, Mutex};
+use sync::{Arc, Mutex};
use core::mem;
pub const CHAN_CONFIRM_DEPTH: u32 = 10;
let events = $node.node.get_and_clear_pending_events();
assert_eq!(events.len(), 1);
match events[0] {
- Event::PaymentReceived { ref payment_hash, ref payment_preimage, ref payment_secret, amt, user_payment_id: _ } => {
+ Event::PaymentReceived { ref payment_hash, ref purpose, amt } => {
assert_eq!($expected_payment_hash, *payment_hash);
- assert!(payment_preimage.is_none());
- assert_eq!($expected_payment_secret, *payment_secret);
assert_eq!($expected_recv_value, amt);
+ match purpose {
+ PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
+ assert!(payment_preimage.is_none());
+ assert_eq!($expected_payment_secret, *payment_secret);
+ },
+ _ => {},
+ }
},
_ => panic!("Unexpected event"),
}
if payment_received_expected {
assert_eq!(events_2.len(), 1);
match events_2[0] {
- Event::PaymentReceived { ref payment_hash, ref payment_preimage, ref payment_secret, amt, user_payment_id: _ } => {
+ Event::PaymentReceived { ref payment_hash, ref purpose, amt} => {
assert_eq!(our_payment_hash, *payment_hash);
- assert!(payment_preimage.is_none());
- assert_eq!(our_payment_secret, *payment_secret);
+ match &purpose {
+ PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
+ assert!(payment_preimage.is_none());
+ assert_eq!(our_payment_secret, *payment_secret);
+ },
+ _ => {},
+ }
assert_eq!(amt, recv_value);
},
_ => panic!("Unexpected event"),
pub fn route_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route: &[&Node<'a, 'b, 'c>], recv_value: u64) -> (PaymentPreimage, PaymentHash, PaymentSecret) {
let net_graph_msg_handler = &origin_node.net_graph_msg_handler;
let logger = test_utils::TestLogger::new();
- let route = get_route(&origin_node.node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &expected_route.last().unwrap().node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &Vec::new(), recv_value, TEST_FINAL_CLTV, &logger).unwrap();
+ let route = get_route(&origin_node.node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(),
+ &expected_route.last().unwrap().node.get_our_node_id(), Some(InvoiceFeatures::known()),
+ Some(&origin_node.node.list_usable_channels().iter().collect::<Vec<_>>()), &[],
+ recv_value, TEST_FINAL_CLTV, &logger).unwrap();
assert_eq!(route.paths.len(), 1);
assert_eq!(route.paths[0].len(), expected_route.len());
for (node, hop) in expected_route.iter().zip(route.paths[0].iter()) {