channeldb: inject clock into database
Use our standard clock mock for database time queries.
This commit is contained in:
7 files changed
+29
-15
No files matched your search
@@ -110,7 +110,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func newTestChannelDB() (*channeldb.DB, func(), error) {
|
||||
func newTestChannelDB(clock clock.Clock) (*channeldb.DB, func(), error) {
|
||||
// First, create a temporary directory to be used for the duration of
|
||||
// this test.
|
||||
tempDirName, err := ioutil.TempDir("", "channeldb")
|
||||
@@ -119,7 +119,9 @@ func newTestChannelDB() (*channeldb.DB, func(), error) {
|
||||
}
|
||||
|
||||
// Next, create channeldb for the first time.
|
||||
cdb, err := channeldb.Open(tempDirName)
|
||||
cdb, err := channeldb.Open(
|
||||
tempDirName, channeldb.OptionClock(clock),
|
||||
)
|
||||
if err != nil {
|
||||
os.RemoveAll(tempDirName)
|
||||
return nil, nil, err
|
||||
@@ -145,11 +147,10 @@ type testContext struct {
|
||||
func newTestContext(t *testing.T) *testContext {
|
||||
clock := clock.NewTestClock(testTime)
|
||||
|
||||
cdb, cleanup, err := newTestChannelDB()
|
||||
cdb, cleanup, err := newTestChannelDB(clock)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cdb.Now = clock.Now
|
||||
|
||||
expiryWatcher := NewInvoiceExpiryWatcher(clock)
|
||||
|
||||
|
||||
Reference in new issue
Block a user