mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-05 07:37:14 +00:00
rpc: use shorter path names for tests (#6602)
This commit is contained in:
@@ -23,7 +23,7 @@ import (
|
||||
func ExampleClient_Update() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
conf := rpctest.CreateConfig()
|
||||
conf := rpctest.CreateConfig("ExampleClient_Update")
|
||||
|
||||
// Start a test application
|
||||
app := kvstore.NewApplication()
|
||||
@@ -100,7 +100,7 @@ func ExampleClient_Update() {
|
||||
func ExampleClient_VerifyLightBlockAtHeight() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
conf := rpctest.CreateConfig()
|
||||
conf := rpctest.CreateConfig("ExampleClient_VerifyLightBlockAtHeight")
|
||||
|
||||
// Start a test application
|
||||
app := kvstore.NewApplication()
|
||||
|
||||
@@ -40,7 +40,7 @@ func NodeSuite(t *testing.T) (service.Service, *config.Config) {
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
conf := rpctest.CreateConfig()
|
||||
conf := rpctest.CreateConfig(t.Name())
|
||||
|
||||
// start a tendermint node in the background to test against
|
||||
app := kvstore.NewApplication()
|
||||
|
||||
@@ -18,7 +18,7 @@ func ExampleHTTP_simple() {
|
||||
|
||||
// Start a tendermint node (and kvstore) in the background to test against
|
||||
app := kvstore.NewApplication()
|
||||
conf := rpctest.CreateConfig()
|
||||
conf := rpctest.CreateConfig("ExampleHTTP_simple")
|
||||
|
||||
_, closer, err := rpctest.StartTendermint(ctx, conf, app, rpctest.SuppressStdout)
|
||||
if err != nil {
|
||||
@@ -79,7 +79,7 @@ func ExampleHTTP_batching() {
|
||||
|
||||
// Start a tendermint node (and kvstore) in the background to test against
|
||||
app := kvstore.NewApplication()
|
||||
conf := rpctest.CreateConfig()
|
||||
conf := rpctest.CreateConfig("ExampleHTTP_batching")
|
||||
|
||||
_, closer, err := rpctest.StartTendermint(ctx, conf, app, rpctest.SuppressStdout)
|
||||
if err != nil {
|
||||
|
||||
@@ -19,7 +19,7 @@ func NodeSuite(t *testing.T) (service.Service, *config.Config) {
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
conf := rpctest.CreateConfig()
|
||||
conf := rpctest.CreateConfig(t.Name())
|
||||
|
||||
// start a tendermint node in the background to test against
|
||||
dir, err := ioutil.TempDir("/tmp", fmt.Sprint("rpc-client-test-", t.Name()))
|
||||
|
||||
@@ -18,7 +18,7 @@ func NodeSuite(t *testing.T) (service.Service, *config.Config) {
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
conf := rpctest.CreateConfig()
|
||||
conf := rpctest.CreateConfig(t.Name())
|
||||
|
||||
// start a tendermint node in the background to test against
|
||||
app := kvstore.NewApplication()
|
||||
|
||||
+2
-17
@@ -4,8 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
@@ -54,18 +52,6 @@ func waitForGRPC(ctx context.Context, conf *cfg.Config) {
|
||||
}
|
||||
}
|
||||
|
||||
// f**ing long, but unique for each test
|
||||
func makePathname() string {
|
||||
// get path
|
||||
p, err := os.Getwd()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// fmt.Println(p)
|
||||
sep := string(filepath.Separator)
|
||||
return strings.ReplaceAll(p, sep, "_")
|
||||
}
|
||||
|
||||
func randPort() int {
|
||||
port, err := tmnet.GetFreePort()
|
||||
if err != nil {
|
||||
@@ -80,9 +66,8 @@ func makeAddrs() (string, string, string) {
|
||||
fmt.Sprintf("tcp://127.0.0.1:%d", randPort())
|
||||
}
|
||||
|
||||
func CreateConfig() *cfg.Config {
|
||||
pathname := makePathname()
|
||||
c := cfg.ResetTestRoot(pathname)
|
||||
func CreateConfig(testName string) *cfg.Config {
|
||||
c := cfg.ResetTestRoot(testName)
|
||||
|
||||
// and we use random ports to run in parallel
|
||||
tm, rpc, grpc := makeAddrs()
|
||||
|
||||
Reference in New Issue
Block a user