diff options
-rw-r--r-- | cmd/geth/main.go | 4 | ||||
-rw-r--r-- | eth/backend.go | 21 | ||||
-rw-r--r-- | jsre/jsre_test.go | 2 | ||||
-rw-r--r-- | tests/init.go | 7 | ||||
-rw-r--r-- | whisper/whisper_test.go | 13 |
5 files changed, 22 insertions, 25 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index e74ddd0d0..0fb654eed 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -542,10 +542,10 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int, i func blockRecovery(ctx *cli.Context) { utils.CheckLegalese(utils.MustDataDir(ctx)) - arg := ctx.Args().First() - if len(ctx.Args()) < 1 && len(arg) > 0 { + if len(ctx.Args()) < 1 { glog.Fatal("recover requires block number or hash") } + arg := ctx.Args().First() cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx) utils.CheckLegalese(cfg.DataDir) diff --git a/eth/backend.go b/eth/backend.go index 9eb211e31..761a17a8f 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -65,7 +65,7 @@ const ( var ( jsonlogger = logger.NewJsonLogger() - datadirInUseErrNos = []uint{11, 32, 35} + datadirInUseErrnos = map[uint]bool{11: true, 32: true, 35: true} portInUseErrRE = regexp.MustCompile("address already in use") defaultBootNodes = []*discover.Node{ @@ -286,15 +286,7 @@ func New(config *Config) (*Ethereum, error) { // Open the chain database and perform any upgrades needed chainDb, err := newdb(filepath.Join(config.DataDir, "chaindata")) if err != nil { - var ok bool - errno := uint(err.(syscall.Errno)) - for _, no := range datadirInUseErrNos { - if errno == no { - ok = true - break - } - } - if ok { + if errno, ok := err.(syscall.Errno); ok && datadirInUseErrnos[uint(errno)] { err = fmt.Errorf("%v (check if another instance of geth is already running with the same data directory '%s')", err, config.DataDir) } return nil, fmt.Errorf("blockchain db err: %v", err) @@ -311,14 +303,7 @@ func New(config *Config) (*Ethereum, error) { dappDb, err := newdb(filepath.Join(config.DataDir, "dapp")) if err != nil { - var ok bool - for _, no := range datadirInUseErrNos { - if uint(err.(syscall.Errno)) == no { - ok = true - break - } - } - if ok { + if errno, ok := err.(syscall.Errno); ok && datadirInUseErrnos[uint(errno)] { err = fmt.Errorf("%v (check if another instance of geth is already running with the same data directory '%s')", err, config.DataDir) } return nil, fmt.Errorf("dapp db err: %v", err) diff --git a/jsre/jsre_test.go b/jsre/jsre_test.go index 8450f546c..ffb6999db 100644 --- a/jsre/jsre_test.go +++ b/jsre/jsre_test.go @@ -85,7 +85,7 @@ func TestNatto(t *testing.T) { if err != nil { t.Errorf("expected no error, got %v", err) } - time.Sleep(time.Millisecond * 10) + time.Sleep(100 * time.Millisecond) val, err := jsre.Run("msg") if err != nil { t.Errorf("expected no error, got %v", err) diff --git a/tests/init.go b/tests/init.go index 3f8b8c684..a86970499 100644 --- a/tests/init.go +++ b/tests/init.go @@ -56,13 +56,16 @@ var ( VmSkipTests = []string{} ) +// Disable reporting bad blocks for the tests +func init() { + core.DisableBadBlockReporting = true +} + func readJson(reader io.Reader, value interface{}) error { data, err := ioutil.ReadAll(reader) if err != nil { return fmt.Errorf("Error reading JSON file", err.Error()) } - - core.DisableBadBlockReporting = true if err = json.Unmarshal(data, &value); err != nil { if syntaxerr, ok := err.(*json.SyntaxError); ok { line := findLine(data, syntaxerr.Offset) diff --git a/whisper/whisper_test.go b/whisper/whisper_test.go index b5a919984..1a9a8667a 100644 --- a/whisper/whisper_test.go +++ b/whisper/whisper_test.go @@ -189,13 +189,22 @@ func TestMessageExpiration(t *testing.T) { t.Fatalf("failed to inject message: %v", err) } // Check that the message is inside the cache - if _, ok := node.messages[envelope.Hash()]; !ok { + node.poolMu.RLock() + _, found := node.messages[envelope.Hash()] + node.poolMu.RUnlock() + + if !found { t.Fatalf("message not found in cache") } // Wait for expiration and check cache again time.Sleep(time.Second) // wait for expiration time.Sleep(expirationCycle) // wait for cleanup cycle - if _, ok := node.messages[envelope.Hash()]; ok { + + node.poolMu.RLock() + _, found = node.messages[envelope.Hash()] + node.poolMu.RUnlock() + + if found { t.Fatalf("message not expired from cache") } } |