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-merkledag
Commits
1e4a4eaa
Commit
1e4a4eaa
authored
Mar 01, 2018
by
Hector Sanjuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ReadFull. Remove duplicated code
License: MIT Signed-off-by:
Hector Sanjuan
<
hector@protocol.ai
>
parent
90a5c15f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
merkledag_test.go
merkledag_test.go
+16
-12
No files found.
merkledag_test.go
View file @
1e4a4eaa
...
@@ -133,19 +133,23 @@ func TestBatchFetchDupBlock(t *testing.T) {
...
@@ -133,19 +133,23 @@ func TestBatchFetchDupBlock(t *testing.T) {
func
makeTestDAG
(
t
*
testing
.
T
,
read
io
.
Reader
,
ds
ipld
.
DAGService
)
ipld
.
Node
{
func
makeTestDAG
(
t
*
testing
.
T
,
read
io
.
Reader
,
ds
ipld
.
DAGService
)
ipld
.
Node
{
p
:=
make
([]
byte
,
512
)
p
:=
make
([]
byte
,
512
)
nodes
:=
[]
*
ProtoNode
{}
nodes
:=
[]
*
ProtoNode
{}
var
err
error
n
,
err
=
io
.
ReadFull
(
read
,
p
)
for
{
if
n
!=
len
(
p
)
{
n
,
err
:=
io
.
ReadFull
(
read
,
p
)
t
.
Fatal
(
"should have read 512 bytes from the reader"
)
if
err
==
io
.
EOF
{
}
break
for
err
==
nil
{
}
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
n
!=
len
(
p
)
{
t
.
Fatal
(
"should have read 512 bytes from the reader"
)
}
protoNode
:=
NodeWithData
(
p
)
protoNode
:=
NodeWithData
(
p
)
nodes
=
append
(
nodes
,
protoNode
)
nodes
=
append
(
nodes
,
protoNode
)
_
,
err
=
read
.
Read
(
p
)
}
if
err
!=
io
.
EOF
{
t
.
Fatal
(
err
)
}
}
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
...
@@ -158,7 +162,7 @@ func makeTestDAG(t *testing.T, read io.Reader, ds ipld.DAGService) ipld.Node {
...
@@ -158,7 +162,7 @@ func makeTestDAG(t *testing.T, read io.Reader, ds ipld.DAGService) ipld.Node {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
}
}
err
=
ds
.
Add
(
ctx
,
root
)
err
:
=
ds
.
Add
(
ctx
,
root
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
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