(t *testing.T)
| 221 | } |
| 222 | |
| 223 | func TestClientSubscribe(t *testing.T) { |
| 224 | server := newTestServer("eth", new(NotificationTestService)) |
| 225 | defer server.Stop() |
| 226 | client := DialInProc(server) |
| 227 | defer client.Close() |
| 228 | |
| 229 | nc := make(chan int) |
| 230 | count := 10 |
| 231 | sub, err := client.EthSubscribe(context.Background(), nc, "someSubscription", count, 0) |
| 232 | if err != nil { |
| 233 | t.Fatal("can't subscribe:", err) |
| 234 | } |
| 235 | for i := 0; i < count; i++ { |
| 236 | if val := <-nc; val != i { |
| 237 | t.Fatalf("value mismatch: got %d, want %d", val, i) |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | sub.Unsubscribe() |
| 242 | select { |
| 243 | case v := <-nc: |
| 244 | t.Fatal("received value after unsubscribe:", v) |
| 245 | case err := <-sub.Err(): |
| 246 | if err != nil { |
| 247 | t.Fatalf("Err returned a non-nil error after explicit unsubscribe: %q", err) |
| 248 | } |
| 249 | case <-time.After(1 * time.Second): |
| 250 | t.Fatalf("subscription not closed within 1s after unsubscribe") |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | func TestClientSubscribeCustomNamespace(t *testing.T) { |
| 255 | namespace := "custom" |
nothing calls this directly
no test coverage detected