Commit 1298633e authored by Steven Allen's avatar Steven Allen

testutil: fix block generator

parent 1b921d21
......@@ -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)
......
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")
}
}
}
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