From 119ab7b2c01aa3446de1751af26996c4f9aadfa9 Mon Sep 17 00:00:00 2001 From: Kukks Date: Mon, 23 Aug 2021 12:34:36 +0200 Subject: [PATCH] attempt EnsureNewLightningInvoiceOnPartialPayment test fix --- BTCPayServer.Tests/TestUtils.cs | 6 +++--- BTCPayServer.Tests/UnitTest1.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/BTCPayServer.Tests/TestUtils.cs b/BTCPayServer.Tests/TestUtils.cs index 82466e84d..e32e690e1 100644 --- a/BTCPayServer.Tests/TestUtils.cs +++ b/BTCPayServer.Tests/TestUtils.cs @@ -95,9 +95,9 @@ namespace BTCPayServer.Tests } } - public static async Task EventuallyAsync(Func act) + public static async Task EventuallyAsync(Func act, int delay = 20000) { - CancellationTokenSource cts = new CancellationTokenSource(20000); + CancellationTokenSource cts = new CancellationTokenSource(delay); while (true) { try @@ -107,7 +107,7 @@ namespace BTCPayServer.Tests } catch (XunitException) when (!cts.Token.IsCancellationRequested) { - await Task.Delay(500); + await Task.Delay(500, cts.Token); } } } diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index c956b5486..844e0a90e 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -1020,16 +1020,16 @@ namespace BTCPayServer.Tests }, e => e.InvoiceId == invoice.Id && e.PaymentMethodId.PaymentType == LightningPaymentType.Instance ); await tester.ExplorerNode.GenerateAsync(1); Invoice newInvoice = null; - await Task.Delay(100); // wait a bit for payment to process before fetching new invoice await TestUtils.EventuallyAsync(async () => { + await Task.Delay(1000); // wait a bit for payment to process before fetching new invoice newInvoice = await user.BitPay.GetInvoiceAsync(invoice.Id); var newBolt11 = newInvoice.CryptoInfo.First(o => o.PaymentUrls.BOLT11 != null).PaymentUrls.BOLT11; var oldBolt11 = invoice.CryptoInfo.First(o => o.PaymentUrls.BOLT11 != null).PaymentUrls.BOLT11; Assert.NotEqual(newBolt11, oldBolt11); Assert.Equal(newInvoice.BtcDue.GetValue(), BOLT11PaymentRequest.Parse(newBolt11, Network.RegTest).MinimumAmount.ToDecimal(LightMoneyUnit.BTC)); - }); + }, 40000); Logs.Tester.LogInformation($"Paying invoice {newInvoice.Id} remaining due amount {newInvoice.BtcDue.GetValue()} via lightning"); var evt = await tester.WaitForEvent(async () =>