Browse Source

tests: bind test servers to 127.0.0.1 (#4322)

pull/4323/head
Erik Grinaker 4 years ago
committed by GitHub
parent
commit
9cbfe7950d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 12 deletions
  1. +3
    -3
      config/config.go
  2. +3
    -3
      consensus/wal_generator.go
  3. +1
    -1
      p2p/netaddress.go
  4. +1
    -1
      rpc/lib/rpc_test.go
  5. +1
    -1
      rpc/lib/test/main.go
  6. +3
    -3
      rpc/test/helpers.go

+ 3
- 3
config/config.go 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


+ 3
- 3
consensus/wal_generator.go 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


+ 1
- 1
p2p/netaddress.go 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
}


+ 1
- 1
rpc/lib/rpc_test.go 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


+ 1
- 1
rpc/lib/test/main.go 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())
}


+ 3
- 3
rpc/test/helpers.go 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 {


Loading…
Cancel
Save