Revision b467515719e686e4678e6da4e102f32a491b85a0 authored by Ethan Buchman on 10 July 2017, 20:22:09 UTC, committed by GitHub on 10 July 2017, 20:22:09 UTC
2 parent s 7f3c697 + 75df0d9
Raw File
node_test.go
package node

import (
	"testing"
	"time"

	cfg "github.com/tendermint/tendermint/config"
	"github.com/tendermint/tmlibs/log"
)

func TestNodeStartStop(t *testing.T) {
	config := cfg.ResetTestRoot("node_node_test")

	// Create & start node
	n := NewNodeDefault(config, log.TestingLogger())
	n.Start()
	t.Logf("Started node %v", n.sw.NodeInfo())

	// Wait a bit to initialize
	// TODO remove time.Sleep(), make asynchronous.
	time.Sleep(time.Second * 2)

	ch := make(chan struct{}, 1)
	go func() {
		n.Stop()
		ch <- struct{}{}
	}()
	ticker := time.NewTicker(time.Second * 5)
	select {
	case <-ch:
	case <-ticker.C:
		t.Fatal("timed out waiting for shutdown")
	}
}
back to top