Files
tendermint/rpc/client/main_test.go
Sam Kleinman 61a81279bd abci: make tendermint example+test clients manage a mutex (#7978)
This is the first step in removing the mutex from ABCI applications:
making our test applications hold mutexes, which this does, hopefully
with zero impact. If this lands well, then we can explore deleting the
other mutexes (in the ABCI server and the clients.) While this change
is not user impacting at all, removing the other mutexes *will* be. 

In persuit of this, I've changed the KV app somewhat, to put almost
all of the logic in the base application and make the persistent
application mostly be a wrapper on top of that with a different
storage layer.
2022-02-23 22:39:47 +00:00

38 lines
958 B
Go

package client_test
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/abci/example/kvstore"
"github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/libs/service"
rpctest "github.com/tendermint/tendermint/rpc/test"
)
func NodeSuite(ctx context.Context, t *testing.T, logger log.Logger) (service.Service, *config.Config) {
t.Helper()
ctx, cancel := context.WithCancel(ctx)
conf, err := rpctest.CreateConfig(t, t.Name())
require.NoError(t, err)
app := kvstore.NewApplication()
// start a tendermint node in the background to test against.
node, closer, err := rpctest.StartTendermint(ctx, conf, app, rpctest.SuppressStdout)
require.NoError(t, err)
t.Cleanup(func() {
cancel()
assert.NoError(t, closer(ctx))
assert.NoError(t, app.Close())
node.Wait()
})
return node, conf
}