You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
714 B

  1. package pubsub_test
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/stretchr/testify/require"
  6. "github.com/tendermint/tendermint/libs/log"
  7. "github.com/tendermint/tendermint/libs/pubsub"
  8. "github.com/tendermint/tendermint/libs/pubsub/query"
  9. )
  10. func TestExample(t *testing.T) {
  11. s := pubsub.NewServer()
  12. s.SetLogger(log.TestingLogger())
  13. s.Start()
  14. defer s.Stop()
  15. ctx := context.Background()
  16. ch := make(chan interface{}, 1)
  17. err := s.Subscribe(ctx, "example-client", query.MustParse("abci.account.name='John'"), ch)
  18. require.NoError(t, err)
  19. err = s.PublishWithTags(ctx, "Tombstone", pubsub.NewTagMap(map[string]string{"abci.account.name": "John"}))
  20. require.NoError(t, err)
  21. assertReceive(t, "Tombstone", ch)
  22. }