From 8775420b01ec49fb73f06b324017696d51c008ce Mon Sep 17 00:00:00 2001 From: joschisan Date: Fri, 6 Dec 2024 10:23:38 +0200 Subject: [PATCH 1/3] fix: check that full balance becomes available to the client --- modules/fedimint-lnv2-tests/src/bin/tests.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/fedimint-lnv2-tests/src/bin/tests.rs b/modules/fedimint-lnv2-tests/src/bin/tests.rs index 6050523fd3a..b25d0671852 100644 --- a/modules/fedimint-lnv2-tests/src/bin/tests.rs +++ b/modules/fedimint-lnv2-tests/src/bin/tests.rs @@ -1,8 +1,11 @@ +use std::time::Duration; + use devimint::devfed::DevJitFed; use devimint::federation::Client; use devimint::version_constants::VERSION_0_5_0_ALPHA; use devimint::{cmd, util}; use fedimint_core::core::OperationId; +use fedimint_core::task::sleep_in_test; use fedimint_lnv2_client::{FinalReceiveOperationState, FinalSendOperationState}; use lightning_invoice::Bolt11Invoice; use substring::Substring; @@ -157,6 +160,8 @@ async fn test_payments(dev_fed: &DevJitFed) -> anyhow::Result<()> { federation.pegin_client(10_000, &client).await?; + assert_eq!(client.balance().await?, 10_000 * 1000); + let gw_lnd = dev_fed.gw_lnd().await?; let gw_ldk = dev_fed .gw_ldk() @@ -260,7 +265,15 @@ async fn test_payments(dev_fed: &DevJitFed) -> anyhow::Result<()> { await_receive_claimed(&client, receive_op).await?; } - info!("Testing LDK Gateway can pay HOLD invoice..."); + while client.balance().await? < 9000 * 1000 { + sleep_in_test( + format!("Waiting for the full balance to become available to the client"), + Duration::from_secs(1), + ) + .await; + } + + info!("Testing Client can pay LND HOLD invoice via LDK Gateway..."); try_join!( test_send( From 09b6fb7b2eae3a7b39dfc3c55831790fe4c5b6a6 Mon Sep 17 00:00:00 2001 From: joschisan Date: Fri, 6 Dec 2024 10:34:47 +0200 Subject: [PATCH 2/3] cleanup: restructure lnv2 tests crate --- modules/fedimint-lnv2-tests/Cargo.toml | 6 +++++- modules/fedimint-lnv2-tests/{src => }/bin/tests.rs | 2 +- scripts/tests/lnv2-module-test.sh | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) rename modules/fedimint-lnv2-tests/{src => }/bin/tests.rs (99%) diff --git a/modules/fedimint-lnv2-tests/Cargo.toml b/modules/fedimint-lnv2-tests/Cargo.toml index 0b6cca6d17a..14be786f3f5 100644 --- a/modules/fedimint-lnv2-tests/Cargo.toml +++ b/modules/fedimint-lnv2-tests/Cargo.toml @@ -3,10 +3,14 @@ name = "fedimint-lnv2-tests" version = { workspace = true } authors = ["The Fedimint Developers"] edition = "2021" -description = "fedimint-ln-tests contains integration tests for the lightning module" +description = "fedimint-lnv2-tests contains integration tests for the lnv2 module" license = "MIT" publish = false +[[bin]] +name = "fedimint-lnv2-devimint-tests" +path = "bin/tests.rs" + [[test]] name = "fedimint_lnv2_tests" path = "tests/tests.rs" diff --git a/modules/fedimint-lnv2-tests/src/bin/tests.rs b/modules/fedimint-lnv2-tests/bin/tests.rs similarity index 99% rename from modules/fedimint-lnv2-tests/src/bin/tests.rs rename to modules/fedimint-lnv2-tests/bin/tests.rs index b25d0671852..d6aaabfae00 100644 --- a/modules/fedimint-lnv2-tests/src/bin/tests.rs +++ b/modules/fedimint-lnv2-tests/bin/tests.rs @@ -267,7 +267,7 @@ async fn test_payments(dev_fed: &DevJitFed) -> anyhow::Result<()> { while client.balance().await? < 9000 * 1000 { sleep_in_test( - format!("Waiting for the full balance to become available to the client"), + "Waiting for the full balance to become available to the client", Duration::from_secs(1), ) .await; diff --git a/scripts/tests/lnv2-module-test.sh b/scripts/tests/lnv2-module-test.sh index 87b670e74f4..63034424997 100755 --- a/scripts/tests/lnv2-module-test.sh +++ b/scripts/tests/lnv2-module-test.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -# Runs a test to determine the latency of certain user actions set -euo pipefail export RUST_LOG="${RUST_LOG:-info}" @@ -8,4 +7,4 @@ source scripts/_common.sh build_workspace add_target_dir_to_path -tests all \ No newline at end of file +fedimint-lnv2-devimint-tests From 134d199a73ea5552ff8dcc22df701feca82e574e Mon Sep 17 00:00:00 2001 From: joschisan Date: Fri, 6 Dec 2024 16:10:23 +0200 Subject: [PATCH 3/3] fix: no custom retry logic --- modules/fedimint-lnv2-tests/bin/tests.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/fedimint-lnv2-tests/bin/tests.rs b/modules/fedimint-lnv2-tests/bin/tests.rs index d6aaabfae00..f784b0b6036 100644 --- a/modules/fedimint-lnv2-tests/bin/tests.rs +++ b/modules/fedimint-lnv2-tests/bin/tests.rs @@ -1,11 +1,10 @@ -use std::time::Duration; - +use anyhow::ensure; use devimint::devfed::DevJitFed; use devimint::federation::Client; use devimint::version_constants::VERSION_0_5_0_ALPHA; use devimint::{cmd, util}; use fedimint_core::core::OperationId; -use fedimint_core::task::sleep_in_test; +use fedimint_core::util::{backoff_util, retry}; use fedimint_lnv2_client::{FinalReceiveOperationState, FinalSendOperationState}; use lightning_invoice::Bolt11Invoice; use substring::Substring; @@ -265,13 +264,16 @@ async fn test_payments(dev_fed: &DevJitFed) -> anyhow::Result<()> { await_receive_claimed(&client, receive_op).await?; } - while client.balance().await? < 9000 * 1000 { - sleep_in_test( - "Waiting for the full balance to become available to the client", - Duration::from_secs(1), - ) - .await; - } + retry( + "Waiting for the full balance to become available to the client".to_string(), + backoff_util::background_backoff(), + || async { + ensure!(client.balance().await? >= 9000 * 1000); + + Ok(()) + }, + ) + .await?; info!("Testing Client can pay LND HOLD invoice via LDK Gateway...");