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:
7 files changed
+23
-14
No files matched your search
@@ -549,7 +549,7 @@ func (n *threeHopNetwork) makePayment(sendingPeer, receivingPeer Peer,
|
||||
rhash = fastsha256.Sum256(invoice.Terms.PaymentPreimage[:])
|
||||
|
||||
// Check who is last in the route and add invoice to server registry.
|
||||
if err := receiver.registry.AddInvoice(invoice); err != nil {
|
||||
if err := receiver.registry.AddInvoice(*invoice); err != nil {
|
||||
paymentErr <- err
|
||||
return &paymentResponse{
|
||||
rhash: rhash,
|
||||
|
||||
Reference in new issue
Block a user