From 5f48a55dc3d506476d9048d4ed85d7fcf494a05a Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Thu, 17 Aug 2023 15:07:14 +0200 Subject: [PATCH 1/2] Allow GOSSIP logging feature .. as we restrict it further via the config anyways. --- Cargo.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9a11ea556..ae4a826d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ panic = 'abort' # Abort on panic default = [] [dependencies] -lightning = { version = "0.0.118", features = ["max_level_trace", "std"] } +lightning = { version = "0.0.118", features = ["std"] } lightning-invoice = { version = "0.26.0" } lightning-net-tokio = { version = "0.0.118" } lightning-persister = { version = "0.0.118" } @@ -36,7 +36,7 @@ lightning-background-processor = { version = "0.0.118", features = ["futures"] } lightning-rapid-gossip-sync = { version = "0.0.118" } lightning-transaction-sync = { version = "0.0.118", features = ["esplora-async-https"] } -# lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["max_level_trace", "std"] } +# lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std"] } # lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" } # lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" } # lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" } @@ -44,7 +44,7 @@ lightning-transaction-sync = { version = "0.0.118", features = ["esplora-async-h # lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" } # lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["esplora-async"] } -#lightning = { path = "../rust-lightning/lightning", features = ["max_level_trace", "std"] } +#lightning = { path = "../rust-lightning/lightning", features = ["std"] } #lightning-invoice = { path = "../rust-lightning/lightning-invoice" } #lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" } #lightning-persister = { path = "../rust-lightning/lightning-persister" } @@ -72,8 +72,8 @@ vss-client = "0.1" winapi = { version = "0.3", features = ["winbase"] } [dev-dependencies] -lightning = { version = "0.0.118", features = ["max_level_trace", "std", "_test_utils"] } -#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["max_level_trace", "std", "_test_utils"] } +lightning = { version = "0.0.118", features = ["std", "_test_utils"] } +#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] } electrsd = { version = "0.22.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_23_0"] } electrum-client = "0.12.0" proptest = "1.0.0" From 554a5204d12c292bd39d56333ee9abcc59a965c1 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Thu, 16 Nov 2023 12:16:45 +0100 Subject: [PATCH 2/2] Add `expect_channel_pending_event` and `open_channel` test utils --- src/test/utils.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/src/test/utils.rs b/src/test/utils.rs index 55948d3b1..6b415f9d2 100644 --- a/src/test/utils.rs +++ b/src/test/utils.rs @@ -1,8 +1,9 @@ use crate::builder::NodeBuilder; use crate::io::test_utils::TestSyncStore; -use crate::{Config, Node}; +use crate::{Config, Event, Node}; use lightning::ln::msgs::SocketAddress; use lightning::util::logger::{Level, Logger, Record}; +use lightning::util::persist::KVStore; use bitcoin::{Address, Amount, Network, OutPoint, Txid}; @@ -26,7 +27,7 @@ macro_rules! expect_event { ($node: expr, $event_type: ident) => {{ match $node.wait_next_event() { ref e @ Event::$event_type { .. } => { - println!("{} got event {:?}", std::stringify!($node), e); + println!("{} got event {:?}", $node.node_id(), e); $node.event_handled(); } ref e => { @@ -38,6 +39,24 @@ macro_rules! expect_event { pub(crate) use expect_event; +macro_rules! expect_channel_pending_event { + ($node: expr, $counterparty_node_id: expr) => {{ + match $node.wait_next_event() { + ref e @ Event::ChannelPending { funding_txo, counterparty_node_id, .. } => { + println!("{} got event {:?}", $node.node_id(), e); + assert_eq!(counterparty_node_id, $counterparty_node_id); + $node.event_handled(); + funding_txo + } + ref e => { + panic!("{} got unexpected event!: {:?}", std::stringify!($node), e); + } + } + }}; +} + +pub(crate) use expect_channel_pending_event; + // Copied over from upstream LDK #[allow(dead_code)] pub struct TestLogger { @@ -162,7 +181,7 @@ pub fn random_config() -> Config { println!("Setting random LDK listening addresses: {:?}", rand_listening_addresses); config.listening_addresses = Some(rand_listening_addresses); - config.log_level = Level::Trace; + config.log_level = Level::Gossip; config } @@ -214,6 +233,7 @@ pub(crate) fn setup_node(electrsd: &ElectrsD, config: Config) -> Node( + node_a: &Node, node_b: &Node, funding_amount_sat: u64, announce: bool, + electrsd: &ElectrsD, +) { + node_a + .connect_open_channel( + node_b.node_id(), + node_b.listening_addresses().unwrap().first().unwrap().clone(), + funding_amount_sat, + None, + None, + announce, + ) + .unwrap(); + assert!(node_a.list_peers().iter().find(|c| { c.node_id == node_b.node_id() }).is_some()); + + let funding_txo_a = expect_channel_pending_event!(node_a, node_b.node_id()); + let funding_txo_b = expect_channel_pending_event!(node_b, node_a.node_id()); + assert_eq!(funding_txo_a, funding_txo_b); + wait_for_tx(&electrsd, funding_txo_a.txid); +}