Skip to content

Commit

Permalink
fix the tests. includes some hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
ebuchman committed Mar 18, 2018
1 parent d807d32 commit 6485213
Show file tree
Hide file tree
Showing 12 changed files with 297 additions and 110 deletions.
1 change: 1 addition & 0 deletions client/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func SignAndBuild(name, passphrase string, msg sdk.Msg, cdc *wire.Codec) ([]byte

// sign and build
bz := signMsg.Bytes()

sig, pubkey, err := keybase.Sign(name, passphrase, bz)
if err != nil {
return nil, err
Expand Down
69 changes: 69 additions & 0 deletions client/lcd/helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package lcd

// NOTE: COPIED VERBATIM FROM tendermint/tendermint/rpc/test/helpers.go

import (
"fmt"
"os"
"path/filepath"
"strings"

cmn "github.com/tendermint/tmlibs/common"

cfg "github.com/tendermint/tendermint/config"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
rpcclient "github.com/tendermint/tendermint/rpc/lib/client"
)

var globalConfig *cfg.Config

func waitForRPC() {
laddr := GetConfig().RPC.ListenAddress
fmt.Println("LADDR", laddr)
client := rpcclient.NewJSONRPCClient(laddr)
result := new(ctypes.ResultStatus)
for {
_, err := client.Call("status", map[string]interface{}{}, result)
if err == nil {
return
}
}
}

// 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.Replace(p, sep, "_", -1)
}

func randPort() int {
return int(cmn.RandUint16()/2 + 10000)
}

func makeAddrs() (string, string, string) {
start := randPort()
return fmt.Sprintf("tcp://0.0.0.0:%d", start),
fmt.Sprintf("tcp://0.0.0.0:%d", start+1),
fmt.Sprintf("tcp://0.0.0.0:%d", start+2)
}

// GetConfig returns a config for the test cases as a singleton
func GetConfig() *cfg.Config {
if globalConfig == nil {
pathname := makePathname()
globalConfig = cfg.ResetTestRoot(pathname)

// and we use random ports to run in parallel
tm, rpc, _ := makeAddrs()
globalConfig.P2P.ListenAddress = tm
globalConfig.RPC.ListenAddress = rpc
globalConfig.TxIndex.IndexTags = "app.creator" // see kvstore application
}
return globalConfig
}
Loading

0 comments on commit 6485213

Please sign in to comment.