testu

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestRsDefaultNumData   = 10
	TestRsDefaultNumParity = 20
)

Variables

View Source
var (
	UseProtoBufLeaves = NodeOpts{Prefix: mdag.V0CidPrefix()}
	UseRawLeaves      = NodeOpts{Prefix: mdag.V0CidPrefix(), ForceRawLeaves: true, RawLeavesUsed: true}
	UseCidV1          = NodeOpts{Prefix: mdag.V1CidPrefix(), RawLeavesUsed: true}
	UseBlake2b256     NodeOpts
)

Some shorthands for NodeOpts.

Functions

func ArrComp

func ArrComp(a, b []byte) error

ArrComp checks if two byte slices are the same.

func ExtendMetaBytes added in v0.4.6

func ExtendMetaBytes(existing []byte, extended []byte) []byte

func GetDAGServ

func GetDAGServ() ipld.DAGService

GetDAGServ returns a mock DAGService.

func GetDagBuilderParams added in v0.4.9

func GetDagBuilderParams(dserv ipld.DAGService, opts NodeOpts) *h.DagBuilderParams

func GetEmptyNode

func GetEmptyNode(t testing.TB, dserv ipld.DAGService, opts NodeOpts) ipld.Node

GetEmptyNode returns an empty unixfs file node.

func GetNode

func GetNode(t testing.TB, dserv ipld.DAGService, data []byte, opts NodeOpts) ipld.Node

GetNode returns a unixfs file node with the specified data.

func GetNodeWithGivenData added in v0.4.9

func GetNodeWithGivenData(t testing.TB, dserv ipld.DAGService, data []byte, opts NodeOpts) ipld.Node

func GetRandomNode

func GetRandomNode(t testing.TB, dserv ipld.DAGService, size int64, opts NodeOpts) ([]byte, ipld.Node)

GetRandomNode returns a random unixfs file node.

func GetReedSolomonShards added in v0.5.1

func GetReedSolomonShards(t *testing.T, inbuf []byte, numData, numParity uint64) [][]byte

GetReedSolomonShards gets the shards from the original file

func MetaSplitterGen added in v0.4.6

func MetaSplitterGen(size int64) chunker.SplitterGen

func PrintDag

func PrintDag(nd *mdag.ProtoNode, ds ipld.DAGService, indent int)

PrintDag pretty-prints the given dag to stdout.

func RandomRemoveNodes added in v0.5.1

func RandomRemoveNodes(t *testing.T, ctx context.Context,
	root ipld.Node, dserv ipld.DAGService, n int) (ipld.Node, []cid.Cid, []int)

RandomRemoveNodes randomly removes n sharded nodes from under the file root Can remove from 1-n nodes since rand can repeat index Returns shard root node, the list of removed hashes and indices in the original links

func ReedSolomonMetaBytes added in v0.4.6

func ReedSolomonMetaBytes(numData, numParity, fileSize uint64) []byte

func SizeSplitterGen

func SizeSplitterGen(size int64) chunker.SplitterGen

SizeSplitterGen creates a generator.

Types

type NodeOpts

type NodeOpts struct {
	Prefix cid.Prefix
	// ForceRawLeaves if true will force the use of raw leaves
	ForceRawLeaves bool
	// RawLeavesUsed is true if raw leaves or either implicitly or explicitly enabled
	RawLeavesUsed bool
	// Enables reed solomon splitter
	ReedSolomonEnabled bool
	// Enables balanced DAG to be used than trickle.
	Balanced bool

	Metadata        []byte
	ChunkSize       uint64
	MaxLinks        int
	MetadataToMdify []byte
	// contains filtered or unexported fields
}

NodeOpts is used by GetNode, GetEmptyNode and GetRandomNode

func UseBalancedWithMetadata added in v0.4.5

func UseBalancedWithMetadata(maxLinks int, mdata []byte, chkSize uint64, mdata2 []byte) NodeOpts

func UseReedSolomon added in v0.4.4

func UseReedSolomon(numData, numParity, fileSize uint64, mdata []byte, chkSize uint64) (NodeOpts, []byte)

func UseTrickleWithMetadata added in v0.4.6

func UseTrickleWithMetadata(maxLinks int, mdata []byte, chkSize uint64, mdata2 []byte) NodeOpts

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL