diff --git a/channeldb/invoice_test.go b/channeldb/invoice_test.go index 8f5746c8..b29102fb 100644 --- a/channeldb/invoice_test.go +++ b/channeldb/invoice_test.go @@ -12,14 +12,15 @@ import ( ) func randInvoice(value lnwire.MilliSatoshi) (*Invoice, error) { - var pre [32]byte if _, err := rand.Read(pre[:]); err != nil { return nil, err } i := &Invoice{ - CreationDate: time.Now(), + // Use single second precision to avoid false positive test + // failures due to the monotonic time component. + CreationDate: time.Unix(time.Now().Unix(), 0), Terms: ContractTerm{ PaymentPreimage: pre, Value: value, @@ -43,7 +44,9 @@ func TestInvoiceWorkflow(t *testing.T) { // Create a fake invoice which we'll use several times in the tests // below. fakeInvoice := &Invoice{ - CreationDate: time.Now(), + // Use single second precision to avoid false positive test + // failures due to the monotonic time component. + CreationDate: time.Unix(time.Now().Unix(), 0), } fakeInvoice.Memo = []byte("memo") fakeInvoice.Receipt = []byte("recipt") diff --git a/channeldb/payments_test.go b/channeldb/payments_test.go index 78baa052..f84572c2 100644 --- a/channeldb/payments_test.go +++ b/channeldb/payments_test.go @@ -15,7 +15,9 @@ import ( func makeFakePayment() *OutgoingPayment { fakeInvoice := &Invoice{ - CreationDate: time.Now(), + // Use single second precision to avoid false positive test + // failures due to the monotonic time component. + CreationDate: time.Unix(time.Now().Unix(), 0), Memo: []byte("fake memo"), Receipt: []byte("fake receipt"), } @@ -52,7 +54,9 @@ func randomBytes(minLen, maxLen int) ([]byte, error) { func makeRandomFakePayment() (*OutgoingPayment, error) { var err error fakeInvoice := &Invoice{ - CreationDate: time.Now(), + // Use single second precision to avoid false positive test + // failures due to the monotonic time component. + CreationDate: time.Unix(time.Now().Unix(), 0), } fakeInvoice.Memo, err = randomBytes(1, 50)