mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
liquidity: add clock for mocking time in tests
This commit is contained in:
parent
7e9034b2ff
commit
ad8b5d0552
4 changed files with 14 additions and 2 deletions
1
go.mod
1
go.mod
|
|
@ -14,6 +14,7 @@ require (
|
|||
github.com/lightninglabs/protobuf-hex-display v1.3.3-0.20191212020323-b444784ce75d
|
||||
github.com/lightningnetwork/lnd v0.11.1-beta.rc3
|
||||
github.com/lightningnetwork/lnd/cert v1.0.3
|
||||
github.com/lightningnetwork/lnd/clock v1.0.1
|
||||
github.com/lightningnetwork/lnd/queue v1.0.4
|
||||
github.com/stretchr/testify v1.5.1
|
||||
github.com/urfave/cli v1.20.0
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightningnetwork/lnd/clock"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
|
|
@ -57,6 +58,9 @@ type Config struct {
|
|||
|
||||
// Lnd provides us with access to lnd's rpc servers.
|
||||
Lnd *lndclient.LndServices
|
||||
|
||||
// Clock allows easy mocking of time in unit tests.
|
||||
Clock clock.Clock
|
||||
}
|
||||
|
||||
// Parameters is a set of parameters provided by the user which guide
|
||||
|
|
|
|||
|
|
@ -3,16 +3,20 @@ package liquidity
|
|||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightninglabs/loop/test"
|
||||
"github.com/lightningnetwork/lnd/clock"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
testTime = time.Date(2020, 02, 13, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
chanID1 = lnwire.NewShortChanIDFromInt(1)
|
||||
chanID2 = lnwire.NewShortChanIDFromInt(2)
|
||||
|
||||
|
|
@ -55,7 +59,8 @@ func newTestConfig() (*Config, *test.LndMockServices) {
|
|||
|
||||
return NewRestrictions(1, 10000), nil
|
||||
},
|
||||
Lnd: &lnd.LndServices,
|
||||
Lnd: &lnd.LndServices,
|
||||
Clock: clock.NewTestClock(testTime),
|
||||
}, lnd
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/lightninglabs/lndclient"
|
||||
"github.com/lightninglabs/loop"
|
||||
"github.com/lightninglabs/loop/liquidity"
|
||||
"github.com/lightningnetwork/lnd/clock"
|
||||
)
|
||||
|
||||
// getClient returns an instance of the swap client.
|
||||
|
|
@ -46,7 +47,8 @@ func getLiquidityManager(client *loop.Client) *liquidity.Manager {
|
|||
outTerms.MinSwapAmount, outTerms.MaxSwapAmount,
|
||||
), nil
|
||||
},
|
||||
Lnd: client.LndServices,
|
||||
Lnd: client.LndServices,
|
||||
Clock: clock.NewDefaultClock(),
|
||||
}
|
||||
|
||||
return liquidity.NewManager(mngrCfg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue