| 
1 | 1 | #![cfg(test)]  | 
2 | 2 | 
 
  | 
3 |  | -use lightning_liquidity::LiquidityManager;  | 
 | 3 | +use bitcoin::Network;  | 
 | 4 | +use lightning::ln::channelmanager::ChainParameters;  | 
 | 5 | +use lightning_liquidity::{LiquidityClientConfig, LiquidityManager, LiquidityServiceConfig};  | 
4 | 6 | 
 
  | 
5 |  | -use lightning::chain::Filter;  | 
6 |  | -use lightning::ln::channelmanager;  | 
7 |  | -use lightning::util::test_utils;  | 
 | 7 | +use lightning::chain::{BestBlock, Filter};  | 
 | 8 | +use lightning::ln::functional_test_utils::{Node, TestChannelManager};  | 
 | 9 | +use lightning::util::test_utils::TestKeysInterface;  | 
 | 10 | + | 
 | 11 | +use core::ops::Deref;  | 
8 | 12 | 
 
  | 
9 | 13 | use std::sync::Arc;  | 
10 | 14 | 
 
  | 
11 |  | -pub(crate) type TestCM<'a, 'b> = channelmanager::ChannelManager<  | 
12 |  | -	&'a test_utils::TestChainMonitor<'b>,  | 
13 |  | -	&'b test_utils::TestBroadcaster,  | 
14 |  | -	&'a test_utils::TestKeysInterface,  | 
15 |  | -	&'a test_utils::TestKeysInterface,  | 
16 |  | -	&'a test_utils::TestKeysInterface,  | 
17 |  | -	&'b test_utils::TestFeeEstimator,  | 
18 |  | -	&'a test_utils::TestRouter<'b>,  | 
19 |  | -	&'a test_utils::TestMessageRouter<'b>,  | 
20 |  | -	&'b test_utils::TestLogger,  | 
21 |  | ->;  | 
 | 15 | +pub(crate) struct LSPSNodes<'a, 'b, 'c> {  | 
 | 16 | +	pub service_node: LiquidityNode<'a, 'b, 'c>,  | 
 | 17 | +	pub client_node: LiquidityNode<'a, 'b, 'c>,  | 
 | 18 | +}  | 
 | 19 | + | 
 | 20 | +pub(crate) fn create_service_and_client_nodes_with_optional_payer_node<'a, 'b, 'c>(  | 
 | 21 | +	nodes: Vec<Node<'a, 'b, 'c>>, service_config: LiquidityServiceConfig,  | 
 | 22 | +	client_config: LiquidityClientConfig,  | 
 | 23 | +) -> LSPSNodes<'a, 'b, 'c> {  | 
 | 24 | +	let chain_params = ChainParameters {  | 
 | 25 | +		network: Network::Testnet,  | 
 | 26 | +		best_block: BestBlock::from_network(Network::Testnet),  | 
 | 27 | +	};  | 
 | 28 | +	let service_lm = LiquidityManager::new(  | 
 | 29 | +		nodes[0].keys_manager,  | 
 | 30 | +		nodes[0].node,  | 
 | 31 | +		None::<Arc<dyn Filter + Send + Sync>>,  | 
 | 32 | +		Some(chain_params.clone()),  | 
 | 33 | +		Some(service_config),  | 
 | 34 | +		None,  | 
 | 35 | +	);  | 
 | 36 | + | 
 | 37 | +	let client_lm = LiquidityManager::new(  | 
 | 38 | +		nodes[1].keys_manager,  | 
 | 39 | +		nodes[1].node,  | 
 | 40 | +		None::<Arc<dyn Filter + Send + Sync>>,  | 
 | 41 | +		Some(chain_params),  | 
 | 42 | +		None,  | 
 | 43 | +		Some(client_config),  | 
 | 44 | +	);  | 
 | 45 | + | 
 | 46 | +	let mut iter = nodes.into_iter();  | 
 | 47 | +	let service_node = LiquidityNode::new(iter.next().unwrap(), service_lm);  | 
 | 48 | +	let client_node = LiquidityNode::new(iter.next().unwrap(), client_lm);  | 
 | 49 | + | 
 | 50 | +	LSPSNodes { service_node, client_node }  | 
 | 51 | +}  | 
22 | 52 | 
 
  | 
23 | 53 | pub(crate) struct LiquidityNode<'a, 'b, 'c> {  | 
24 |  | -	pub inner: lightning::ln::functional_test_utils::Node<'a, 'b, 'c>,  | 
 | 54 | +	pub inner: Node<'a, 'b, 'c>,  | 
25 | 55 | 	pub liquidity_manager: LiquidityManager<  | 
26 |  | -		&'c test_utils::TestKeysInterface,  | 
27 |  | -		&'a TestCM<'b, 'c>,  | 
 | 56 | +		&'c TestKeysInterface,  | 
 | 57 | +		&'a TestChannelManager<'b, 'c>,  | 
28 | 58 | 		Arc<dyn Filter + Send + Sync>,  | 
29 | 59 | 	>,  | 
30 | 60 | }  | 
31 | 61 | 
 
  | 
32 | 62 | impl<'a, 'b, 'c> LiquidityNode<'a, 'b, 'c> {  | 
33 | 63 | 	pub fn new(  | 
34 |  | -		node: lightning::ln::functional_test_utils::Node<'a, 'b, 'c>,  | 
 | 64 | +		node: Node<'a, 'b, 'c>,  | 
35 | 65 | 		liquidity_manager: LiquidityManager<  | 
36 |  | -			&'c test_utils::TestKeysInterface,  | 
37 |  | -			&'a TestCM<'b, 'c>,  | 
 | 66 | +			&'c TestKeysInterface,  | 
 | 67 | +			&'a TestChannelManager<'b, 'c>,  | 
38 | 68 | 			Arc<dyn Filter + Send + Sync>,  | 
39 | 69 | 		>,  | 
40 | 70 | 	) -> Self {  | 
41 | 71 | 		Self { inner: node, liquidity_manager }  | 
42 | 72 | 	}  | 
43 | 73 | }  | 
44 | 74 | 
 
  | 
45 |  | -impl<'a, 'b, 'c> core::ops::Deref for LiquidityNode<'a, 'b, 'c> {  | 
46 |  | -	type Target = lightning::ln::functional_test_utils::Node<'a, 'b, 'c>;  | 
 | 75 | +impl<'a, 'b, 'c> Deref for LiquidityNode<'a, 'b, 'c> {  | 
 | 76 | +	type Target = Node<'a, 'b, 'c>;  | 
47 | 77 | 	fn deref(&self) -> &Self::Target {  | 
48 | 78 | 		&self.inner  | 
49 | 79 | 	}  | 
 | 
0 commit comments