Browse Source

3291 follow-up (#3323)

* changelog: use issue number instead of PR number

* follow up to #3291

- rpc/test/helpers.go add StopTendermint(node) func
- remove ensureDir(filepath.Dir(walFile), 0700)
- mempool/mempool_test.go add type cleanupFunc func()

* cmd/show_validator: wrap err to make it more clear
pull/3331/head
Anton Kaliaev 6 years ago
committed by GitHub
parent
commit
8283ca7ddb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 45 additions and 35 deletions
  1. +4
    -3
      CHANGELOG_PENDING.md
  2. +2
    -1
      blockchain/store_test.go
  3. +2
    -1
      cmd/tendermint/commands/show_validator.go
  4. +2
    -1
      consensus/common_test.go
  5. +2
    -5
      consensus/replay_test.go
  6. +2
    -4
      lite/client/provider_test.go
  7. +2
    -5
      lite/proxy/query_test.go
  8. +5
    -1
      mempool/mempool_test.go
  9. +5
    -0
      node/node.go
  10. +3
    -5
      rpc/client/main_test.go
  11. +3
    -4
      rpc/grpc/grpc_test.go
  12. +13
    -5
      rpc/test/helpers.go

+ 4
- 3
CHANGELOG_PENDING.md View File

@ -26,9 +26,10 @@ Special thanks to external contributors on this release:
* [consensus] \#3297 Flush WAL on stop to prevent data corruption during
graceful shutdown
- [consensus] \#3310 Reset TriggeredTimeoutPrecommit before starting next height
- [consensus] \#3302 Reset TriggeredTimeoutPrecommit before starting next
height
- [rpc] \#3251 Fix /net_info#peers#remote_ip format. New format spec:
* dotted decimal ("192.0.2.1"), if ip is an IPv4 or IP4-mapped IPv6 address
* IPv6 ("2001:db8::1"), if ip is a valid IPv6 address
* [cmd] \#3314 Return an
error on `show_validator` when the private validator file does not exist
* [cmd] \#3314 Return an error on `show_validator` when the private validator
file does not exist

+ 2
- 1
blockchain/store_test.go View File

@ -22,7 +22,8 @@ import (
tmtime "github.com/tendermint/tendermint/types/time"
)
// A cleanupFunc cleans up any config / test files created for a particular test.
// A cleanupFunc cleans up any config / test files created for a particular
// test.
type cleanupFunc func()
// make a Commit with a single vote containing just the height and a timestamp


+ 2
- 1
cmd/tendermint/commands/show_validator.go View File

@ -3,6 +3,7 @@ package commands
import (
"fmt"
"github.com/pkg/errors"
"github.com/spf13/cobra"
cmn "github.com/tendermint/tendermint/libs/common"
@ -25,7 +26,7 @@ func showValidator(cmd *cobra.Command, args []string) error {
pv := privval.LoadFilePV(keyFilePath, config.PrivValidatorStateFile())
bz, err := cdc.MarshalJSON(pv.GetPubKey())
if err != nil {
return err
return errors.Wrap(err, "failed to marshal private validator pubkey")
}
fmt.Println(string(bz))


+ 2
- 1
consensus/common_test.go View File

@ -37,7 +37,8 @@ const (
testSubscriber = "test-client"
)
// A cleanupFunc cleans up any config / test files created for a particular test.
// A cleanupFunc cleans up any config / test files created for a particular
// test.
type cleanupFunc func()
// genesis, chain_id, priv_val


+ 2
- 5
consensus/replay_test.go View File

@ -8,7 +8,6 @@ import (
"io/ioutil"
"os"
"path"
"path/filepath"
"runtime"
"testing"
"time"
@ -18,17 +17,16 @@ import (
"github.com/tendermint/tendermint/abci/example/kvstore"
abci "github.com/tendermint/tendermint/abci/types"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto"
auto "github.com/tendermint/tendermint/libs/autofile"
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/version"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
"github.com/tendermint/tendermint/version"
)
func TestMain(m *testing.M) {
@ -153,7 +151,6 @@ LOOP:
// clean up WAL file from the previous iteration
walFile := cs.config.WalFile()
ensureDir(filepath.Dir(walFile), 0700)
os.Remove(walFile)
// set crashing WAL


+ 2
- 4
lite/client/provider_test.go View File

@ -15,13 +15,11 @@ import (
func TestMain(m *testing.M) {
app := kvstore.NewKVStoreApplication()
node, cleanup := rpctest.StartTendermint(app)
defer cleanup()
node := rpctest.StartTendermint(app)
code := m.Run()
node.Stop()
node.Wait()
rpctest.StopTendermint(node)
os.Exit(code)
}


+ 2
- 5
lite/proxy/query_test.go View File

@ -27,15 +27,12 @@ var waitForEventTimeout = 5 * time.Second
// TODO fix tests!!
func TestMain(m *testing.M) {
var cleanup func()
app := kvstore.NewKVStoreApplication()
node, cleanup = rpctest.StartTendermint(app)
node = rpctest.StartTendermint(app)
code := m.Run()
node.Stop()
node.Wait()
cleanup()
rpctest.StopTendermint(node)
os.Exit(code)
}


+ 5
- 1
mempool/mempool_test.go View File

@ -25,7 +25,11 @@ import (
"github.com/tendermint/tendermint/types"
)
func newMempoolWithApp(cc proxy.ClientCreator) (*Mempool, func()) {
// A cleanupFunc cleans up any config / test files created for a particular
// test.
type cleanupFunc func()
func newMempoolWithApp(cc proxy.ClientCreator) (*Mempool, cleanupFunc) {
config := cfg.ResetTestRoot("mempool_test")
appConnMem, _ := cc.NewABCIClient()


+ 5
- 0
node/node.go View File

@ -793,6 +793,11 @@ func (n *Node) ProxyApp() proxy.AppConns {
return n.proxyApp
}
// Config returns the Node's config.
func (n *Node) Config() *cfg.Config {
return n.config
}
//------------------------------------------------------------------------------
func (n *Node) Listeners() []string {


+ 3
- 5
rpc/client/main_test.go View File

@ -13,14 +13,12 @@ var node *nm.Node
func TestMain(m *testing.M) {
// start a tendermint node (and kvstore) in the background to test against
var cleanup func()
app := kvstore.NewKVStoreApplication()
node, cleanup = rpctest.StartTendermint(app)
node = rpctest.StartTendermint(app)
code := m.Run()
// and shut down proper at the end
node.Stop()
node.Wait()
cleanup()
rpctest.StopTendermint(node)
os.Exit(code)
}

+ 3
- 4
rpc/grpc/grpc_test.go View File

@ -15,13 +15,12 @@ import (
func TestMain(m *testing.M) {
// start a tendermint node in the background to test against
app := kvstore.NewKVStoreApplication()
node, cleanup := rpctest.StartTendermint(app)
node := rpctest.StartTendermint(app)
code := m.Run()
// and shut down proper at the end
node.Stop()
node.Wait()
cleanup()
rpctest.StopTendermint(node)
os.Exit(code)
}


+ 13
- 5
rpc/test/helpers.go View File

@ -100,8 +100,8 @@ func GetGRPCClient() core_grpc.BroadcastAPIClient {
}
// StartTendermint starts a test tendermint server in a go routine and returns when it is initialized
func StartTendermint(app abci.Application) (*nm.Node, func()) {
node, cleanup := NewTendermint(app)
func StartTendermint(app abci.Application) *nm.Node {
node := NewTendermint(app)
err := node.Start()
if err != nil {
panic(err)
@ -113,11 +113,19 @@ func StartTendermint(app abci.Application) (*nm.Node, func()) {
fmt.Println("Tendermint running!")
return node, cleanup
return node
}
// StopTendermint stops a test tendermint server, waits until it's stopped and
// cleans up test/config files.
func StopTendermint(node *nm.Node) {
node.Stop()
node.Wait()
os.RemoveAll(node.Config().RootDir)
}
// NewTendermint creates a new tendermint server and sleeps forever
func NewTendermint(app abci.Application) (*nm.Node, func()) {
func NewTendermint(app abci.Application) *nm.Node {
// Create & start node
config := GetConfig()
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
@ -138,5 +146,5 @@ func NewTendermint(app abci.Application) (*nm.Node, func()) {
if err != nil {
panic(err)
}
return node, func() { os.RemoveAll(config.RootDir) }
return node
}

Loading…
Cancel
Save