blocktest

package
v1.11.11 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchedVM

type BatchedVM struct {
	T *testing.T

	CantGetAncestors    bool
	CantBatchParseBlock bool

	GetAncestorsF func(
		ctx context.Context,
		blkID ids.ID,
		maxBlocksNum int,
		maxBlocksSize int,
		maxBlocksRetrivalTime time.Duration,
	) ([][]byte, error)

	BatchedParseBlockF func(
		ctx context.Context,
		blks [][]byte,
	) ([]snowman.Block, error)
}

BatchedVM is a BatchedVM that is useful for testing.

func (*BatchedVM) BatchedParseBlock

func (vm *BatchedVM) BatchedParseBlock(
	ctx context.Context,
	blks [][]byte,
) ([]snowman.Block, error)

func (*BatchedVM) Default

func (vm *BatchedVM) Default(cant bool)

func (*BatchedVM) GetAncestors

func (vm *BatchedVM) GetAncestors(
	ctx context.Context,
	blkID ids.ID,
	maxBlocksNum int,
	maxBlocksSize int,
	maxBlocksRetrivalTime time.Duration,
) ([][]byte, error)

type StateSummary

type StateSummary struct {
	IDV     ids.ID
	HeightV uint64
	BytesV  []byte

	T          *testing.T
	CantAccept bool
	AcceptF    func(context.Context) (block.StateSyncMode, error)
}

func (*StateSummary) Accept

func (*StateSummary) Bytes

func (s *StateSummary) Bytes() []byte

func (*StateSummary) Height

func (s *StateSummary) Height() uint64

func (*StateSummary) ID

func (s *StateSummary) ID() ids.ID

type StateSyncableVM

type StateSyncableVM struct {
	T *testing.T

	CantStateSyncEnabled,
	CantStateSyncGetOngoingSummary,
	CantGetLastStateSummary,
	CantParseStateSummary,
	CantGetStateSummary bool

	StateSyncEnabledF           func(context.Context) (bool, error)
	GetOngoingSyncStateSummaryF func(context.Context) (block.StateSummary, error)
	GetLastStateSummaryF        func(context.Context) (block.StateSummary, error)
	ParseStateSummaryF          func(ctx context.Context, summaryBytes []byte) (block.StateSummary, error)
	GetStateSummaryF            func(ctx context.Context, summaryHeight uint64) (block.StateSummary, error)
}

func (*StateSyncableVM) GetLastStateSummary

func (vm *StateSyncableVM) GetLastStateSummary(ctx context.Context) (block.StateSummary, error)

func (*StateSyncableVM) GetOngoingSyncStateSummary

func (vm *StateSyncableVM) GetOngoingSyncStateSummary(ctx context.Context) (block.StateSummary, error)

func (*StateSyncableVM) GetStateSummary

func (vm *StateSyncableVM) GetStateSummary(ctx context.Context, summaryHeight uint64) (block.StateSummary, error)

func (*StateSyncableVM) ParseStateSummary

func (vm *StateSyncableVM) ParseStateSummary(ctx context.Context, summaryBytes []byte) (block.StateSummary, error)

func (*StateSyncableVM) StateSyncEnabled

func (vm *StateSyncableVM) StateSyncEnabled(ctx context.Context) (bool, error)

type VM

type VM struct {
	enginetest.VM

	CantBuildBlock,
	CantParseBlock,
	CantGetBlock,
	CantSetPreference,
	CantLastAccepted,
	CantGetBlockIDAtHeight bool

	BuildBlockF         func(context.Context) (snowman.Block, error)
	ParseBlockF         func(context.Context, []byte) (snowman.Block, error)
	GetBlockF           func(context.Context, ids.ID) (snowman.Block, error)
	SetPreferenceF      func(context.Context, ids.ID) error
	LastAcceptedF       func(context.Context) (ids.ID, error)
	GetBlockIDAtHeightF func(ctx context.Context, height uint64) (ids.ID, error)
}

VM is a ChainVM that is useful for testing.

func (*VM) BuildBlock

func (vm *VM) BuildBlock(ctx context.Context) (snowman.Block, error)

func (*VM) Default

func (vm *VM) Default(cant bool)

func (*VM) GetBlock

func (vm *VM) GetBlock(ctx context.Context, id ids.ID) (snowman.Block, error)

func (*VM) GetBlockIDAtHeight

func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)

func (*VM) LastAccepted

func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error)

func (*VM) ParseBlock

func (vm *VM) ParseBlock(ctx context.Context, b []byte) (snowman.Block, error)

func (*VM) SetPreference

func (vm *VM) SetPreference(ctx context.Context, id ids.ID) error

Jump to

Keyboard shortcuts

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