X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fonion_route_tests.rs;h=48b8f05b3e2b5fe0099d6a9a1203c05137e24cd2;hb=0aaba2ce45a5f295aa76ff4afeaf96fa5f52bb5a;hp=c9422a6e07205f260d277ee24578a5b92a43ce5c;hpb=4006717f6fe195c4ea502002cd9360d620de9525;p=rust-lightning diff --git a/lightning/src/ln/onion_route_tests.rs b/lightning/src/ln/onion_route_tests.rs index c9422a6e..48b8f05b 100644 --- a/lightning/src/ln/onion_route_tests.rs +++ b/lightning/src/ln/onion_route_tests.rs @@ -25,7 +25,7 @@ use crate::ln::msgs::{ChannelMessageHandler, ChannelUpdate}; use crate::ln::wire::Encode; use crate::util::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider}; use crate::util::ser::{Writeable, Writer}; -use crate::util::{byte_utils, test_utils}; +use crate::util::test_utils; use crate::util::config::{UserConfig, ChannelConfig}; use crate::util::errors::APIError; @@ -125,7 +125,7 @@ fn run_onion_failure_test_with_fail_intercept(_name: &str, test_case: if test_case == 2 || test_case == 200 { expect_htlc_forward!(&nodes[2]); - expect_event!(&nodes[2], Event::PaymentReceived); + expect_event!(&nodes[2], Event::PaymentClaimable); callback_node(); expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[2], vec![HTLCDestination::FailedPayment { payment_hash: payment_hash.clone() }]); } @@ -1053,8 +1053,8 @@ fn test_phantom_final_incorrect_cltv_expiry() { commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false); // Ensure the payment fails with the expected error. - let expected_cltv = 82; - let error_data = byte_utils::be32_to_array(expected_cltv).to_vec(); + let expected_cltv: u32 = 82; + let error_data = expected_cltv.to_be_bytes().to_vec(); let mut fail_conditions = PaymentFailedConditions::new() .blamed_scid(phantom_scid) .expected_htlc_error_data(18, &error_data); @@ -1144,10 +1144,8 @@ fn test_phantom_failure_too_low_recv_amt() { commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false); // Ensure the payment fails with the expected error. - let mut error_data = byte_utils::be64_to_array(bad_recv_amt_msat).to_vec(); - error_data.extend_from_slice( - &byte_utils::be32_to_array(nodes[1].node.best_block.read().unwrap().height()), - ); + let mut error_data = bad_recv_amt_msat.to_be_bytes().to_vec(); + error_data.extend_from_slice(&nodes[1].node.best_block.read().unwrap().height().to_be_bytes()); let mut fail_conditions = PaymentFailedConditions::new() .blamed_scid(phantom_scid) .expected_htlc_error_data(0x4000 | 15, &error_data); @@ -1229,7 +1227,7 @@ fn test_phantom_failure_reject_payment() { nodes[1].node.process_pending_htlc_forwards(); expect_pending_htlcs_forwardable_ignore!(nodes[1]); nodes[1].node.process_pending_htlc_forwards(); - expect_payment_received!(nodes[1], payment_hash, payment_secret, recv_amt_msat); + expect_payment_claimable!(nodes[1], payment_hash, payment_secret, recv_amt_msat, None, route.paths[0].last().unwrap().pubkey); nodes[1].node.fail_htlc_backwards(&payment_hash); expect_pending_htlcs_forwardable_and_htlc_handling_failed_ignore!(nodes[1], vec![HTLCDestination::FailedPayment { payment_hash }]); nodes[1].node.process_pending_htlc_forwards(); @@ -1242,10 +1240,8 @@ fn test_phantom_failure_reject_payment() { commitment_signed_dance!(nodes[0], nodes[1], update_1.commitment_signed, false); // Ensure the payment fails with the expected error. - let mut error_data = byte_utils::be64_to_array(recv_amt_msat).to_vec(); - error_data.extend_from_slice( - &byte_utils::be32_to_array(nodes[1].node.best_block.read().unwrap().height()), - ); + let mut error_data = recv_amt_msat.to_be_bytes().to_vec(); + error_data.extend_from_slice(&nodes[1].node.best_block.read().unwrap().height().to_be_bytes()); let mut fail_conditions = PaymentFailedConditions::new() .blamed_scid(phantom_scid) .expected_htlc_error_data(0x4000 | 15, &error_data);