X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fonion_route_tests.rs;h=0b6012f637a52ad5090ff1ab782cabb202c9f872;hb=a257906743d528c32c862b053b652d4b728aa990;hp=a15e06b5d0c74a7f83604b22f80433bc6101ecdc;hpb=3b3713fdde4c0bea587f8e9bca396d81fb5a7ac9;p=rust-lightning diff --git a/lightning/src/ln/onion_route_tests.rs b/lightning/src/ln/onion_route_tests.rs index a15e06b5..0b6012f6 100644 --- a/lightning/src/ln/onion_route_tests.rs +++ b/lightning/src/ln/onion_route_tests.rs @@ -11,23 +11,23 @@ //! These tests work by standing up full nodes and route payments across the network, checking the //! returned errors decode to the correct thing. -use chain::channelmonitor::{ChannelMonitor, CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS}; -use chain::keysinterface::{KeysInterface, Recipient}; -use ln::{PaymentHash, PaymentSecret}; -use ln::channel::EXPIRE_PREV_CONFIG_TICKS; -use ln::channelmanager::{self, ChannelManager, ChannelManagerReadArgs, HTLCForwardInfo, CLTV_FAR_FAR_AWAY, MIN_CLTV_EXPIRY_DELTA, PendingHTLCInfo, PendingHTLCRouting}; -use ln::onion_utils; -use routing::gossip::{NetworkUpdate, RoutingFees, NodeId}; -use routing::router::{get_route, PaymentParameters, Route, RouteHint, RouteHintHop}; -use ln::features::{InitFeatures, InvoiceFeatures, NodeFeatures}; -use ln::msgs; -use ln::msgs::{ChannelMessageHandler, ChannelUpdate}; -use ln::wire::Encode; -use util::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider}; -use util::ser::{ReadableArgs, Writeable, Writer}; -use util::{byte_utils, test_utils}; -use util::config::{UserConfig, ChannelConfig}; -use util::errors::APIError; +use crate::chain::channelmonitor::{ChannelMonitor, CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS}; +use crate::chain::keysinterface::{KeysInterface, Recipient}; +use crate::ln::{PaymentHash, PaymentSecret}; +use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS; +use crate::ln::channelmanager::{self, ChannelManager, ChannelManagerReadArgs, HTLCForwardInfo, CLTV_FAR_FAR_AWAY, MIN_CLTV_EXPIRY_DELTA, PendingHTLCInfo, PendingHTLCRouting}; +use crate::ln::onion_utils; +use crate::routing::gossip::{NetworkUpdate, RoutingFees, NodeId}; +use crate::routing::router::{get_route, PaymentParameters, Route, RouteHint, RouteHintHop}; +use crate::ln::features::{InitFeatures, InvoiceFeatures, NodeFeatures}; +use crate::ln::msgs; +use crate::ln::msgs::{ChannelMessageHandler, ChannelUpdate}; +use crate::ln::wire::Encode; +use crate::util::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider}; +use crate::util::ser::{ReadableArgs, Writeable, Writer}; +use crate::util::{byte_utils, test_utils}; +use crate::util::config::{UserConfig, ChannelConfig}; +use crate::util::errors::APIError; use bitcoin::hash_types::BlockHash; @@ -38,11 +38,11 @@ use bitcoin::secp256k1; use bitcoin::secp256k1::Secp256k1; use bitcoin::secp256k1::{PublicKey, SecretKey}; -use io; -use prelude::*; +use crate::io; +use crate::prelude::*; use core::default::Default; -use ln::functional_test_utils::*; +use crate::ln::functional_test_utils::*; fn run_onion_failure_test(_name: &str, test_case: u8, nodes: &Vec, route: &Route, payment_hash: &PaymentHash, payment_secret: &PaymentSecret, callback_msg: F1, callback_node: F2, expected_retryable: bool, expected_error_code: Option, expected_channel_update: Option, expected_short_channel_id: Option) where F1: for <'a> FnMut(&'a mut msgs::UpdateAddHTLC), @@ -540,7 +540,7 @@ fn test_onion_failure() { }, || {}, true, Some(17), None, None); run_onion_failure_test("final_incorrect_cltv_expiry", 1, &nodes, &route, &payment_hash, &payment_secret, |_| {}, || { - for (_, pending_forwards) in nodes[1].node.channel_state.lock().unwrap().forward_htlcs.iter_mut() { + for (_, pending_forwards) in nodes[1].node.forward_htlcs.lock().unwrap().iter_mut() { for f in pending_forwards.iter_mut() { match f { &mut HTLCForwardInfo::AddHTLC { ref mut forward_info, .. } => @@ -553,7 +553,7 @@ fn test_onion_failure() { run_onion_failure_test("final_incorrect_htlc_amount", 1, &nodes, &route, &payment_hash, &payment_secret, |_| {}, || { // violate amt_to_forward > msg.amount_msat - for (_, pending_forwards) in nodes[1].node.channel_state.lock().unwrap().forward_htlcs.iter_mut() { + for (_, pending_forwards) in nodes[1].node.forward_htlcs.lock().unwrap().iter_mut() { for f in pending_forwards.iter_mut() { match f { &mut HTLCForwardInfo::AddHTLC { ref mut forward_info, .. } => @@ -1021,8 +1021,8 @@ fn test_phantom_onion_hmac_failure() { // Modify the payload so the phantom hop's HMAC is bogus. let sha256_of_onion = { - let mut channel_state = nodes[1].node.channel_state.lock().unwrap(); - let mut pending_forward = channel_state.forward_htlcs.get_mut(&phantom_scid).unwrap(); + let mut forward_htlcs = nodes[1].node.forward_htlcs.lock().unwrap(); + let mut pending_forward = forward_htlcs.get_mut(&phantom_scid).unwrap(); match pending_forward[0] { HTLCForwardInfo::AddHTLC { forward_info: PendingHTLCInfo { @@ -1081,7 +1081,7 @@ fn test_phantom_invalid_onion_payload() { commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true); // Modify the onion packet to have an invalid payment amount. - for (_, pending_forwards) in nodes[1].node.channel_state.lock().unwrap().forward_htlcs.iter_mut() { + for (_, pending_forwards) in nodes[1].node.forward_htlcs.lock().unwrap().iter_mut() { for f in pending_forwards.iter_mut() { match f { &mut HTLCForwardInfo::AddHTLC { @@ -1152,7 +1152,7 @@ fn test_phantom_final_incorrect_cltv_expiry() { commitment_signed_dance!(nodes[1], nodes[0], &update_0.commitment_signed, false, true); // Modify the payload so the phantom hop's HMAC is bogus. - for (_, pending_forwards) in nodes[1].node.channel_state.lock().unwrap().forward_htlcs.iter_mut() { + for (_, pending_forwards) in nodes[1].node.forward_htlcs.lock().unwrap().iter_mut() { for f in pending_forwards.iter_mut() { match f { &mut HTLCForwardInfo::AddHTLC {