htlcswitch: face race condition in unit tests by returning invoice

In this commit we modify the primary InvoiceRegistry interface within
the package to instead return a direct value for LookupInvoice rather
than a pointer. This fixes an existing race condition wherein a caller
could modify or read the value of the returned invoice.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-11-11 16:09:29 -08:00
1 parent 010815e280
commit b6f64932c2
7 files changed
+23 -14

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@ import (
type InvoiceDatabase interface {
// LookupInvoice attempts to look up an invoice according to it's 32
// byte payment hash.
LookupInvoice(chainhash.Hash) (*channeldb.Invoice, error)
LookupInvoice(chainhash.Hash) (channeldb.Invoice, error)
// SettleInvoice attempts to mark an invoice corresponding to the
// passed payment hash as fully settled.