aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-02 20:00:25 +0800
committerobscuren <geffobscura@gmail.com>2015-01-02 20:00:25 +0800
commite2d1d832efe0623539c9d37ca8aee17d44e47067 (patch)
treeae681ba7255a293bf3edc02c30da207bae9ac96a
parentd336e24dcec2bb2cb89fff76302882aa82124dc8 (diff)
downloaddexon-e2d1d832efe0623539c9d37ca8aee17d44e47067.tar.gz
dexon-e2d1d832efe0623539c9d37ca8aee17d44e47067.tar.zst
dexon-e2d1d832efe0623539c9d37ca8aee17d44e47067.zip
added nil check
-rw-r--r--core/chain_manager_test.go10
-rw-r--r--core/types/block_test.go22
-rw-r--r--state/state_test.go9
-rw-r--r--whisper/envelope.go1
-rw-r--r--whisper/messages_test.go5
5 files changed, 8 insertions, 39 deletions
diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go
index 10ff7359b..2ed3c6c9e 100644
--- a/core/chain_manager_test.go
+++ b/core/chain_manager_test.go
@@ -16,17 +16,9 @@ import (
"github.com/ethereum/go-ethereum/rlp"
)
-//var Logger logpkg.LogSystem
-
-//var Log = logpkg.NewLogger("TEST")
-
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
- //Logger = logpkg.NewStdLogSystem(os.Stdout, log.LstdFlags, logpkg.DebugLevel)
- //logpkg.AddLogSystem(Logger)
-
ethutil.ReadConfig("/tmp/ethtest", "/tmp/ethtest", "ETH")
-
}
func reset() {
@@ -38,7 +30,7 @@ func reset() {
}
func loadChain(fn string, t *testing.T) (types.Blocks, error) {
- fh, err := os.OpenFile(path.Join("..", "_data", fn), os.O_RDONLY, os.ModePerm)
+ fh, err := os.OpenFile(path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "_data", fn), os.O_RDONLY, os.ModePerm)
if err != nil {
return nil, err
}
diff --git a/core/types/block_test.go b/core/types/block_test.go
index c85708975..ab1254f4c 100644
--- a/core/types/block_test.go
+++ b/core/types/block_test.go
@@ -1,23 +1 @@
package types
-
-import (
- "bytes"
- "testing"
-
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/ethutil"
- "github.com/ethereum/go-ethereum/rlp"
-)
-
-func init() {
- ethutil.ReadConfig(".ethtest", "/tmp/ethtest", "")
- ethutil.Config.Db, _ = ethdb.NewMemDatabase()
-}
-
-func TestNewBlock(t *testing.T) {
- block := GenesisBlock()
- data := ethutil.Encode(block)
-
- var genesis Block
- err := rlp.Decode(bytes.NewReader(data), &genesis)
-}
diff --git a/state/state_test.go b/state/state_test.go
index 28e4fc5da..1f76eff0f 100644
--- a/state/state_test.go
+++ b/state/state_test.go
@@ -5,7 +5,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethutil"
- "github.com/ethereum/go-ethereum/trie"
+ "github.com/ethereum/go-ethereum/ptrie"
)
type StateSuite struct {
@@ -18,9 +18,8 @@ var _ = checker.Suite(&StateSuite{})
func (s *StateSuite) TestDump(c *checker.C) {
key := []byte{0x01}
- value := "foo"
- node := []interface{}{key, value}
- s.state.Trie.Put(node)
+ value := []byte("foo")
+ s.state.trie.Update(key, value)
dump := s.state.Dump()
c.Assert(dump, checker.NotNil)
}
@@ -29,7 +28,7 @@ func (s *StateSuite) SetUpTest(c *checker.C) {
db, _ := ethdb.NewMemDatabase()
ethutil.ReadConfig(".ethtest", "/tmp/ethtest", "")
ethutil.Config.Db = db
- s.state = New(trie.New(db, ""))
+ s.state = New(ptrie.New(nil, db))
}
func (s *StateSuite) TestSnapshot(c *checker.C) {
diff --git a/whisper/envelope.go b/whisper/envelope.go
index 066e20f6a..9d28dfa6b 100644
--- a/whisper/envelope.go
+++ b/whisper/envelope.go
@@ -79,6 +79,7 @@ func (self *Envelope) Open(prv *ecdsa.PrivateKey) (msg *Message, err error) {
if prv != nil {
message.Payload, err = crypto.Decrypt(prv, payload)
switch err {
+ case nil: // OK
case ecies.ErrInvalidPublicKey: // Payload isn't encrypted
message.Payload = payload
return &message, err
diff --git a/whisper/messages_test.go b/whisper/messages_test.go
index cba103011..93caa31b3 100644
--- a/whisper/messages_test.go
+++ b/whisper/messages_test.go
@@ -40,12 +40,11 @@ func TestMessageEncryptDecrypt(t *testing.T) {
msg1, err := envelope.Open(prv2)
if err != nil {
- fmt.Println(err)
+ t.Error(err)
t.FailNow()
}
if !bytes.Equal(msg1.Payload, data) {
- fmt.Println("encryption error. data did not match")
- t.FailNow()
+ t.Error("encryption error. data did not match")
}
}