tests: bind test servers to 127.0.0.1 (#4322)

This commit is contained in:
Erik Grinaker
2020-01-18 19:01:18 +01:00
committed by GitHub
parent b50cb26664
commit 9cbfe7950d
6 changed files with 12 additions and 12 deletions

View File

@@ -415,8 +415,8 @@ func DefaultRPCConfig() *RPCConfig {
// TestRPCConfig returns a configuration for testing the RPC server
func TestRPCConfig() *RPCConfig {
cfg := DefaultRPCConfig()
cfg.ListenAddress = "tcp://0.0.0.0:36657"
cfg.GRPCListenAddress = "tcp://0.0.0.0:36658"
cfg.ListenAddress = "tcp://127.0.0.1:36657"
cfg.GRPCListenAddress = "tcp://127.0.0.1:36658"
cfg.Unsafe = true
return cfg
}
@@ -584,7 +584,7 @@ func DefaultP2PConfig() *P2PConfig {
// TestP2PConfig returns a configuration for testing the peer-to-peer layer
func TestP2PConfig() *P2PConfig {
cfg := DefaultP2PConfig()
cfg.ListenAddress = "tcp://0.0.0.0:36656"
cfg.ListenAddress = "tcp://127.0.0.1:36656"
cfg.FlushThrottleTimeout = 10 * time.Millisecond
cfg.AllowDuplicateIP = true
return cfg

View File

@@ -125,9 +125,9 @@ func randPort() int {
func makeAddrs() (string, string, string) {
start := randPort()
return fmt.Sprintf("tcp://0.0.0.0:%d", start),
fmt.Sprintf("tcp://0.0.0.0:%d", start+1),
fmt.Sprintf("tcp://0.0.0.0:%d", start+2)
return fmt.Sprintf("tcp://127.0.0.1:%d", start),
fmt.Sprintf("tcp://127.0.0.1:%d", start+1),
fmt.Sprintf("tcp://127.0.0.1:%d", start+2)
}
// getConfig returns a config for test cases

View File

@@ -48,7 +48,7 @@ func NewNetAddress(id ID, addr net.Addr) *NetAddress {
if flag.Lookup("test.v") == nil { // normal run
panic(fmt.Sprintf("Only TCPAddrs are supported. Got: %v", addr))
} else { // in testing
netAddr := NewNetAddressIPPort(net.IP("0.0.0.0"), 0)
netAddr := NewNetAddressIPPort(net.IP("127.0.0.1"), 0)
netAddr.ID = id
return netAddr
}

View File

@@ -28,7 +28,7 @@ import (
// Client and Server should work over tcp or unix sockets
const (
tcpAddr = "tcp://0.0.0.0:47768"
tcpAddr = "tcp://127.0.0.1:47768"
unixSocket = "/tmp/rpc_test.sock"
unixAddr = "unix://" + unixSocket

View File

@@ -37,7 +37,7 @@ func main() {
rpcserver.RegisterRPCFuncs(mux, routes, cdc, logger)
config := rpcserver.DefaultConfig()
listener, err := rpcserver.Listen("0.0.0.0:8008", config)
listener, err := rpcserver.Listen("tcp://127.0.0.1:8008", config)
if err != nil {
tmos.Exit(err.Error())
}

View File

@@ -85,9 +85,9 @@ func randPort() int {
}
func makeAddrs() (string, string, string) {
return fmt.Sprintf("tcp://0.0.0.0:%d", randPort()),
fmt.Sprintf("tcp://0.0.0.0:%d", randPort()),
fmt.Sprintf("tcp://0.0.0.0:%d", randPort())
return fmt.Sprintf("tcp://127.0.0.1:%d", randPort()),
fmt.Sprintf("tcp://127.0.0.1:%d", randPort()),
fmt.Sprintf("tcp://127.0.0.1:%d", randPort())
}
func createConfig() *cfg.Config {