mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-05 19:42:13 +00:00
> why we need it? most of our subscribers will be RPC WS subscribers, so if there are too many, nothing wrong with rejecting to subscribe. however, consensus reactor must be the first to subscribe, since its work depends on the pubsub package.
25 lines
590 B
Go
25 lines
590 B
Go
package pubsub_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/tendermint/tmlibs/log"
|
|
"github.com/tendermint/tmlibs/pubsub"
|
|
"github.com/tendermint/tmlibs/pubsub/query"
|
|
)
|
|
|
|
func TestExample(t *testing.T) {
|
|
s := pubsub.NewServer()
|
|
s.SetLogger(log.TestingLogger())
|
|
s.Start()
|
|
defer s.Stop()
|
|
|
|
ch := make(chan interface{}, 1)
|
|
err := s.Subscribe("example-client", query.MustParse("abci.account.name=John"), ch)
|
|
require.NoError(t, err)
|
|
s.PublishWithTags("Tombstone", map[string]interface{}{"abci.account.name": "John"})
|
|
assertReceive(t, "Tombstone", ch)
|
|
}
|