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.

39 lines
943 B

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