mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-24 14:22:16 +00:00
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
This commit is contained in:
parent
59cc6d36c9
commit
8283ca7ddb
@ -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
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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…
x
Reference in New Issue
Block a user