mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-23 17:51:39 +00:00
.circleci
.github
DOCKER
benchmarks
blockchain
cmd
config
consensus
crypto
docs
evidence
libs
lite
mempool
networks
node
id.go
node.go
node_test.go
wire.go
p2p
privval
proxy
rpc
scripts
state
test
types
version
.editorconfig
.gitignore
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Gopkg.lock
Gopkg.toml
LICENSE
Makefile
README.md
ROADMAP.md
SECURITY.md
Vagrantfile
appveyor.yml
codecov.yml
docker-compose.yml
49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
![]() |
package node
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
|
||
|
"github.com/tendermint/tmlibs/log"
|
||
|
|
||
|
cfg "github.com/tendermint/tendermint/config"
|
||
|
"github.com/tendermint/tendermint/types"
|
||
|
)
|
||
|
|
||
|
func TestNodeStartStop(t *testing.T) {
|
||
|
config := cfg.ResetTestRoot("node_node_test")
|
||
|
|
||
|
// create & start node
|
||
|
n, err := DefaultNewNode(config, log.TestingLogger())
|
||
|
assert.NoError(t, err, "expected no err on DefaultNewNode")
|
||
|
err1 := n.Start()
|
||
|
if err1 != nil {
|
||
|
t.Error(err1)
|
||
|
}
|
||
|
t.Logf("Started node %v", n.sw.NodeInfo())
|
||
|
|
||
|
// wait for the node to produce a block
|
||
|
blockCh := make(chan interface{})
|
||
|
err = n.EventBus().Subscribe(context.Background(), "node_test", types.EventQueryNewBlock, blockCh)
|
||
|
assert.NoError(t, err)
|
||
|
select {
|
||
|
case <-blockCh:
|
||
|
case <-time.After(10 * time.Second):
|
||
|
t.Fatal("timed out waiting for the node to produce a block")
|
||
|
}
|
||
|
|
||
|
// stop the node
|
||
|
go func() {
|
||
|
n.Stop()
|
||
|
}()
|
||
|
|
||
|
select {
|
||
|
case <-n.Quit():
|
||
|
case <-time.After(5 * time.Second):
|
||
|
t.Fatal("timed out waiting for shutdown")
|
||
|
}
|
||
|
}
|