mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
instantout/reservation: fix data race in test
This commit is contained in:
parent
4c292f179f
commit
ce77fcc12c
1 changed files with 7 additions and 5 deletions
|
|
@ -3,6 +3,7 @@ package reservation
|
|||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -72,13 +73,14 @@ func TestManager(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
// We'll now expect a spend registration.
|
||||
spendReg := <-testContext.mockLnd.RegisterSpendChannel
|
||||
require.Equal(t, spendReg.PkScript, pkScript)
|
||||
var spendReg atomic.Pointer[test.SpendRegistration]
|
||||
spendReg.Store(<-testContext.mockLnd.RegisterSpendChannel)
|
||||
require.Equal(t, spendReg.Load().PkScript, pkScript)
|
||||
|
||||
go func() {
|
||||
// We'll expect a second spend registration.
|
||||
spendReg = <-testContext.mockLnd.RegisterSpendChannel
|
||||
require.Equal(t, spendReg.PkScript, pkScript)
|
||||
spendReg.Store(<-testContext.mockLnd.RegisterSpendChannel)
|
||||
require.Equal(t, spendReg.Load().PkScript, pkScript)
|
||||
}()
|
||||
|
||||
// We'll now try to lock the reservation.
|
||||
|
|
@ -90,7 +92,7 @@ func TestManager(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
|
||||
testContext.mockLnd.SpendChannel <- &chainntnfs.SpendDetail{
|
||||
SpentOutPoint: spendReg.Outpoint,
|
||||
SpentOutPoint: spendReg.Load().Outpoint,
|
||||
}
|
||||
|
||||
// We'll now expect the reservation to be expired.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue