exit the test server after 15 seconds

Signed-off-by: Leo Chen <leo@harmony.one>
pull/82/head
Leo Chen 6 years ago
parent b6c54e8f34
commit 689ef0badc
  1. 9
      node/node_test.go

@ -2,6 +2,7 @@ package node
import ( import (
"fmt" "fmt"
"os"
"testing" "testing"
"time" "time"
@ -139,6 +140,13 @@ func sendPongMessage(leader p2p.Peer) {
fmt.Println("sent pong message ...") fmt.Println("sent pong message ...")
} }
func exitServer() {
fmt.Println("wait 15 seconds to terminate the process ...")
time.Sleep(15 * time.Second)
os.Exit(0)
}
func TestPingPongHandler(test *testing.T) { func TestPingPongHandler(test *testing.T) {
leader := p2p.Peer{Ip: "127.0.0.1", Port: "8881"} leader := p2p.Peer{Ip: "127.0.0.1", Port: "8881"}
validator := p2p.Peer{Ip: "127.0.0.1", Port: "9991"} validator := p2p.Peer{Ip: "127.0.0.1", Port: "9991"}
@ -148,6 +156,7 @@ func TestPingPongHandler(test *testing.T) {
go sendPingMessage(leader) go sendPingMessage(leader)
go sendPongMessage(leader) go sendPongMessage(leader)
go exitServer()
node.StartServer("8881") node.StartServer("8881")
} }

Loading…
Cancel
Save