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-bitswap
Commits
1298633e
Commit
1298633e
authored
Jun 03, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testutil: fix block generator
parent
1b921d21
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
testutil/testutil.go
testutil/testutil.go
+1
-1
testutil/testutil_test.go
testutil/testutil_test.go
+16
-0
No files found.
testutil/testutil.go
View file @
1298633e
...
...
@@ -17,9 +17,9 @@ var prioritySeq int
// GenerateBlocksOfSize generates a series of blocks of the given byte size
func
GenerateBlocksOfSize
(
n
int
,
size
int64
)
[]
blocks
.
Block
{
generatedBlocks
:=
make
([]
blocks
.
Block
,
0
,
n
)
buf
:=
make
([]
byte
,
size
)
for
i
:=
0
;
i
<
n
;
i
++
{
// rand.Read never errors
buf
:=
make
([]
byte
,
size
)
rand
.
Read
(
buf
)
b
:=
blocks
.
NewBlock
(
buf
)
generatedBlocks
=
append
(
generatedBlocks
,
b
)
...
...
testutil/testutil_test.go
0 → 100644
View file @
1298633e
package
testutil
import
(
"testing"
blocks
"github.com/ipfs/go-block-format"
)
func
TestGenerateBlocksOfSize
(
t
*
testing
.
T
)
{
for
_
,
b1
:=
range
GenerateBlocksOfSize
(
10
,
100
)
{
b2
:=
blocks
.
NewBlock
(
b1
.
RawData
())
if
b2
.
Cid
()
!=
b1
.
Cid
()
{
t
.
Fatal
(
"block CIDs mismatch"
)
}
}
}
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