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
10e93ab6
Unverified
Commit
10e93ab6
authored
Jun 03, 2019
by
Hannah Howard
Committed by
GitHub
Jun 03, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #135 from ipfs/fix/blocks-generator
testutil: fix block generator
parents
1b921d21
1298633e
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 @
10e93ab6
...
...
@@ -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 @
10e93ab6
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