add test for multiple subscriptions

This commit is contained in:
Steven Allen 2017-12-05 18:03:03 -08:00
parent dd7efed6ee
commit 76e427fca8

View File

@ -54,6 +54,10 @@ func TestAddrStream(t *testing.T) {
}
}
// start a second stream
ctx2, cancel2 := context.WithCancel(context.Background())
addrch2 := ps.AddrStream(ctx2, pid)
done := make(chan struct{})
go func() {
defer close(done)
@ -83,9 +87,17 @@ func TestAddrStream(t *testing.T) {
}
}
// now cancel it, and add a few more addresses it doesnt hang afterwards
// now cancel it
cancel()
// now check the *second* subscription. We should see 80 addresses.
for i := 0; i < 80; i++ {
<-addrch2
}
cancel2()
// and add a few more addresses it doesnt hang afterwards
for _, a := range addrs[80:] {
ps.AddAddr(pid, a, time.Hour)
}