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