lntest/itest: use helper functions in calcStaticFee

This commit is contained in:
Joost Jager 2020-03-27 07:55:13 +01:00
parent 0e8eb40625
commit 7dbb936791
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -43,6 +43,7 @@ import (
"github.com/lightningnetwork/lnd/lntest" "github.com/lightningnetwork/lnd/lntest"
"github.com/lightningnetwork/lnd/lntest/wait" "github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/lntypes" "github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing" "github.com/lightningnetwork/lnd/routing"
) )
@ -607,13 +608,13 @@ func shutdownAndAssert(net *lntest.NetworkHarness, t *harnessTest,
// TODO(bvu): Refactor when dynamic fee estimation is added. // TODO(bvu): Refactor when dynamic fee estimation is added.
// TODO(conner) remove code duplication // TODO(conner) remove code duplication
func calcStaticFee(numHTLCs int) btcutil.Amount { func calcStaticFee(numHTLCs int) btcutil.Amount {
const ( const htlcWeight = input.HTLCWeight
commitWeight = btcutil.Amount(724) var (
htlcWeight = 172 feePerKw = chainfee.SatPerKVByte(50000).FeePerKWeight()
feePerKw = btcutil.Amount(50 * 1000 / 4) commitWeight = input.CommitWeight
) )
return feePerKw * (commitWeight +
btcutil.Amount(htlcWeight*numHTLCs)) / 1000 return feePerKw.FeeForWeight(int64(commitWeight + htlcWeight*numHTLCs))
} }
// completePaymentRequests sends payments from a lightning node to complete all // completePaymentRequests sends payments from a lightning node to complete all