(t *testing.T)
| 252 | } |
| 253 | |
| 254 | func TestClientSubscribeCustomNamespace(t *testing.T) { |
| 255 | namespace := "custom" |
| 256 | server := newTestServer(namespace, new(NotificationTestService)) |
| 257 | defer server.Stop() |
| 258 | client := DialInProc(server) |
| 259 | defer client.Close() |
| 260 | |
| 261 | nc := make(chan int) |
| 262 | count := 10 |
| 263 | sub, err := client.Subscribe(context.Background(), namespace, nc, "someSubscription", count, 0) |
| 264 | if err != nil { |
| 265 | t.Fatal("can't subscribe:", err) |
| 266 | } |
| 267 | for i := 0; i < count; i++ { |
| 268 | if val := <-nc; val != i { |
| 269 | t.Fatalf("value mismatch: got %d, want %d", val, i) |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | sub.Unsubscribe() |
| 274 | select { |
| 275 | case v := <-nc: |
| 276 | t.Fatal("received value after unsubscribe:", v) |
| 277 | case err := <-sub.Err(): |
| 278 | if err != nil { |
| 279 | t.Fatalf("Err returned a non-nil error after explicit unsubscribe: %q", err) |
| 280 | } |
| 281 | case <-time.After(1 * time.Second): |
| 282 | t.Fatalf("subscription not closed within 1s after unsubscribe") |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | // In this test, the connection drops while EthSubscribe is |
| 287 | // waiting for a response. |
nothing calls this directly
no test coverage detected