|
4 | 4 | #![allow(unused_imports)]
|
5 | 5 | #![allow(unused_macros)]
|
6 | 6 |
|
| 7 | +use bitcoin::secp256k1::SecretKey; |
7 | 8 | use lightning::chain::Filter;
|
8 | 9 | use lightning::sign::EntropySource;
|
9 | 10 |
|
@@ -34,6 +35,8 @@ use lightning::util::persist::{
|
34 | 35 | SCORER_PERSISTENCE_SECONDARY_NAMESPACE,
|
35 | 36 | };
|
36 | 37 | use lightning::util::test_utils;
|
| 38 | +use lightning_liquidity::lsps5::client::{LSPS5ClientConfig, LSPS5ClientHandler}; |
| 39 | +use lightning_liquidity::lsps5::service::{LSPS5ServiceConfig, LSPS5ServiceHandler}; |
37 | 40 | use lightning_liquidity::{LiquidityClientConfig, LiquidityManager, LiquidityServiceConfig};
|
38 | 41 | use lightning_persister::fs_store::FilesystemStore;
|
39 | 42 |
|
@@ -684,3 +687,46 @@ fn advance_chain(node: &mut Node, num_blocks: u32) {
|
684 | 687 | }
|
685 | 688 | }
|
686 | 689 | }
|
| 690 | + |
| 691 | +pub fn get_client_and_service() -> ( |
| 692 | + &'static LSPS5ClientHandler<Arc<KeysManager>>, |
| 693 | + &'static LSPS5ServiceHandler, |
| 694 | + bitcoin::secp256k1::PublicKey, |
| 695 | + bitcoin::secp256k1::PublicKey, |
| 696 | + &'static Node, |
| 697 | + &'static Node, |
| 698 | +) { |
| 699 | + let signing_key = SecretKey::from_slice(&[42; 32]).unwrap(); |
| 700 | + let mut lsps5_service_config = LSPS5ServiceConfig::default(); |
| 701 | + lsps5_service_config.signing_key = signing_key; |
| 702 | + let service_config = LiquidityServiceConfig { |
| 703 | + #[cfg(lsps1_service)] |
| 704 | + lsps1_service_config: None, |
| 705 | + lsps2_service_config: None, |
| 706 | + lsps5_service_config: Some(lsps5_service_config), |
| 707 | + advertise_service: true, |
| 708 | + }; |
| 709 | + |
| 710 | + let lsps5_client_config = LSPS5ClientConfig::default(); |
| 711 | + let client_config = LiquidityClientConfig { |
| 712 | + lsps1_client_config: None, |
| 713 | + lsps2_client_config: None, |
| 714 | + lsps5_client_config: Some(lsps5_client_config), |
| 715 | + }; |
| 716 | + |
| 717 | + let (service_node, client_node) = |
| 718 | + create_service_and_client_nodes("webhook_registration_flow", service_config, client_config); |
| 719 | + |
| 720 | + // Leak the nodes to extend their lifetime to 'static since this is test code |
| 721 | + let service_node = Box::leak(Box::new(service_node)); |
| 722 | + let client_node = Box::leak(Box::new(client_node)); |
| 723 | + |
| 724 | + let client_handler = client_node.liquidity_manager.lsps5_client_handler().unwrap(); |
| 725 | + let service_handler = service_node.liquidity_manager.lsps5_service_handler().unwrap(); |
| 726 | + |
| 727 | + let secp = bitcoin::secp256k1::Secp256k1::new(); |
| 728 | + let service_node_id = bitcoin::secp256k1::PublicKey::from_secret_key(&secp, &signing_key); |
| 729 | + let client_node_id = client_node.channel_manager.get_our_node_id(); |
| 730 | + |
| 731 | + (client_handler, service_handler, service_node_id, client_node_id, service_node, client_node) |
| 732 | +} |
0 commit comments