added nil check

pull/229/merge
obscuren 10 years ago
parent d336e24dce
commit e2d1d832ef
  1. 10
      core/chain_manager_test.go
  2. 22
      core/types/block_test.go
  3. 9
      state/state_test.go
  4. 1
      whisper/envelope.go
  5. 5
      whisper/messages_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
}

@ -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)
}

@ -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) {

@ -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

@ -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")
}
}

Loading…
Cancel
Save