Commit 7614cdad authored by Jakub Sztandera's avatar Jakub Sztandera

test: do explicit error check

License: MIT
Signed-off-by: default avatarJakub Sztandera <kubuxu@ipfs.io>
parent e6e5593a
......@@ -11,6 +11,8 @@ import (
u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
)
var errWrongHash = errors.New("Data did not match given hash!")
type Block interface {
Multihash() mh.Multihash
Data() []byte
......@@ -37,7 +39,7 @@ func NewBlockWithHash(data []byte, h mh.Multihash) (*BasicBlock, error) {
if u.Debug {
chk := u.Hash(data)
if string(chk) != string(h) {
return nil, errors.New("Data did not match given hash!")
return nil, errWrongHash
}
}
return &BasicBlock{data: data, multihash: h}, nil
......
......@@ -89,7 +89,7 @@ func TestManualHash(t *testing.T) {
u.Debug = true
block, err = NewBlockWithHash(data, hash)
if err == nil {
if err != errWrongHash {
t.Fatal(err)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment