From 7b3042511115775f86d2b34c3ef202996b35bf45 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 13 Feb 2018 15:15:14 +0100 Subject: [PATCH] multi test: update tests/mocks to use EstimateFeePerVSize --- breacharbiter_test.go | 8 ++++---- mock.go | 2 +- peer_test.go | 9 +++++---- test_utils.go | 12 ++++++------ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/breacharbiter_test.go b/breacharbiter_test.go index 7502415a..0fd093ee 100644 --- a/breacharbiter_test.go +++ b/breacharbiter_test.go @@ -1331,18 +1331,18 @@ func createInitChannels(revocationWindow int) (*lnwallet.LightningChannel, *lnwa } estimator := &lnwallet.StaticFeeEstimator{FeeRate: 50} - feePerWeight, err := estimator.EstimateFeePerWeight(1) + feePerVSize, err := estimator.EstimateFeePerVSize(1) if err != nil { return nil, nil, nil, err } - feePerKw := feePerWeight * 1000 + feePerKw := feePerVSize.FeePerKWeight() // TODO(roasbeef): need to factor in commit fee? aliceCommit := channeldb.ChannelCommitment{ CommitHeight: 0, LocalBalance: lnwire.NewMSatFromSatoshis(channelBal), RemoteBalance: lnwire.NewMSatFromSatoshis(channelBal), - FeePerKw: feePerKw, + FeePerKw: btcutil.Amount(feePerKw), CommitFee: 8688, CommitTx: aliceCommitTx, CommitSig: bytes.Repeat([]byte{1}, 71), @@ -1351,7 +1351,7 @@ func createInitChannels(revocationWindow int) (*lnwallet.LightningChannel, *lnwa CommitHeight: 0, LocalBalance: lnwire.NewMSatFromSatoshis(channelBal), RemoteBalance: lnwire.NewMSatFromSatoshis(channelBal), - FeePerKw: feePerKw, + FeePerKw: btcutil.Amount(feePerKw), CommitFee: 8688, CommitTx: bobCommitTx, CommitSig: bytes.Repeat([]byte{1}, 71), diff --git a/mock.go b/mock.go index 25528042..39a2eba2 100644 --- a/mock.go +++ b/mock.go @@ -229,7 +229,7 @@ func (m *mockWalletController) FetchRootKey() (*btcec.PrivateKey, error) { return m.rootKey, nil } func (*mockWalletController) SendOutputs(outputs []*wire.TxOut, - _ btcutil.Amount) (*chainhash.Hash, error) { + _ lnwallet.SatPerVByte) (*chainhash.Hash, error) { return nil, nil } diff --git a/peer_test.go b/peer_test.go index 4e9f93f0..d4a8163a 100644 --- a/peer_test.go +++ b/peer_test.go @@ -170,11 +170,12 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) { } estimator := lnwallet.StaticFeeEstimator{FeeRate: 50} - feeRate, err := estimator.EstimateFeePerWeight(1) + feeRate, err := estimator.EstimateFeePerVSize(1) if err != nil { t.Fatalf("unable to query fee estimator: %v", err) } - fee := btcutil.Amount(responderChan.CalcFee(uint64(feeRate * 1000))) + feePerKw := feeRate.FeePerKWeight() + fee := btcutil.Amount(responderChan.CalcFee(feePerKw)) closeSig, _, _, err := responderChan.CreateCloseProposal(fee, dummyDeliveryScript, initiatorDeliveryScript) if err != nil { @@ -460,12 +461,12 @@ func TestPeerChannelClosureFeeNegotiationsInitiator(t *testing.T) { } estimator := lnwallet.StaticFeeEstimator{FeeRate: 50} - initiatorIdealFeeRate, err := estimator.EstimateFeePerWeight(1) + initiatorIdealFeeRate, err := estimator.EstimateFeePerVSize(1) if err != nil { t.Fatalf("unable to query fee estimator: %v", err) } initiatorIdealFee := responderChan.CalcFee( - uint64(initiatorIdealFeeRate * 1000), + initiatorIdealFeeRate.FeePerKWeight(), ) increasedFee := btcutil.Amount(float64(initiatorIdealFee) * 2.5) closeSig, _, _, err := responderChan.CreateCloseProposal( diff --git a/test_utils.go b/test_utils.go index c5d6bf90..2f279c30 100644 --- a/test_utils.go +++ b/test_utils.go @@ -138,19 +138,19 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, } estimator := &lnwallet.StaticFeeEstimator{FeeRate: 50} - feePerWeight, err := estimator.EstimateFeePerWeight(1) + feePerVSize, err := estimator.EstimateFeePerVSize(1) if err != nil { return nil, nil, nil, nil, err } - feePerKw := feePerWeight * 1000 + feePerKw := feePerVSize.FeePerKWeight() // TODO(roasbeef): need to factor in commit fee? aliceCommit := channeldb.ChannelCommitment{ CommitHeight: 0, LocalBalance: lnwire.NewMSatFromSatoshis(channelBal), RemoteBalance: lnwire.NewMSatFromSatoshis(channelBal), - FeePerKw: feePerKw, - CommitFee: 8688, + FeePerKw: btcutil.Amount(feePerKw), + CommitFee: feePerKw.FeeForWeight(lnwallet.CommitWeight), CommitTx: aliceCommitTx, CommitSig: bytes.Repeat([]byte{1}, 71), } @@ -158,8 +158,8 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, CommitHeight: 0, LocalBalance: lnwire.NewMSatFromSatoshis(channelBal), RemoteBalance: lnwire.NewMSatFromSatoshis(channelBal), - FeePerKw: feePerKw, - CommitFee: 8688, + FeePerKw: btcutil.Amount(feePerKw), + CommitFee: feePerKw.FeeForWeight(lnwallet.CommitWeight), CommitTx: bobCommitTx, CommitSig: bytes.Repeat([]byte{1}, 71), }