From 3ad3c1271ee8a7cc7058cac3882e7049c9bd7ca5 Mon Sep 17 00:00:00 2001
From: Silas Davis <silas@monax.io>
Date: Mon, 23 Jul 2018 13:08:32 +0100
Subject: [PATCH] Use Tendermint default address and fix up integration test
 helper to use routable local address

Signed-off-by: Silas Davis <silas@monax.io>
---
 consensus/tendermint/config.go |  9 +++++----
 integration/integration.go     |  1 +
 rpc/config.go                  | 14 ++++++++++----
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/consensus/tendermint/config.go b/consensus/tendermint/config.go
index d736e4ba..92acbf9c 100644
--- a/consensus/tendermint/config.go
+++ b/consensus/tendermint/config.go
@@ -20,10 +20,11 @@ type BurrowTendermintConfig struct {
 }
 
 func DefaultBurrowTendermintConfig() *BurrowTendermintConfig {
-	//tmDefaultConfig := tm_config.DefaultConfig()
+	tmDefaultConfig := tm_config.DefaultConfig()
 	return &BurrowTendermintConfig{
-		ListenAddress:  "tcp://127.0.0.1:26656", //stmDefaultConfig.P2P.ListenAddress,
-		TendermintRoot: ".burrow",
+		ListenAddress:   tmDefaultConfig.P2P.ListenAddress,
+		ExternalAddress: tmDefaultConfig.P2P.ExternalAddress,
+		TendermintRoot:  ".burrow",
 	}
 }
 
@@ -39,7 +40,7 @@ func (btc *BurrowTendermintConfig) TendermintConfig() *tm_config.Config {
 		conf.P2P.Seeds = btc.Seeds
 		conf.P2P.PersistentPeers = btc.PersistentPeers
 		conf.P2P.ListenAddress = btc.ListenAddress
-		conf.P2P.ExternalAddress = btc.ListenAddress
+		conf.P2P.ExternalAddress = btc.ExternalAddress
 		conf.Moniker = btc.Moniker
 		// Unfortunately this stops metrics from being used at all
 		conf.Instrumentation.Prometheus = false
diff --git a/integration/integration.go b/integration/integration.go
index ae3cf0ba..69267521 100644
--- a/integration/integration.go
+++ b/integration/integration.go
@@ -163,6 +163,7 @@ func NewTestConfig(genesisDoc *genesis.GenesisDoc) *config.BurrowConfig {
 	cnf.Tendermint.Moniker = name
 	cnf.Tendermint.TendermintRoot = fmt.Sprintf(".burrow_%s", name)
 	cnf.Tendermint.ListenAddress = GetTCPLocalAddress()
+	cnf.Tendermint.ExternalAddress = cnf.Tendermint.ListenAddress
 	cnf.RPC.GRPC.ListenAddress = GetLocalAddress()
 	cnf.RPC.Metrics.ListenAddress = GetTCPLocalAddress()
 	cnf.RPC.TM.ListenAddress = GetTCPLocalAddress()
diff --git a/rpc/config.go b/rpc/config.go
index 44acb555..23bfbdbb 100644
--- a/rpc/config.go
+++ b/rpc/config.go
@@ -1,5 +1,11 @@
 package rpc
 
+import "fmt"
+
+// 'localhost' gets interpreted as ipv6
+// TODO: revisit this
+const localhost = "127.0.0.1"
+
 type RPCConfig struct {
 	TM       *ServerConfig  `json:",omitempty" toml:",omitempty"`
 	Profiler *ServerConfig  `json:",omitempty" toml:",omitempty"`
@@ -41,28 +47,28 @@ func DefaultRPCConfig() *RPCConfig {
 func DefaultTMConfig() *ServerConfig {
 	return &ServerConfig{
 		Enabled:       true,
-		ListenAddress: "tcp://localhost:26658",
+		ListenAddress: fmt.Sprintf("tcp://%s:26658", localhost),
 	}
 }
 
 func DefaultGRPCConfig() *ServerConfig {
 	return &ServerConfig{
 		Enabled:       true,
-		ListenAddress: "localhost:10997",
+		ListenAddress: fmt.Sprintf("%s:10997", localhost),
 	}
 }
 
 func DefaultProfilerConfig() *ServerConfig {
 	return &ServerConfig{
 		Enabled:       false,
-		ListenAddress: "tcp://localhost:6060",
+		ListenAddress: fmt.Sprintf("tcp://%s:6060", localhost),
 	}
 }
 
 func DefaultMetricsConfig() *MetricsConfig {
 	return &MetricsConfig{
 		Enabled:         false,
-		ListenAddress:   "tcp://localhost:9102",
+		ListenAddress:   fmt.Sprintf("tcp://%s:9102", localhost),
 		MetricsPath:     "/metrics",
 		BlockSampleSize: 100,
 	}
-- 
GitLab