htlcswitch/link_test: replace mockTicker with ticker.Mock

This commit is contained in:
Conner Fromknecht committed 2018-08-09 02:48:07 -07:00
1 parent e3253a4f3b
commit 2651136806
1 file changed
+13 -10
+13 -10
View File
@@ -28,6 +28,7 @@ import (
"github.com/lightningnetwork/lnd/lnpeer" "github.com/lightningnetwork/lnd/lnpeer"
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/ticker"
) )
const ( const (
@@ -1474,8 +1475,9 @@ func newSingleLinkTestHarness(chanAmt, chanReserve btcutil.Amount) (
return nil, nil, nil, nil, nil, nil, err return nil, nil, nil, nil, nil, nil, err
} }
t := make(chan time.Time) // Instantiate with a long interval, so that we can precisely control
ticker := &mockTicker{t} // the firing via force feeding.
bticker := ticker.MockNew(time.Hour)
aliceCfg := ChannelLinkConfig{ aliceCfg := ChannelLinkConfig{
FwrdingPolicy: globalPolicy, FwrdingPolicy: globalPolicy,
Peer: alicePeer, Peer: alicePeer,
@@ -1497,8 +1499,8 @@ func newSingleLinkTestHarness(chanAmt, chanReserve btcutil.Amount) (
}, },
Registry: invoiceRegistry, Registry: invoiceRegistry,
ChainEvents: &contractcourt.ChainEventSubscription{}, ChainEvents: &contractcourt.ChainEventSubscription{},
BatchTicker: ticker, BatchTicker: bticker,
FwdPkgGCTicker: NewBatchTicker(5 * time.Second), FwdPkgGCTicker: ticker.MockNew(5 * time.Second),
// Make the BatchSize and Min/MaxFeeUpdateTimeout large enough // Make the BatchSize and Min/MaxFeeUpdateTimeout large enough
// to not trigger commit updates automatically during tests. // to not trigger commit updates automatically during tests.
BatchSize: 10000, BatchSize: 10000,
@@ -1528,7 +1530,7 @@ func newSingleLinkTestHarness(chanAmt, chanReserve btcutil.Amount) (
defer bobChannel.Stop() defer bobChannel.Stop()
} }
return aliceLink, bobChannel, t, start, cleanUp, restore, nil return aliceLink, bobChannel, bticker.Force, start, cleanUp, restore, nil
} }
func assertLinkBandwidth(t *testing.T, link ChannelLink, func assertLinkBandwidth(t *testing.T, link ChannelLink,
@@ -3865,8 +3867,9 @@ func restartLink(aliceChannel *lnwallet.LightningChannel, aliceSwitch *Switch,
} }
} }
t := make(chan time.Time) // Instantiate with a long interval, so that we can precisely control
ticker := &mockTicker{t} // the firing via force feeding.
bticker := ticker.MockNew(time.Hour)
aliceCfg := ChannelLinkConfig{ aliceCfg := ChannelLinkConfig{
FwrdingPolicy: globalPolicy, FwrdingPolicy: globalPolicy,
Peer: alicePeer, Peer: alicePeer,
@@ -3888,8 +3891,8 @@ func restartLink(aliceChannel *lnwallet.LightningChannel, aliceSwitch *Switch,
}, },
Registry: invoiceRegistry, Registry: invoiceRegistry,
ChainEvents: &contractcourt.ChainEventSubscription{}, ChainEvents: &contractcourt.ChainEventSubscription{},
BatchTicker: ticker, BatchTicker: bticker,
FwdPkgGCTicker: NewBatchTicker(5 * time.Second), FwdPkgGCTicker: ticker.New(5 * time.Second),
// Make the BatchSize and Min/MaxFeeUpdateTimeout large enough // Make the BatchSize and Min/MaxFeeUpdateTimeout large enough
// to not trigger commit updates automatically during tests. // to not trigger commit updates automatically during tests.
BatchSize: 10000, BatchSize: 10000,
@@ -3920,7 +3923,7 @@ func restartLink(aliceChannel *lnwallet.LightningChannel, aliceSwitch *Switch,
defer aliceLink.Stop() defer aliceLink.Stop()
} }
return aliceLink, t, cleanUp, nil return aliceLink, bticker.Force, cleanUp, nil
} }
// gnerateHtlc generates a simple payment from Bob to Alice. // gnerateHtlc generates a simple payment from Bob to Alice.