Skip to content

Commit e385663

Browse files
committed
f increase test coverage
1 parent cd01677 commit e385663

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lightning/src/ln/functional_test_utils.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1244,13 +1244,15 @@ pub fn send_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, route: Route
12441244
(our_payment_preimage, our_payment_hash, our_payment_secret, payment_id)
12451245
}
12461246

1247-
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) {
1247+
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 {
12481248
for path in expected_paths.iter() {
12491249
assert_eq!(path.last().unwrap().node.get_our_node_id(), expected_paths[0].last().unwrap().node.get_our_node_id());
12501250
}
12511251
assert!(expected_paths[0].last().unwrap().node.claim_funds(our_payment_preimage));
12521252
check_added_monitors!(expected_paths[0].last().unwrap(), expected_paths.len());
12531253

1254+
let mut expected_total_fee_msat = 0;
1255+
12541256
macro_rules! msgs_from_ev {
12551257
($ev: expr) => {
12561258
match $ev {
@@ -1293,6 +1295,7 @@ pub fn do_claim_payment_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>,
12931295
$node.node.handle_update_fulfill_htlc(&$prev_node.node.get_our_node_id(), &next_msgs.as_ref().unwrap().0);
12941296
let fee = $node.node.channel_state.lock().unwrap().by_id.get(&next_msgs.as_ref().unwrap().0.channel_id).unwrap().config.forwarding_fee_base_msat;
12951297
expect_payment_forwarded!($node, Some(fee as u64), false);
1298+
expected_total_fee_msat += fee as u64;
12961299
check_added_monitors!($node, 1);
12971300
let new_next_msgs = if $new_msgs {
12981301
let events = $node.node.get_and_clear_pending_msg_events();
@@ -1331,11 +1334,12 @@ pub fn do_claim_payment_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>,
13311334
last_update_fulfill_dance!(origin_node, expected_route.first().unwrap());
13321335
}
13331336
}
1337+
expected_total_fee_msat
13341338
}
13351339
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) {
1336-
do_claim_payment_along_route(origin_node, expected_paths, skip_last, our_payment_preimage);
1340+
let expected_total_fee_msat = do_claim_payment_along_route(origin_node, expected_paths, skip_last, our_payment_preimage);
13371341
if !skip_last {
1338-
expect_payment_sent!(origin_node, our_payment_preimage);
1342+
expect_payment_sent!(origin_node, our_payment_preimage, Some(expected_total_fee_msat));
13391343
}
13401344
}
13411345

0 commit comments

Comments
 (0)