diff options
-rw-r--r-- | cmd/geth/accountcmd.go | 2 | ||||
-rw-r--r-- | cmd/geth/consolecmd_test.go | 16 | ||||
-rw-r--r-- | console/console.go | 3 |
3 files changed, 15 insertions, 6 deletions
diff --git a/cmd/geth/accountcmd.go b/cmd/geth/accountcmd.go index 0f9d95c2c..2c2308514 100644 --- a/cmd/geth/accountcmd.go +++ b/cmd/geth/accountcmd.go @@ -70,7 +70,7 @@ either new or import). Without it you are not able to unlock your account. Note that exporting your key in unencrypted format is NOT supported. -Keys are stored under <DATADIR>/keys. +Keys are stored under <DATADIR>/keystore. It is safe to transfer the entire directory or the individual keys therein between ethereum nodes by simply copying. Make sure you backup your keys regularly. diff --git a/cmd/geth/consolecmd_test.go b/cmd/geth/consolecmd_test.go index e59fe1415..e0e549e12 100644 --- a/cmd/geth/consolecmd_test.go +++ b/cmd/geth/consolecmd_test.go @@ -17,7 +17,8 @@ package main import ( - "math/rand" + "crypto/rand" + "math/big" "os" "path/filepath" "runtime" @@ -73,7 +74,7 @@ func TestIPCAttachWelcome(t *testing.T) { coinbase := "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182" var ipc string if runtime.GOOS == "windows" { - ipc = `\\.\pipe\geth` + strconv.Itoa(rand.Int()) + ipc = `\\.\pipe\geth` + strconv.Itoa(trulyRandInt(100000, 999999)) } else { ws := tmpdir(t) defer os.RemoveAll(ws) @@ -94,7 +95,7 @@ func TestIPCAttachWelcome(t *testing.T) { func TestHTTPAttachWelcome(t *testing.T) { coinbase := "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182" - port := strconv.Itoa(rand.Intn(65535-1024) + 1024) // Yeah, sometimes this will fail, sorry :P + port := strconv.Itoa(trulyRandInt(1024, 65536)) // Yeah, sometimes this will fail, sorry :P geth := runGeth(t, "--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none", "--etherbase", coinbase, "--rpc", "--rpcport", port) @@ -108,7 +109,7 @@ func TestHTTPAttachWelcome(t *testing.T) { func TestWSAttachWelcome(t *testing.T) { coinbase := "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182" - port := strconv.Itoa(rand.Intn(65535-1024) + 1024) // Yeah, sometimes this will fail, sorry :P + port := strconv.Itoa(trulyRandInt(1024, 65536)) // Yeah, sometimes this will fail, sorry :P geth := runGeth(t, "--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none", @@ -160,3 +161,10 @@ at block: 0 ({{niltime}}){{if ipc}} `) attach.expectExit() } + +// trulyRandInt generates a crypto random integer used by the console tests to +// not clash network ports with other tests running cocurrently. +func trulyRandInt(lo, hi int) int { + num, _ := rand.Int(rand.Reader, big.NewInt(int64(hi-lo))) + return int(num.Int64()) + lo +} diff --git a/console/console.go b/console/console.go index 9cff8c876..00d1fea1d 100644 --- a/console/console.go +++ b/console/console.go @@ -30,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/internal/jsre" "github.com/ethereum/go-ethereum/internal/web3ext" "github.com/ethereum/go-ethereum/rpc" + "github.com/mattn/go-colorable" "github.com/peterh/liner" "github.com/robertkrimen/otto" ) @@ -80,7 +81,7 @@ func New(config Config) (*Console, error) { config.Prompt = DefaultPrompt } if config.Printer == nil { - config.Printer = os.Stdout + config.Printer = colorable.NewColorableStdout() } // Initialize the console and return console := &Console{ |