htlcswitch/mailbox: block until mailbox shutdown

Fixes a bug where Stop() wouldn't actually wait for the mailbox to exit.
This commit is contained in:
Conner Fromknecht
2020-04-14 10:48:06 -07:00
parent 5b38ed0b3e
commit f3051efeb3
2 changed files with 63 additions and 6 deletions

View File

@@ -148,6 +148,28 @@ func TestMailBoxCouriers(t *testing.T) {
}
}
// TestMailBoxResetAfterShutdown tests that ResetMessages and ResetPackets
// return ErrMailBoxShuttingDown after the mailbox has been stopped.
func TestMailBoxResetAfterShutdown(t *testing.T) {
t.Parallel()
m := newMemoryMailBox()
m.Start()
// Stop the mailbox, then try to reset the message and packet couriers.
m.Stop()
err := m.ResetMessages()
if err != ErrMailBoxShuttingDown {
t.Fatalf("expected ErrMailBoxShuttingDown, got: %v", err)
}
err = m.ResetPackets()
if err != ErrMailBoxShuttingDown {
t.Fatalf("expected ErrMailBoxShuttingDown, got: %v", err)
}
}
// TestMailOrchestrator asserts that the orchestrator properly buffers packets
// for channels that haven't been made live, such that they are delivered
// immediately after BindLiveShortChanID. It also tests that packets are delivered