channeldb: export now function
To allow mocking when testing other packages.
This commit is contained in:
parent
1371e5affc
commit
e234f88b82
@ -137,7 +137,8 @@ type DB struct {
|
||||
*bbolt.DB
|
||||
dbPath string
|
||||
graph *ChannelGraph
|
||||
now func() time.Time
|
||||
|
||||
Now func() time.Time
|
||||
}
|
||||
|
||||
// Open opens an existing channeldb. Any necessary schemas migrations due to
|
||||
@ -171,7 +172,7 @@ func Open(dbPath string, modifiers ...OptionModifier) (*DB, error) {
|
||||
chanDB := &DB{
|
||||
DB: bdb,
|
||||
dbPath: dbPath,
|
||||
now: time.Now,
|
||||
Now: time.Now,
|
||||
}
|
||||
chanDB.graph = newChannelGraph(
|
||||
chanDB, opts.RejectCacheSize, opts.ChannelCacheSize,
|
||||
|
@ -337,7 +337,7 @@ func TestDuplicateSettleInvoice(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to make test db: %v", err)
|
||||
}
|
||||
db.now = func() time.Time { return time.Unix(1, 0) }
|
||||
db.Now = func() time.Time { return time.Unix(1, 0) }
|
||||
|
||||
// We'll start out by creating an invoice and writing it to the DB.
|
||||
amt := lnwire.NewMSatFromSatoshis(1000)
|
||||
|
@ -1244,7 +1244,7 @@ func (d *DB) updateInvoice(hash lntypes.Hash, invoices, settleIndex *bbolt.Bucke
|
||||
// Update invoice state.
|
||||
invoice.State = update.State
|
||||
|
||||
now := d.now()
|
||||
now := d.Now()
|
||||
|
||||
// Update htlc set.
|
||||
for key, htlcUpdate := range update.Htlcs {
|
||||
|
Loading…
Reference in New Issue
Block a user