fix ghost test

Signed-off-by: Luca Bigliardi <shammash@google.com>
This commit is contained in:
Luca Bigliardi 2021-03-27 15:52:48 +01:00
parent 0ec08d5ea1
commit 2990b5a309

View File

@ -494,18 +494,24 @@ func TestGhostAndIdentify(t *testing.T) {
notifier, _, ctx, cancel, stopWg := makeTestNotifier(t, config) notifier, _, ctx, cancel, stopWg := makeTestNotifier(t, config)
notifier.NickservDelayWait = 0 * time.Second notifier.NickservDelayWait = 0 * time.Second
var testStep, usedNick, unregisteredNickHandler sync.WaitGroup var testStep sync.WaitGroup
// Trigger 433 for first nick // Trigger 433 for first nick when we see the USER command
usedNick.Add(1) userHandler := func(conn *bufio.ReadWriter, line *irc.Line) error {
unregisteredNickHandler.Add(1)
nickHandler := func(conn *bufio.ReadWriter, line *irc.Line) error {
var err error var err error
if line.Args[0] == "foo" { if line.Args[0] == "foo" {
_, err = conn.WriteString(":example.com 433 * foo :nick in use\n") _, err = conn.WriteString(":example.com 433 * foo :nick in use\n")
} }
usedNick.Done() return err
unregisteredNickHandler.Wait() }
server.SetHandler("USER", userHandler)
// Trigger 001 when we see NICK foo^
nickHandler := func(conn *bufio.ReadWriter, line *irc.Line) error {
var err error
if line.Args[0] == "foo^" {
_, err = conn.WriteString(":example.com 001 foo^ :Welcome\n")
}
return err return err
} }
server.SetHandler("NICK", nickHandler) server.SetHandler("NICK", nickHandler)
@ -521,10 +527,6 @@ func TestGhostAndIdentify(t *testing.T) {
testStep.Add(1) testStep.Add(1)
go notifier.Run(ctx, stopWg) go notifier.Run(ctx, stopWg)
usedNick.Wait()
server.SetHandler("NICK", nil)
unregisteredNickHandler.Done()
testStep.Wait() testStep.Wait()
cancel() cancel()