Skip to content

Commit dab203b

Browse files
committed
f - Clear pending payments in onion_route_tests
1 parent a5e513b commit dab203b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4665,6 +4665,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
46654665
pub fn has_pending_payments(&self) -> bool {
46664666
!self.pending_outbound_payments.lock().unwrap().is_empty()
46674667
}
4668+
4669+
#[cfg(test)]
4670+
pub fn clear_pending_payments(&self) {
4671+
self.pending_outbound_payments.lock().unwrap().clear()
4672+
}
46684673
}
46694674

46704675
impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> MessageSendEventsProvider for ChannelManager<Signer, M, T, K, F, L>

lightning/src/ln/onion_route_tests.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,19 +477,16 @@ fn test_onion_failure() {
477477
bogus_route.paths[0][route_len-1].fee_msat = amt_to_forward;
478478
run_onion_failure_test("amount_below_minimum", 0, &nodes, &bogus_route, &payment_hash, &payment_secret, |_| {}, ||{}, true, Some(UPDATE|11), Some(NetworkUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy(short_channel_id)}), Some(short_channel_id));
479479

480+
// Clear pending payments so that the following positive test has the correct payment hash.
480481
for node in nodes.iter() {
481-
*node.keys_manager.override_session_priv.lock().unwrap() = Some([4; 32]);
482+
node.node.clear_pending_payments();
482483
}
483484

484485
// Test a positive test-case with one extra msat, meeting the minimum.
485486
bogus_route.paths[0][route_len-1].fee_msat = amt_to_forward + 1;
486487
let preimage = send_along_route(&nodes[0], bogus_route, &[&nodes[1], &nodes[2]], amt_to_forward+1).0;
487488
claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], preimage);
488489

489-
for node in nodes.iter() {
490-
*node.keys_manager.override_session_priv.lock().unwrap() = Some([3; 32]);
491-
}
492-
493490
//TODO: with new config API, we will be able to generate both valid and
494491
//invalid channel_update cases.
495492
let short_channel_id = channels[0].0.contents.short_channel_id;

0 commit comments

Comments
 (0)