From 41ac491dcca788abd7dbd32d7703c6089872d6d3 Mon Sep 17 00:00:00 2001 From: Evan Feenstra Date: Mon, 17 Jun 2024 20:51:54 -0700 Subject: [PATCH] lnd testing v2 --- src/bin/v1/mod.rs | 35 +++++++++++++++++++++++++++++------ src/setup/mod.rs | 5 +---- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/bin/v1/mod.rs b/src/bin/v1/mod.rs index 73352a0d..3f39c6fc 100644 --- a/src/bin/v1/mod.rs +++ b/src/bin/v1/mod.rs @@ -4,11 +4,11 @@ use sphinx_swarm::config::{Clients, Node, Stack}; use sphinx_swarm::dock::*; use sphinx_swarm::images::cln::ClnPlugin; use sphinx_swarm::images::{ - broker::BrokerImage, btc::BtcImage, cln::ClnImage, mixer::MixerImage, tribes::TribesImage, - Image, + broker::BrokerImage, btc::BtcImage, cln::ClnImage, lnd::LndImage, mixer::MixerImage, + tribes::TribesImage, Image, }; use sphinx_swarm::rocket_utils::CmdRequest; -use sphinx_swarm::setup::{get_pubkey_cln, mine_blocks, setup_cln_chans}; +use sphinx_swarm::setup::{get_pubkey_cln, mine_blocks, setup_cln_chans, setup_lnd_chans}; use sphinx_swarm::utils::domain; use sphinx_swarm::{builder, events, handler, logs, routes}; use std::sync::Arc; @@ -34,6 +34,7 @@ const TRIBES1: &str = "tribes_1"; // const TRIBES2: &str = "tribes_2"; const TRIBES3: &str = "tribes_3"; const JWT_KEY: &str = "f8int45s0pofgtye"; +const LND_1: &str = "lnd_1"; #[rocket::main] pub async fn main() -> Result<()> { @@ -78,11 +79,16 @@ pub async fn main() -> Result<()> { if !skip_setup { sleep(2).await; log::info!("setup now"); - mine_blocks(&mut clients, BTC, 1001).await?; - mine_blocks(&mut clients, BTC, 1001).await?; + mine_blocks(&mut clients, BTC, 500).await?; + mine_blocks(&mut clients, BTC, 500).await?; + mine_blocks(&mut clients, BTC, 500).await?; + mine_blocks(&mut clients, BTC, 500).await?; log::info!("setup chans"); setup_cln_chans(&mut clients, &stack.nodes, CLN1, CLN2, BTC).await?; setup_cln_chans(&mut clients, &stack.nodes, CLN3, CLN2, BTC).await?; + if do_test_lnd() { + setup_lnd_chans(&mut clients, &stack.nodes, CLN1, LND_1, BTC).await?; + } } try_check_2_hops(&mut clients, CLN1, CLN3).await; @@ -224,7 +230,7 @@ fn make_stack() -> Stack { mixer3.set_initial_peers(&format!("{}@{}", mixer2pk, broker2ip)); mixer1.set_initial_peers(&format!("{}@{}", mixer2pk, broker2ip)); - let nodes = vec![ + let mut nodes = vec![ // bitcoin Image::Btc(bitcoind), // 1 @@ -243,6 +249,14 @@ fn make_stack() -> Stack { Image::Tribes(tribes3), ]; + if do_test_lnd() { + let v = "v0.18.0-beta"; + let mut lnd = LndImage::new(LND_1, v, &network, "10012", "9738"); + lnd.http_port = Some("8881".to_string()); + lnd.links(vec![BTC]); + nodes.extend_from_slice(&[Image::Lnd(lnd)]); + } + let ns: Vec = nodes.iter().map(|n| Node::Internal(n.to_owned())).collect(); Stack { network, @@ -255,6 +269,15 @@ fn make_stack() -> Stack { } } +fn do_test_lnd() -> bool { + if let Ok(test_proxy) = std::env::var("TEST_LND") { + if test_proxy == String::from("true") { + return true; + } + } + false +} + /* xlarge (16) ========== diff --git a/src/setup/mod.rs b/src/setup/mod.rs index 97db7e33..566a89a3 100644 --- a/src/setup/mod.rs +++ b/src/setup/mod.rs @@ -52,9 +52,6 @@ pub async fn setup_lnd_chans( recip: &str, btc_name: &str, ) -> Result<()> { - // if !do_test_proxy() { - // return Ok(()); - // } let lnd1_pubkey = get_pubkey_lnd(clients, recip).await?; if let Some(node) = nodes.iter().find(|n| n.name() == recip) { log::info!("LND1 pubkey {}", &lnd1_pubkey); @@ -65,7 +62,7 @@ pub async fn setup_lnd_chans( sleep(1000).await; // keysend send cln_keysend_to(clients, sender, &lnd1_pubkey, 1_000_000, false).await?; - sleep(59000).await; + sleep(9000).await; // keysend receive let cln1_pubkey = get_pubkey_cln(clients, sender).await?; log::info!("lnd send 1");