Commit 697625a9 authored by Brian Tiger Chow's avatar Brian Tiger Chow

feat(util:testutil) add NewBlockOrFail(t, data) factory method

for use in tests
parent be835662
package testutil
import (
"testing"
blocks "github.com/jbenet/go-ipfs/blocks"
)
// NewBlockOrFail returns a block created from msgData. Signals test failure if
// creation fails.
//
// NB: NewBlockOrFail accepts a msgData parameter to avoid non-determinism in
// tests. Generating random block data could potentially result in unexpected
// behavior in tests. Thus, it is left up to the caller to select the msgData
// that will determine the blocks key.
func NewBlockOrFail(t *testing.T, msgData string) blocks.Block {
block, blockCreationErr := blocks.NewBlock([]byte(msgData))
if blockCreationErr != nil {
t.Fatal(blockCreationErr)
}
return *block
}
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