attempt EnsureNewLightningInvoiceOnPartialPayment test fix

This commit is contained in:
Kukks 2021-08-23 12:34:36 +02:00
parent d1ea4e4fa4
commit 119ab7b2c0
2 changed files with 5 additions and 5 deletions

View File

@ -95,9 +95,9 @@ namespace BTCPayServer.Tests
}
}
public static async Task EventuallyAsync(Func<Task> act)
public static async Task EventuallyAsync(Func<Task> 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);
}
}
}

View File

@ -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<InvoiceDataChangedEvent>(async () =>