Skip to content

Commit 5dc724f

Browse files
committed
Drop new test Node field introduced in 8ce2223
8ce2223 introduced a new field in the "Node" objects used in our functional tests - the node_id. Its not a bad idea to cache it, but unless we want to commit and use it everywhere, we should avoid duplicating data, especially in tests where we'd rather exercise the underlying code than bypass it.
1 parent 07a7e34 commit 5dc724f

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
44
use chain::chaininterface;
55
use chain::transaction::OutPoint;
6-
use chain::keysinterface::KeysInterface;
76
use ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentPreimage, PaymentHash, PaymentSecret, PaymentSendFailure};
87
use ln::channelmonitor::{ChannelMonitor, ManyChannelMonitor};
98
use routing::router::{Route, get_route};
@@ -29,7 +28,6 @@ use bitcoin::hashes::sha256::Hash as Sha256;
2928
use bitcoin::hashes::Hash;
3029
use bitcoin::hash_types::BlockHash;
3130

32-
use bitcoin::secp256k1::Secp256k1;
3331
use bitcoin::secp256k1::key::PublicKey;
3432

3533
use rand::{thread_rng,Rng};
@@ -84,7 +82,6 @@ pub struct Node<'a, 'b: 'a, 'c: 'b> {
8482
pub keys_manager: &'b test_utils::TestKeysInterface,
8583
pub node: &'a ChannelManager<EnforcingChannelKeys, &'b TestChannelMonitor<'c>, &'c test_utils::TestBroadcaster, &'b test_utils::TestKeysInterface, &'c test_utils::TestFeeEstimator>,
8684
pub net_graph_msg_handler: NetGraphMsgHandler,
87-
pub our_node_id: PublicKey,
8885
pub node_seed: [u8; 32],
8986
pub network_payment_count: Rc<RefCell<u8>>,
9087
pub network_chan_count: Rc<RefCell<u32>>,
@@ -955,7 +952,7 @@ pub const TEST_FINAL_CLTV: u32 = 32;
955952
pub fn route_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route: &[&Node<'a, 'b, 'c>], recv_value: u64) -> (PaymentPreimage, PaymentHash) {
956953
let net_graph_msg_handler = &origin_node.net_graph_msg_handler;
957954
let logger = Arc::new(test_utils::TestLogger::new());
958-
let route = get_route(&origin_node.our_node_id, net_graph_msg_handler, &expected_route.last().unwrap().node.get_our_node_id(), None, &Vec::new(), recv_value, TEST_FINAL_CLTV, logger.clone()).unwrap();
955+
let route = get_route(&origin_node.node.get_our_node_id(), net_graph_msg_handler, &expected_route.last().unwrap().node.get_our_node_id(), None, &Vec::new(), recv_value, TEST_FINAL_CLTV, logger.clone()).unwrap();
959956
assert_eq!(route.paths.len(), 1);
960957
assert_eq!(route.paths[0].len(), expected_route.len());
961958
for (node, hop) in expected_route.iter().zip(route.paths[0].iter()) {
@@ -968,7 +965,7 @@ pub fn route_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route:
968965
pub fn route_over_limit<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route: &[&Node<'a, 'b, 'c>], recv_value: u64) {
969966
let logger = Arc::new(test_utils::TestLogger::new());
970967
let net_graph_msg_handler = &origin_node.net_graph_msg_handler;
971-
let route = get_route(&origin_node.our_node_id, net_graph_msg_handler, &expected_route.last().unwrap().node.get_our_node_id(), None, &Vec::new(), recv_value, TEST_FINAL_CLTV, logger.clone()).unwrap();
968+
let route = get_route(&origin_node.node.get_our_node_id(), net_graph_msg_handler, &expected_route.last().unwrap().node.get_our_node_id(), None, &Vec::new(), recv_value, TEST_FINAL_CLTV, logger.clone()).unwrap();
972969
assert_eq!(route.paths.len(), 1);
973970
assert_eq!(route.paths[0].len(), expected_route.len());
974971
for (node, hop) in expected_route.iter().zip(route.paths[0].iter()) {
@@ -1101,7 +1098,6 @@ pub fn create_node_chanmgrs<'a, 'b>(node_count: usize, cfgs: &'a Vec<NodeCfg<'b>
11011098
}
11021099

11031100
pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec<NodeCfg<'c>>, chan_mgrs: &'a Vec<ChannelManager<EnforcingChannelKeys, &'b TestChannelMonitor<'c>, &'c test_utils::TestBroadcaster, &'b test_utils::TestKeysInterface, &'c test_utils::TestFeeEstimator>>) -> Vec<Node<'a, 'b, 'c>> {
1104-
let secp_ctx = Secp256k1::new();
11051101
let mut nodes = Vec::new();
11061102
let chan_count = Rc::new(RefCell::new(0));
11071103
let payment_count = Rc::new(RefCell::new(0));
@@ -1112,11 +1108,10 @@ pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec<NodeC
11121108
block_notifier.register_listener(&chan_mgrs[i] as &chaininterface::ChainListener);
11131109
let net_graph_msg_handler = NetGraphMsgHandler::new(cfgs[i].chain_monitor.clone(), cfgs[i].logger.clone() as Arc<Logger>);
11141110
nodes.push(Node{ chain_monitor: cfgs[i].chain_monitor.clone(), block_notifier,
1115-
tx_broadcaster: cfgs[i].tx_broadcaster, chan_monitor: &cfgs[i].chan_monitor,
1116-
keys_manager: &cfgs[i].keys_manager, node: &chan_mgrs[i], net_graph_msg_handler,
1117-
node_seed: cfgs[i].node_seed, network_chan_count: chan_count.clone(),
1118-
network_payment_count: payment_count.clone(), logger: cfgs[i].logger.clone(),
1119-
our_node_id: PublicKey::from_secret_key(&secp_ctx, &cfgs[i].keys_manager.get_node_secret()),
1111+
tx_broadcaster: cfgs[i].tx_broadcaster, chan_monitor: &cfgs[i].chan_monitor,
1112+
keys_manager: &cfgs[i].keys_manager, node: &chan_mgrs[i], net_graph_msg_handler,
1113+
node_seed: cfgs[i].node_seed, network_chan_count: chan_count.clone(),
1114+
network_payment_count: payment_count.clone(), logger: cfgs[i].logger.clone(),
11201115
})
11211116
}
11221117

0 commit comments

Comments
 (0)