chaintest

package
v1.19.7 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2025 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package chaintest provides test utilities for chains

Package chaintest provides test utilities for chain testing

Index

Constants

This section is empty.

Variables

View Source
var Genesis = &TestBlock{
	id:        ids.GenerateTestID(),
	parentID:  ids.Empty,
	height:    0,
	bytes:     []byte("genesis"),
	status:    consensustest.Accepted,
	timestamp: time.Now(),
}

Genesis is the genesis test block

Functions

This section is empty.

Types

type TestBlock

type TestBlock struct {
	// contains filtered or unexported fields
}

TestBlock is a mock block for testing

func BuildChild

func BuildChild(parent *TestBlock) *TestBlock

BuildChild builds a child block

func BuildChildWithTime

func BuildChildWithTime(parent *TestBlock, timestamp time.Time) *TestBlock

BuildChildWithTime builds a child block with timestamp

func (*TestBlock) Accept

func (b *TestBlock) Accept(ctx context.Context) error

Accept accepts the block

func (*TestBlock) Bytes

func (b *TestBlock) Bytes() []byte

Bytes returns the block bytes

func (*TestBlock) Height

func (b *TestBlock) Height() uint64

Height returns the block height

func (*TestBlock) ID

func (b *TestBlock) ID() ids.ID

ID returns the block ID

func (*TestBlock) Parent

func (b *TestBlock) Parent() ids.ID

Parent returns the parent block ID (alias for ParentID)

func (*TestBlock) ParentID

func (b *TestBlock) ParentID() ids.ID

ParentID returns the parent block ID

func (*TestBlock) Reject

func (b *TestBlock) Reject(ctx context.Context) error

Reject rejects the block

func (*TestBlock) Status

func (b *TestBlock) Status() uint8

Status returns the block status

func (*TestBlock) Timestamp

func (b *TestBlock) Timestamp() time.Time

Timestamp returns the block timestamp

func (*TestBlock) Verify

func (b *TestBlock) Verify(ctx context.Context) error

Verify verifies the block

type TestChain

type TestChain struct {
	// contains filtered or unexported fields
}

TestChain provides a test implementation for chains

func NewTestChain

func NewTestChain(id []byte) *TestChain

NewTestChain creates a new test chain

func (*TestChain) Height

func (t *TestChain) Height() uint64

Height returns the current height

func (*TestChain) ID

func (t *TestChain) ID() []byte

ID returns the chain ID

func (*TestChain) SetHeight

func (t *TestChain) SetHeight(height uint64)

SetHeight sets the chain height

Jump to

Keyboard shortcuts

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