X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Ffunctional_test_utils.rs;h=fdcdc0986571d069771c854bf1f4abe3ac870de9;hb=b6ff46daabc2d942f300efcbe9aca8bc541f0ff7;hp=c5361318fca7c59ec5f726b228e1754c2dc2338c;hpb=d1ac0717fe832bc8f439ad75c30dfe2e2012bfb3;p=rust-lightning diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index c5361318..fdcdc098 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -2535,6 +2535,7 @@ pub struct PassAlongPathArgs<'a, 'b, 'c, 'd> { pub expected_preimage: Option, pub is_probe: bool, pub custom_tlvs: Vec<(u64, Vec)>, + pub payment_metadata: Option>, } impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> { @@ -2545,7 +2546,7 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> { Self { origin_node, expected_path, recv_value, payment_hash, payment_secret: None, event, payment_claimable_expected: true, clear_recipient_events: true, expected_preimage: None, - is_probe: false, custom_tlvs: Vec::new(), + is_probe: false, custom_tlvs: Vec::new(), payment_metadata: None, } } pub fn without_clearing_recipient_events(mut self) -> Self { @@ -2573,13 +2574,17 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> { self.custom_tlvs = custom_tlvs; self } + pub fn with_payment_metadata(mut self, payment_metadata: Vec) -> Self { + self.payment_metadata = Some(payment_metadata); + self + } } pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option { let PassAlongPathArgs { origin_node, expected_path, recv_value, payment_hash: our_payment_hash, payment_secret: our_payment_secret, event: ev, payment_claimable_expected, - clear_recipient_events, expected_preimage, is_probe, custom_tlvs + clear_recipient_events, expected_preimage, is_probe, custom_tlvs, payment_metadata, } = args; let mut payment_event = SendEvent::from_event(ev); @@ -2613,6 +2618,7 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option assert_eq!(node.node.get_our_node_id(), receiver_node_id.unwrap()); assert!(onion_fields.is_some()); assert_eq!(onion_fields.as_ref().unwrap().custom_tlvs, custom_tlvs); + assert_eq!(onion_fields.as_ref().unwrap().payment_metadata, payment_metadata); match &purpose { PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => { assert_eq!(expected_preimage, *payment_preimage); @@ -2710,18 +2716,12 @@ pub fn send_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, route: Route (our_payment_preimage, our_payment_hash, our_payment_secret, payment_id) } -pub fn do_claim_payment_along_route<'a, 'b, 'c>( - origin_node: &Node<'a, 'b, 'c>, expected_paths: &[&[&Node<'a, 'b, 'c>]], skip_last: bool, - our_payment_preimage: PaymentPreimage -) -> u64 { - for path in expected_paths.iter() { - assert_eq!(path.last().unwrap().node.get_our_node_id(), expected_paths[0].last().unwrap().node.get_our_node_id()); +pub fn do_claim_payment_along_route(args: ClaimAlongRouteArgs) -> u64 { + for path in args.expected_paths.iter() { + assert_eq!(path.last().unwrap().node.get_our_node_id(), args.expected_paths[0].last().unwrap().node.get_our_node_id()); } - expected_paths[0].last().unwrap().node.claim_funds(our_payment_preimage); - pass_claimed_payment_along_route( - ClaimAlongRouteArgs::new(origin_node, expected_paths, our_payment_preimage) - .skip_last(skip_last) - ) + args.expected_paths[0].last().unwrap().node.claim_funds(args.payment_preimage); + pass_claimed_payment_along_route(args) } pub struct ClaimAlongRouteArgs<'a, 'b, 'c, 'd> { @@ -2951,7 +2951,10 @@ pub fn pass_claimed_payment_along_route<'a, 'b, 'c, 'd>(args: ClaimAlongRouteArg expected_total_fee_msat } pub fn claim_payment_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_paths: &[&[&Node<'a, 'b, 'c>]], skip_last: bool, our_payment_preimage: PaymentPreimage) { - let expected_total_fee_msat = do_claim_payment_along_route(origin_node, expected_paths, skip_last, our_payment_preimage); + let expected_total_fee_msat = do_claim_payment_along_route( + ClaimAlongRouteArgs::new(origin_node, expected_paths, our_payment_preimage) + .skip_last(skip_last) + ); if !skip_last { expect_payment_sent!(origin_node, our_payment_preimage, Some(expected_total_fee_msat)); }