X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Ffunctional_test_utils.rs;h=b803ad1fdbd0b116ee7893f9a52ac45f1919729d;hb=166e0c88e46565d5f65fac83fbb606bbb3414fc3;hp=c3a57791c08b079840ea704989e4d1a616969f32;hpb=d6321e6e11b3e1b11e26617d3bab0b8c21da0b5b;p=rust-lightning diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index c3a57791..b803ad1f 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -10,24 +10,24 @@ //! A bunch of useful utilities for building networks of nodes and exchanging messages between //! nodes for functional tests. -use chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen, Watch, keysinterface::KeysInterface}; -use chain::channelmonitor::ChannelMonitor; -use chain::transaction::OutPoint; -use ln::{PaymentPreimage, PaymentHash, PaymentSecret}; -use ln::channelmanager::{self, ChainParameters, ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentSendFailure, PaymentId, MIN_CLTV_EXPIRY_DELTA}; -use routing::gossip::{P2PGossipSync, NetworkGraph, NetworkUpdate}; -use routing::router::{PaymentParameters, Route, get_route}; -use ln::features::InitFeatures; -use ln::msgs; -use ln::msgs::{ChannelMessageHandler,RoutingMessageHandler}; -use util::enforcing_trait_impls::EnforcingSigner; -use util::scid_utils; -use util::test_utils; -use util::test_utils::{panicking, TestChainMonitor}; -use util::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PaymentPurpose}; -use util::errors::APIError; -use util::config::UserConfig; -use util::ser::{ReadableArgs, Writeable}; +use crate::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen, Watch, keysinterface::KeysInterface}; +use crate::chain::channelmonitor::ChannelMonitor; +use crate::chain::transaction::OutPoint; +use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret}; +use crate::ln::channelmanager::{self, ChainParameters, ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentSendFailure, PaymentId, MIN_CLTV_EXPIRY_DELTA}; +use crate::routing::gossip::{P2PGossipSync, NetworkGraph, NetworkUpdate}; +use crate::routing::router::{PaymentParameters, Route, get_route}; +use crate::ln::features::InitFeatures; +use crate::ln::msgs; +use crate::ln::msgs::{ChannelMessageHandler,RoutingMessageHandler}; +use crate::util::enforcing_trait_impls::EnforcingSigner; +use crate::util::scid_utils; +use crate::util::test_utils; +use crate::util::test_utils::{panicking, TestChainMonitor}; +use crate::util::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PaymentPurpose}; +use crate::util::errors::APIError; +use crate::util::config::UserConfig; +use crate::util::ser::{ReadableArgs, Writeable}; use bitcoin::blockdata::block::{Block, BlockHeader}; use bitcoin::blockdata::constants::genesis_block; @@ -40,11 +40,11 @@ use bitcoin::hashes::Hash as _; use bitcoin::secp256k1::PublicKey; -use io; -use prelude::*; +use crate::io; +use crate::prelude::*; use core::cell::RefCell; use alloc::rc::Rc; -use sync::{Arc, Mutex}; +use crate::sync::{Arc, Mutex}; use core::mem; use core::iter::repeat; use bitcoin::{PackedLockTime, TxMerkleNode}; @@ -1636,7 +1636,8 @@ pub fn expect_payment_failed_conditions<'a, 'b, 'c, 'd, 'e>( } pub fn send_along_route_with_secret<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, route: Route, expected_paths: &[&[&Node<'a, 'b, 'c>]], recv_value: u64, our_payment_hash: PaymentHash, our_payment_secret: PaymentSecret) -> PaymentId { - let payment_id = origin_node.node.send_payment(&route, our_payment_hash, &Some(our_payment_secret)).unwrap(); + let payment_id = PaymentId(origin_node.keys_manager.backing.get_secure_random_bytes()); + origin_node.node.send_payment(&route, our_payment_hash, &Some(our_payment_secret), payment_id).unwrap(); check_added_monitors!(origin_node, expected_paths.len()); pass_along_route(origin_node, expected_paths, recv_value, our_payment_hash, our_payment_secret); payment_id @@ -1883,7 +1884,7 @@ pub fn route_over_limit<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_rou } let (_, our_payment_hash, our_payment_preimage) = get_payment_preimage_hash!(expected_route.last().unwrap()); - unwrap_send_err!(origin_node.node.send_payment(&route, our_payment_hash, &Some(our_payment_preimage)), true, APIError::ChannelUnavailable { ref err }, + unwrap_send_err!(origin_node.node.send_payment(&route, our_payment_hash, &Some(our_payment_preimage), PaymentId(our_payment_hash.0)), true, APIError::ChannelUnavailable { ref err }, assert!(err.contains("Cannot send value that would put us over the max HTLC value in flight our peer will accept"))); }