X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Ffunctional_tests.rs;h=fac15fc5aaab9d17b429ae5ca8661fc03fb95918;hb=cfb9eb96397e392475f6bc65368617372f41dc64;hp=df9b512d9383ce04422ccda0d3d07ae77800f586;hpb=1ceb41e08b2d76b23d2505a10a88db8d840895ca;p=rust-lightning diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index df9b512d..fac15fc5 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -18,7 +18,7 @@ use crate::chain::channelmonitor; use crate::chain::channelmonitor::{CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS, ANTI_REORG_DELAY}; use crate::chain::transaction::OutPoint; use crate::chain::keysinterface::{ChannelSigner, EcdsaChannelSigner, EntropySource}; -use crate::events::{Event, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose, ClosureReason, HTLCDestination}; +use crate::events::{Event, MessageSendEvent, MessageSendEventsProvider, PathFailure, PaymentPurpose, ClosureReason, HTLCDestination, PaymentFailureReason}; use crate::ln::{PaymentPreimage, PaymentSecret, PaymentHash}; use crate::ln::channel::{commitment_tx_base_weight, COMMITMENT_TX_WEIGHT_PER_HTLC, CONCURRENT_INBOUND_HTLC_FEE_BUFFER, FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE, MIN_AFFORDABLE_HTLC_COUNT}; use crate::ln::channelmanager::{self, PaymentId, RAACommitmentOrder, PaymentSendFailure, RecipientOnionFields, BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA}; @@ -4897,15 +4897,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() { nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fulfill_htlcs[0]); commitment_signed_dance!(nodes[0], nodes[1], &updates.commitment_signed, false); - - let events = nodes[0].node.get_and_clear_pending_events(); - match events[0] { - Event::PaymentSent { ref payment_preimage, ref payment_hash, .. } => { - assert_eq!(*payment_preimage, our_payment_preimage); - assert_eq!(*payment_hash, duplicate_payment_hash); - } - _ => panic!("Unexpected event"), - } + expect_payment_sent(&nodes[0], our_payment_preimage, None, true); } #[test] @@ -9481,26 +9473,7 @@ fn test_inconsistent_mpp_params() { pass_along_path(&nodes[0], &[&nodes[2], &nodes[3]], 15_000_000, our_payment_hash, Some(our_payment_secret), events.pop().unwrap(), true, None); do_claim_payment_along_route(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, our_payment_preimage); - let events = nodes[0].node.get_and_clear_pending_events(); - assert_eq!(events.len(), 3); - match events[0] { - Event::PaymentSent { payment_hash, .. } => { // The payment was abandoned earlier, so the fee paid will be None - assert_eq!(payment_hash, our_payment_hash); - }, - _ => panic!("Unexpected event") - } - match events[1] { - Event::PaymentPathSuccessful { payment_hash, .. } => { - assert_eq!(payment_hash.unwrap(), our_payment_hash); - }, - _ => panic!("Unexpected event") - } - match events[2] { - Event::PaymentPathSuccessful { payment_hash, .. } => { - assert_eq!(payment_hash.unwrap(), our_payment_hash); - }, - _ => panic!("Unexpected event") - } + expect_payment_sent(&nodes[0], our_payment_preimage, Some(None), true); } #[test] @@ -9608,7 +9581,7 @@ fn test_double_partial_claim() { ]; expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[3], failed_destinations); - pass_failed_payment_back(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_hash); + pass_failed_payment_back(&nodes[0], &[&[&nodes[1], &nodes[3]], &[&nodes[2], &nodes[3]]], false, payment_hash, PaymentFailureReason::RecipientRejected); // nodes[1] now retries one of the two paths... nodes[0].node.send_payment_with_route(&route, payment_hash,