//! returned errors decode to the correct thing.
use chain::channelmonitor::{CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS};
-use ln::channelmanager::{HTLCForwardInfo, PaymentPreimage, PaymentHash, PaymentSecret};
+use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
+use ln::channelmanager::HTLCForwardInfo;
use ln::onion_utils;
use routing::router::{Route, get_route};
use ln::features::{InitFeatures, InvoiceFeatures};
use bitcoin::secp256k1::Secp256k1;
use bitcoin::secp256k1::key::SecretKey;
-use std::default::Default;
+use core::default::Default;
use std::io;
use ln::functional_test_utils::*;
let logger = test_utils::TestLogger::new();
let route = get_route(&nodes[0].node.get_our_node_id(), &nodes[0].net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), Some(InvoiceFeatures::known()), None, &Vec::new(), 40000, TEST_FINAL_CLTV, &logger).unwrap();
// positve case
- send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 40000, 40_000);
+ send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 40000);
// intermediate node failure
run_onion_failure_test("invalid_realm", 0, &nodes, &route, &payment_hash, &payment_secret, |msg| {
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[1].shared_secret[..], NODE|2, &[0;0]);
}, ||{
- nodes[2].node.fail_htlc_backwards(&payment_hash, &None);
+ nodes[2].node.fail_htlc_backwards(&payment_hash);
}, true, Some(NODE|2), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][1].pubkey, is_permanent: false}));
let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[2]);
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[1].shared_secret[..], PERM|NODE|2, &[0;0]);
}, ||{
- nodes[2].node.fail_htlc_backwards(&payment_hash, &None);
+ nodes[2].node.fail_htlc_backwards(&payment_hash);
}, false, Some(PERM|NODE|2), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][1].pubkey, is_permanent: true}));
let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[2]);
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[0].shared_secret[..], PERM|NODE|3, &[0;0]);
}, ||{
- nodes[2].node.fail_htlc_backwards(&payment_hash, &None);
+ nodes[2].node.fail_htlc_backwards(&payment_hash);
}, true, Some(PERM|NODE|3), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][0].pubkey, is_permanent: true}));
// final node failure
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
msg.reason = onion_utils::build_first_hop_failure_packet(&onion_keys[1].shared_secret[..], PERM|NODE|3, &[0;0]);
}, ||{
- nodes[2].node.fail_htlc_backwards(&payment_hash, &None);
+ nodes[2].node.fail_htlc_backwards(&payment_hash);
}, false, Some(PERM|NODE|3), Some(msgs::HTLCFailChannelUpdate::NodeFailure{node_id: route.paths[0][1].pubkey, is_permanent: true}));
let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[2]);
// Test a positive test-case with one extra msat, meeting the minimum.
bogus_route.paths[0][route_len-1].fee_msat = amt_to_forward + 1;
let (preimage, _, _) = send_along_route(&nodes[0], bogus_route, &[&nodes[1], &nodes[2]], amt_to_forward+1);
- claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], preimage, amt_to_forward+1);
+ claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], preimage);
//TODO: with new config API, we will be able to generate both valid and
//invalid channel_update cases.
}, ||{}, true, Some(UPDATE|14), Some(msgs::HTLCFailChannelUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy()}));
run_onion_failure_test("unknown_payment_hash", 2, &nodes, &route, &payment_hash, &payment_secret, |_| {}, || {
- nodes[2].node.fail_htlc_backwards(&payment_hash, &None);
+ nodes[2].node.fail_htlc_backwards(&payment_hash);
}, false, Some(PERM|15), None);
let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[2]);