Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-block-format
Commits
7614cdad
Commit
7614cdad
authored
Aug 15, 2016
by
Jakub Sztandera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: do explicit error check
License: MIT Signed-off-by:
Jakub Sztandera
<
kubuxu@ipfs.io
>
parent
e6e5593a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
blocks.go
blocks.go
+3
-1
blocks_test.go
blocks_test.go
+1
-1
No files found.
blocks.go
View file @
7614cdad
...
...
@@ -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
,
err
ors
.
New
(
"Data did not match given hash!"
)
return
nil
,
err
WrongHash
}
}
return
&
BasicBlock
{
data
:
data
,
multihash
:
h
},
nil
...
...
blocks_test.go
View file @
7614cdad
...
...
@@ -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
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment