tendermint/libs/pubsub/example_test.go

28 lines
689 B
Go
Raw Normal View History

package pubsub_test
import (
"context"
"testing"
"github.com/stretchr/testify/require"
2018-07-01 22:36:49 -04:00
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/libs/pubsub"
"github.com/tendermint/tendermint/libs/pubsub/query"
)
func TestExample(t *testing.T) {
s := pubsub.NewServer()
s.SetLogger(log.TestingLogger())
s.Start()
defer s.Stop()
ctx := context.Background()
2019-01-30 14:07:38 +04:00
subscription, err := s.Subscribe(ctx, "example-client", query.MustParse("abci.account.name='John'"))
require.NoError(t, err)
err = s.PublishWithTags(ctx, "Tombstone", map[string]string{"abci.account.name": "John"})
require.NoError(t, err)
2019-01-29 18:46:59 +04:00
assertReceive(t, "Tombstone", subscription.Out())
}