Skip to content

Commit

Permalink
lnd testing v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanfeenstra committed Jun 18, 2024
1 parent 87ec0de commit 41ac491
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
35 changes: 29 additions & 6 deletions src/bin/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<()> {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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<Node> = nodes.iter().map(|n| Node::Internal(n.to_owned())).collect();
Stack {
network,
Expand All @@ -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)
==========
Expand Down
5 changes: 1 addition & 4 deletions src/setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
Expand Down

0 comments on commit 41ac491

Please sign in to comment.