testu

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: MIT Imports: 19 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

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

func GetDAGServ

func GetDAGServ() ipld.DAGService

GetDAGServ returns a mock DAGService.

func GetDagBuilderParams

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

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

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

GetReedSolomonShards gets the shards from the original file

func MetaSplitterGen

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

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

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

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

func UseReedSolomon

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

func UseTrickleWithMetadata

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