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.

40 lines
1.0 KiB

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