mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
reservation: add initchan
This fixes a flake in the unit tests
This commit is contained in:
parent
246becb10a
commit
f2fb722901
3 changed files with 28 additions and 4 deletions
|
|
@ -34,7 +34,9 @@ func NewManager(cfg *Config) *Manager {
|
|||
}
|
||||
|
||||
// Run runs the reservation manager.
|
||||
func (m *Manager) Run(ctx context.Context, height int32) error {
|
||||
func (m *Manager) Run(ctx context.Context, height int32,
|
||||
initChan chan struct{}) error {
|
||||
|
||||
log.Debugf("Starting reservation manager")
|
||||
|
||||
runCtx, cancel := context.WithCancel(ctx)
|
||||
|
|
@ -55,6 +57,9 @@ func (m *Manager) Run(ctx context.Context, height int32) error {
|
|||
|
||||
ntfnChan := m.cfg.NotificationManager.SubscribeReservations(runCtx)
|
||||
|
||||
// Signal that the manager has been initialized.
|
||||
close(initChan)
|
||||
|
||||
for {
|
||||
select {
|
||||
case height := <-newBlockChan:
|
||||
|
|
|
|||
|
|
@ -25,12 +25,16 @@ func TestManager(t *testing.T) {
|
|||
|
||||
testContext := newManagerTestContext(t)
|
||||
|
||||
initChan := make(chan struct{})
|
||||
// Start the manager.
|
||||
go func() {
|
||||
err := testContext.manager.Run(ctxb, testContext.mockLnd.Height)
|
||||
err := testContext.manager.Run(ctxb, testContext.mockLnd.Height, initChan)
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
|
||||
// We'll now wait for the manager to be initialized.
|
||||
<-initChan
|
||||
|
||||
// Create a new reservation.
|
||||
reservationFSM, err := testContext.manager.newReservation(
|
||||
ctxb, uint32(testContext.mockLnd.Height),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue