mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 06:07:16 +01:00
Merge pull request #3797 from joostjager/explicit-now-dependency-channeldb
channeldb: inject clock into database
This commit is contained in:
@@ -317,7 +317,7 @@ func TestCancelInvoice(t *testing.T) {
|
||||
func TestSettleHoldInvoice(t *testing.T) {
|
||||
defer timeout()()
|
||||
|
||||
cdb, cleanup, err := newTestChannelDB()
|
||||
cdb, cleanup, err := newTestChannelDB(clock.NewTestClock(time.Time{}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -497,7 +497,7 @@ func TestSettleHoldInvoice(t *testing.T) {
|
||||
func TestCancelHoldInvoice(t *testing.T) {
|
||||
defer timeout()()
|
||||
|
||||
cdb, cleanup, err := newTestChannelDB()
|
||||
cdb, cleanup, err := newTestChannelDB(clock.NewTestClock(time.Time{}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -798,7 +798,7 @@ func TestMppPayment(t *testing.T) {
|
||||
func TestInvoiceExpiryWithRegistry(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cdb, cleanup, err := newTestChannelDB()
|
||||
cdb, cleanup, err := newTestChannelDB(clock.NewTestClock(time.Time{}))
|
||||
defer cleanup()
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -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