MCPcopy Create free account
hub / github.com/tendermint/tendermint / TestExample

Function TestExample

libs/pubsub/example_test.go:15–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestExample(t *testing.T) {
16 s := pubsub.NewServer()
17 s.SetLogger(log.TestingLogger())
18
19 require.NoError(t, s.Start())
20
21 t.Cleanup(func() {
22 if err := s.Stop(); err != nil {
23 t.Error(err)
24 }
25 })
26
27 ctx := context.Background()
28
29 subscription, err := s.Subscribe(ctx, "example-client", query.MustCompile("abci.account.name='John'"))
30 require.NoError(t, err)
31
32 events := []abci.Event{
33 {
34 Type: "abci.account",
35 Attributes: []abci.EventAttribute{{Key: "name", Value: "John"}},
36 },
37 }
38 err = s.PublishWithEvents(ctx, "Tombstone", events)
39 require.NoError(t, err)
40
41 assertReceive(t, "Tombstone", subscription.Out())
42}

Callers

nothing calls this directly

Calls 12

SubscribeMethod · 0.95
PublishWithEventsMethod · 0.95
NewServerFunction · 0.92
TestingLoggerFunction · 0.92
MustCompileFunction · 0.92
assertReceiveFunction · 0.85
SetLoggerMethod · 0.65
StartMethod · 0.65
CleanupMethod · 0.65
StopMethod · 0.65
ErrorMethod · 0.65
OutMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…