From 774d29d8903da1a8a43102a652ec6861e329ba9d Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Mon, 15 Feb 2021 11:07:10 -0800 Subject: [PATCH] htlcswitch: init mockFeeEstimator in other LinkChannelConfigs If the tests don't execute quick enough, the link will try to sample the network fee and cause a panic. This happens semi-regularly on travis. --- htlcswitch/link_test.go | 2 ++ htlcswitch/mock.go | 7 +++++++ htlcswitch/test_utils.go | 7 +------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index e4ca32db..3c0be785 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -1967,6 +1967,7 @@ func newSingleLinkTestHarness(chanAmt, chanReserve btcutil.Amount) ( return nil }, Registry: invoiceRegistry, + FeeEstimator: newMockFeeEstimator(), ChainEvents: &contractcourt.ChainEventSubscription{}, BatchTicker: bticker, FwdPkgGCTicker: ticker.NewForce(15 * time.Second), @@ -4469,6 +4470,7 @@ func (h *persistentLinkHarness) restartLink( return nil }, Registry: h.coreLink.cfg.Registry, + FeeEstimator: newMockFeeEstimator(), ChainEvents: &contractcourt.ChainEventSubscription{}, BatchTicker: bticker, FwdPkgGCTicker: ticker.New(5 * time.Second), diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index 69277bc3..d3e9167e 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -74,6 +74,13 @@ type mockFeeEstimator struct { quit chan struct{} } +func newMockFeeEstimator() *mockFeeEstimator { + return &mockFeeEstimator{ + byteFeeIn: make(chan chainfee.SatPerKWeight), + quit: make(chan struct{}), + } +} + func (m *mockFeeEstimator) EstimateFeePerKW( numBlocks uint32) (chainfee.SatPerKWeight, error) { diff --git a/htlcswitch/test_utils.go b/htlcswitch/test_utils.go index 18cf3151..a1dd30a3 100644 --- a/htlcswitch/test_utils.go +++ b/htlcswitch/test_utils.go @@ -1098,13 +1098,8 @@ func newHopNetwork() *hopNetwork { } obfuscator := NewMockObfuscator() - feeEstimator := &mockFeeEstimator{ - byteFeeIn: make(chan chainfee.SatPerKWeight), - quit: make(chan struct{}), - } - return &hopNetwork{ - feeEstimator: feeEstimator, + feeEstimator: newMockFeeEstimator(), globalPolicy: globalPolicy, obfuscator: obfuscator, defaultDelta: defaultDelta,