testutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0, MIT Imports: 17 Imported by: 1

Documentation

Overview

Package testutil is a fork of some components of github.com/ipfs/go-graphsync/testutil in order to avoid networking dependencies imposed by Graphsync.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomBytes

func RandomBytes(n int64) []byte

RandomBytes returns a byte array of the given size with random values.

Types

type TestBlockChain

type TestBlockChain struct {
	GenisisNode ipld.Node
	GenisisLink ipld.Link
	MiddleNodes []ipld.Node
	MiddleLinks []ipld.Link
	TipNode     ipld.Node
	TipLink     ipld.Link
	// contains filtered or unexported fields
}

TestBlockChain is a simulated data structure similar to a blockchain

func SetupBlockChain

func SetupBlockChain(
	ctx context.Context,
	t testing.TB,
	lsys ipld.LinkSystem,
	size uint64,
	blockChainLength int) *TestBlockChain

SetupBlockChain creates a new test block chain with the given height

func (*TestBlockChain) AllBlocks

func (tbc *TestBlockChain) AllBlocks() []blocks.Block

AllBlocks returns all blocks for a blockchain

func (*TestBlockChain) Blocks

func (tbc *TestBlockChain) Blocks(from int, to int) []blocks.Block

Blocks Returns the given raw blocks for the block chain for the given range, indexed from the tip

func (*TestBlockChain) Chooser

Chooser is a NodeBuilderChooser function that always returns the block chain

func (*TestBlockChain) LinkTipIndex

func (tbc *TestBlockChain) LinkTipIndex(fromTip int) ipld.Link

LinkTipIndex returns a link to the block at the given index from the tip

func (*TestBlockChain) NodeTipIndex

func (tbc *TestBlockChain) NodeTipIndex(fromTip int) ipld.Node

NodeTipIndex returns the node to the block at the given index from the tip

func (*TestBlockChain) PathTipIndex

func (tbc *TestBlockChain) PathTipIndex(fromTip int) ipld.Path

PathTipIndex returns the path to the block at the given index from the tip

func (*TestBlockChain) RemainderBlocks

func (tbc *TestBlockChain) RemainderBlocks(from int) []blocks.Block

RemainderBlocks returns the remaining blocks for a blockchain, indexed from tip

func (*TestBlockChain) Selector

func (tbc *TestBlockChain) Selector() ipld.Node

Selector returns the selector to recursive traverse the block chain parent links

Directories

Path Synopsis
Package chaintypes is a fork of some components of github.com/ipfs/go-graphsync/testutil/chaintypes in order to avoid networking dependencies imposed by Graphsync.
Package chaintypes is a fork of some components of github.com/ipfs/go-graphsync/testutil/chaintypes in order to avoid networking dependencies imposed by Graphsync.

Jump to

Keyboard shortcuts

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