//! 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;
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<F1,F2>(_name: &str, test_case: u8, nodes: &Vec<Node>, route: &Route, payment_hash: &PaymentHash, payment_secret: &PaymentSecret, callback_msg: F1, callback_node: F2, expected_retryable: bool, expected_error_code: Option<u16>, expected_channel_update: Option<NetworkUpdate>, expected_short_channel_id: Option<u64>)
where F1: for <'a> FnMut(&'a mut msgs::UpdateAddHTLC),
}, || {}, 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, .. } =>
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, .. } =>
// 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 {
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 {
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 {