From b9f09a666d50b06c25648bc2317f9a94dfe7cc4c Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 22 Feb 2018 11:14:41 +0100 Subject: [PATCH] lnd test: calculate channel reserve based on balance before fees --- lnd_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lnd_test.go b/lnd_test.go index 2fa4ee8c..28406603 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -4635,8 +4635,9 @@ func testAsyncPayments(net *lntest.NetworkHarness, t *harnessTest) { // amount of payments, between Alice and Bob, at the end of the test // Alice should send all money from her side to Bob. ctxt, _ := context.WithTimeout(ctxb, timeout) + channelCapacity := btcutil.Amount(paymentAmt * 2000) chanPoint := openChannelAndAssert(ctxt, t, net, net.Alice, net.Bob, - paymentAmt*2000, 0) + channelCapacity, 0) info, err := getChanInfo(net.Alice) if err != nil { @@ -4645,8 +4646,10 @@ func testAsyncPayments(net *lntest.NetworkHarness, t *harnessTest) { // Calculate the number of invoices. We will deplete the channel // all the way down to the channel reserve. - chanReserve := info.LocalBalance / 100 - numInvoices := int((info.LocalBalance - chanReserve) / paymentAmt) + chanReserve := channelCapacity / 100 + availableBalance := btcutil.Amount(info.LocalBalance) - chanReserve + numInvoices := int(availableBalance / paymentAmt) + bobAmt := int64(numInvoices * paymentAmt) aliceAmt := info.LocalBalance - bobAmt