Skip to content

Commit ce77fcc

Browse files
stariushieblmi
authored andcommitted
instantout/reservation: fix data race in test
1 parent 4c292f1 commit ce77fcc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

instantout/reservation/manager_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package reservation
33
import (
44
"context"
55
"encoding/hex"
6+
"sync/atomic"
67
"testing"
78
"time"
89

@@ -72,13 +73,14 @@ func TestManager(t *testing.T) {
7273
require.NoError(t, err)
7374

7475
// We'll now expect a spend registration.
75-
spendReg := <-testContext.mockLnd.RegisterSpendChannel
76-
require.Equal(t, spendReg.PkScript, pkScript)
76+
var spendReg atomic.Pointer[test.SpendRegistration]
77+
spendReg.Store(<-testContext.mockLnd.RegisterSpendChannel)
78+
require.Equal(t, spendReg.Load().PkScript, pkScript)
7779

7880
go func() {
7981
// We'll expect a second spend registration.
80-
spendReg = <-testContext.mockLnd.RegisterSpendChannel
81-
require.Equal(t, spendReg.PkScript, pkScript)
82+
spendReg.Store(<-testContext.mockLnd.RegisterSpendChannel)
83+
require.Equal(t, spendReg.Load().PkScript, pkScript)
8284
}()
8385

8486
// We'll now try to lock the reservation.
@@ -90,7 +92,7 @@ func TestManager(t *testing.T) {
9092
require.Error(t, err)
9193

9294
testContext.mockLnd.SpendChannel <- &chainntnfs.SpendDetail{
93-
SpentOutPoint: spendReg.Outpoint,
95+
SpentOutPoint: spendReg.Load().Outpoint,
9496
}
9597

9698
// We'll now expect the reservation to be expired.

0 commit comments

Comments
 (0)