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.

37 lines
958 B

  1. package client_test
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. "github.com/stretchr/testify/require"
  7. "github.com/tendermint/tendermint/abci/example/kvstore"
  8. "github.com/tendermint/tendermint/config"
  9. "github.com/tendermint/tendermint/libs/log"
  10. "github.com/tendermint/tendermint/libs/service"
  11. rpctest "github.com/tendermint/tendermint/rpc/test"
  12. )
  13. func NodeSuite(ctx context.Context, t *testing.T, logger log.Logger) (service.Service, *config.Config) {
  14. t.Helper()
  15. ctx, cancel := context.WithCancel(ctx)
  16. conf, err := rpctest.CreateConfig(t, t.Name())
  17. require.NoError(t, err)
  18. app := kvstore.NewApplication()
  19. // start a tendermint node in the background to test against.
  20. node, closer, err := rpctest.StartTendermint(ctx, conf, app, rpctest.SuppressStdout)
  21. require.NoError(t, err)
  22. t.Cleanup(func() {
  23. cancel()
  24. assert.NoError(t, closer(ctx))
  25. assert.NoError(t, app.Close())
  26. node.Wait()
  27. })
  28. return node, conf
  29. }