package db import ( "testing" "time" ) func TestVerifyPasswordWaitsForArgonSlot(t *testing.T) { for range cap(argonSlots) { argonSlots <- struct{}{} } done := make(chan bool) go func() { ok, _ := VerifyPassword(npmHash, "testpass123") done <- ok }() select { case <-done: t.Fatal("VerifyPassword ran while every slot was taken") case <-time.After(100 * time.Millisecond): } for range cap(argonSlots) { <-argonSlots } if !<-done { t.Fatal("VerifyPassword rejected the right password") } }