Browse Source

rpc: use shorter path names for tests (#6602)

pull/6608/head
Sam Kleinman 3 years ago
committed by GitHub
parent
commit
144af9a81a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 24 deletions
  1. +2
    -2
      light/example_test.go
  2. +1
    -1
      light/provider/http/http_test.go
  3. +2
    -2
      rpc/client/examples_test.go
  4. +1
    -1
      rpc/client/main_test.go
  5. +1
    -1
      rpc/grpc/grpc_test.go
  6. +2
    -17
      rpc/test/helpers.go

+ 2
- 2
light/example_test.go View File

@ -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()


+ 1
- 1
light/provider/http/http_test.go View File

@ -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()


+ 2
- 2
rpc/client/examples_test.go View File

@ -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 {


+ 1
- 1
rpc/client/main_test.go View File

@ -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()))


+ 1
- 1
rpc/grpc/grpc_test.go View File

@ -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
rpc/test/helpers.go View File

@ -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()


Loading…
Cancel
Save