enginetest

package
v1.11.12-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BootstrapTracker

type BootstrapTracker struct {
	T *testing.T

	CantIsBootstrapped, CantBootstrapped, CantOnBootstrapCompleted bool

	IsBootstrappedF func() bool
	BootstrappedF   func(ids.ID)

	OnBootstrapCompletedF func() chan struct{}
}

BootstrapTracker is a test subnet

func (*BootstrapTracker) Bootstrapped

func (s *BootstrapTracker) Bootstrapped(chainID ids.ID)

Bootstrapped calls BootstrappedF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*BootstrapTracker) Default

func (s *BootstrapTracker) Default(cant bool)

Default set the default callable value to [cant]

func (*BootstrapTracker) IsBootstrapped

func (s *BootstrapTracker) IsBootstrapped() bool

IsBootstrapped calls IsBootstrappedF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail. Defaults to returning false.

func (*BootstrapTracker) OnBootstrapCompleted

func (s *BootstrapTracker) OnBootstrapCompleted() chan struct{}

type Bootstrapper

type Bootstrapper struct {
	Engine

	CantClear bool

	ClearF func(ctx context.Context) error
}

func (*Bootstrapper) Clear

func (b *Bootstrapper) Clear(ctx context.Context) error

func (*Bootstrapper) Default

func (b *Bootstrapper) Default(cant bool)

type Engine

type Engine struct {
	T *testing.T

	CantStart,

	CantIsBootstrapped,
	CantTimeout,
	CantGossip,
	CantHalt,
	CantShutdown,

	CantContext,

	CantNotify,

	CantGetStateSummaryFrontier,
	CantGetStateSummaryFrontierFailed,
	CantStateSummaryFrontier,

	CantGetAcceptedStateSummary,
	CantGetAcceptedStateSummaryFailed,
	CantAcceptedStateSummary,

	CantGetAcceptedFrontier,
	CantGetAcceptedFrontierFailed,
	CantAcceptedFrontier,

	CantGetAccepted,
	CantGetAcceptedFailed,
	CantAccepted,

	CantGet,
	CantGetAncestors,
	CantGetFailed,
	CantGetAncestorsFailed,
	CantPut,
	CantAncestors,

	CantPushQuery,
	CantPullQuery,
	CantQueryFailed,
	CantChits,

	CantConnected,
	CantDisconnected,

	CantHealth,

	CantAppRequest,
	CantAppResponse,
	CantAppGossip,
	CantAppRequestFailed,

	CantGetVM bool

	StartF                       func(ctx context.Context, startReqID uint32) error
	IsBootstrappedF              func() bool
	ContextF                     func() *snow.ConsensusContext
	HaltF                        func(context.Context)
	TimeoutF, GossipF, ShutdownF func(context.Context) error
	NotifyF                      func(context.Context, common.Message) error
	GetF, GetAncestorsF          func(ctx context.Context, nodeID ids.NodeID, requestID uint32, containerID ids.ID) error
	PullQueryF                   func(ctx context.Context, nodeID ids.NodeID, requestID uint32, containerID ids.ID, requestedHeight uint64) error
	PutF                         func(ctx context.Context, nodeID ids.NodeID, requestID uint32, container []byte) error
	PushQueryF                   func(ctx context.Context, nodeID ids.NodeID, requestID uint32, container []byte, requestedHeight uint64) error
	AncestorsF                   func(ctx context.Context, nodeID ids.NodeID, requestID uint32, containers [][]byte) error
	AcceptedFrontierF            func(ctx context.Context, nodeID ids.NodeID, requestID uint32, containerID ids.ID) error
	GetAcceptedF, AcceptedF      func(ctx context.Context, nodeID ids.NodeID, requestID uint32, preferredIDs set.Set[ids.ID]) error
	ChitsF                       func(ctx context.Context, nodeID ids.NodeID, requestID uint32, preferredID ids.ID, preferredIDAtHeight ids.ID, acceptedID ids.ID, acceptedHeight uint64) error
	GetStateSummaryFrontierF, GetStateSummaryFrontierFailedF, GetAcceptedStateSummaryFailedF,
	GetAcceptedFrontierF, GetFailedF, GetAncestorsFailedF,
	QueryFailedF, GetAcceptedFrontierFailedF, GetAcceptedFailedF func(ctx context.Context, nodeID ids.NodeID, requestID uint32) error
	AppRequestFailedF        func(ctx context.Context, nodeID ids.NodeID, requestID uint32, appErr *common.AppError) error
	StateSummaryFrontierF    func(ctx context.Context, nodeID ids.NodeID, requestID uint32, summary []byte) error
	GetAcceptedStateSummaryF func(ctx context.Context, nodeID ids.NodeID, requestID uint32, keys set.Set[uint64]) error
	AcceptedStateSummaryF    func(ctx context.Context, nodeID ids.NodeID, requestID uint32, summaryIDs set.Set[ids.ID]) error
	ConnectedF               func(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error
	DisconnectedF            func(ctx context.Context, nodeID ids.NodeID) error
	HealthF                  func(context.Context) (interface{}, error)
	GetVMF                   func() common.VM
	AppRequestF              func(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, msg []byte) error
	AppResponseF             func(ctx context.Context, nodeID ids.NodeID, requestID uint32, msg []byte) error
	AppGossipF               func(ctx context.Context, nodeID ids.NodeID, msg []byte) error
}

Engine is a test engine

func (*Engine) Accepted

func (e *Engine) Accepted(ctx context.Context, nodeID ids.NodeID, requestID uint32, containerIDs set.Set[ids.ID]) error

func (*Engine) AcceptedFrontier

func (e *Engine) AcceptedFrontier(ctx context.Context, nodeID ids.NodeID, requestID uint32, containerID ids.ID) error

func (*Engine) AcceptedStateSummary

func (e *Engine) AcceptedStateSummary(ctx context.Context, validatorID ids.NodeID, requestID uint32, summaryIDs set.Set[ids.ID]) error

func (*Engine) Ancestors

func (e *Engine) Ancestors(ctx context.Context, nodeID ids.NodeID, requestID uint32, containers [][]byte) error

func (*Engine) AppGossip

func (e *Engine) AppGossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error

func (*Engine) AppRequest

func (e *Engine) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error

func (*Engine) AppRequestFailed

func (e *Engine) AppRequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, appErr *common.AppError) error

func (*Engine) AppResponse

func (e *Engine) AppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error

func (*Engine) Chits

func (e *Engine) Chits(ctx context.Context, nodeID ids.NodeID, requestID uint32, preferredID ids.ID, preferredIDAtHeight ids.ID, acceptedID ids.ID, acceptedHeight uint64) error

func (*Engine) Connected

func (e *Engine) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error

func (*Engine) Default

func (e *Engine) Default(cant bool)

func (*Engine) Disconnected

func (e *Engine) Disconnected(ctx context.Context, nodeID ids.NodeID) error

func (*Engine) Get

func (e *Engine) Get(ctx context.Context, nodeID ids.NodeID, requestID uint32, containerID ids.ID) error

func (*Engine) GetAccepted

func (e *Engine) GetAccepted(ctx context.Context, nodeID ids.NodeID, requestID uint32, containerIDs set.Set[ids.ID]) error

func (*Engine) GetAcceptedFailed

func (e *Engine) GetAcceptedFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32) error

func (*Engine) GetAcceptedFrontier

func (e *Engine) GetAcceptedFrontier(ctx context.Context, nodeID ids.NodeID, requestID uint32) error

func (*Engine) GetAcceptedFrontierFailed

func (e *Engine) GetAcceptedFrontierFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32) error

func (*Engine) GetAcceptedStateSummary

func (e *Engine) GetAcceptedStateSummary(ctx context.Context, validatorID ids.NodeID, requestID uint32, keys set.Set[uint64]) error

func (*Engine) GetAcceptedStateSummaryFailed

func (e *Engine) GetAcceptedStateSummaryFailed(ctx context.Context, validatorID ids.NodeID, requestID uint32) error

func (*Engine) GetAncestors

func (e *Engine) GetAncestors(ctx context.Context, nodeID ids.NodeID, requestID uint32, containerID ids.ID) error

func (*Engine) GetAncestorsFailed

func (e *Engine) GetAncestorsFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32) error

func (*Engine) GetFailed

func (e *Engine) GetFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32) error

func (*Engine) GetStateSummaryFrontier

func (e *Engine) GetStateSummaryFrontier(ctx context.Context, validatorID ids.NodeID, requestID uint32) error

func (*Engine) GetStateSummaryFrontierFailed

func (e *Engine) GetStateSummaryFrontierFailed(ctx context.Context, validatorID ids.NodeID, requestID uint32) error

func (*Engine) Gossip

func (e *Engine) Gossip(ctx context.Context) error

func (*Engine) HealthCheck

func (e *Engine) HealthCheck(ctx context.Context) (interface{}, error)

func (*Engine) Notify

func (e *Engine) Notify(ctx context.Context, msg common.Message) error

func (*Engine) PullQuery

func (e *Engine) PullQuery(ctx context.Context, nodeID ids.NodeID, requestID uint32, containerID ids.ID, requestedHeight uint64) error

func (*Engine) PushQuery

func (e *Engine) PushQuery(ctx context.Context, nodeID ids.NodeID, requestID uint32, container []byte, requestedHeight uint64) error

func (*Engine) Put

func (e *Engine) Put(ctx context.Context, nodeID ids.NodeID, requestID uint32, container []byte) error

func (*Engine) QueryFailed

func (e *Engine) QueryFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32) error

func (*Engine) Shutdown

func (e *Engine) Shutdown(ctx context.Context) error

func (*Engine) Start

func (e *Engine) Start(ctx context.Context, startReqID uint32) error

func (*Engine) StateSummaryFrontier

func (e *Engine) StateSummaryFrontier(ctx context.Context, validatorID ids.NodeID, requestID uint32, summary []byte) error

func (*Engine) Timeout

func (e *Engine) Timeout(ctx context.Context) error

type Sender

type Sender struct {
	T *testing.T

	CantSendGetStateSummaryFrontier, CantSendStateSummaryFrontier,
	CantSendGetAcceptedStateSummary, CantSendAcceptedStateSummary,
	CantSendGetAcceptedFrontier, CantSendAcceptedFrontier,
	CantSendGetAccepted, CantSendAccepted,
	CantSendGet, CantSendGetAncestors, CantSendPut, CantSendAncestors,
	CantSendPullQuery, CantSendPushQuery, CantSendChits,
	CantSendAppRequest, CantSendAppResponse, CantSendAppError,
	CantSendAppGossip bool

	SendGetStateSummaryFrontierF func(context.Context, set.Set[ids.NodeID], uint32)
	SendStateSummaryFrontierF    func(context.Context, ids.NodeID, uint32, []byte)
	SendGetAcceptedStateSummaryF func(context.Context, set.Set[ids.NodeID], uint32, []uint64)
	SendAcceptedStateSummaryF    func(context.Context, ids.NodeID, uint32, []ids.ID)
	SendGetAcceptedFrontierF     func(context.Context, set.Set[ids.NodeID], uint32)
	SendAcceptedFrontierF        func(context.Context, ids.NodeID, uint32, ids.ID)
	SendGetAcceptedF             func(context.Context, set.Set[ids.NodeID], uint32, []ids.ID)
	SendAcceptedF                func(context.Context, ids.NodeID, uint32, []ids.ID)
	SendGetF                     func(context.Context, ids.NodeID, uint32, ids.ID)
	SendGetAncestorsF            func(context.Context, ids.NodeID, uint32, ids.ID)
	SendPutF                     func(context.Context, ids.NodeID, uint32, []byte)
	SendAncestorsF               func(context.Context, ids.NodeID, uint32, [][]byte)
	SendPushQueryF               func(context.Context, set.Set[ids.NodeID], uint32, []byte, uint64)
	SendPullQueryF               func(context.Context, set.Set[ids.NodeID], uint32, ids.ID, uint64)
	SendChitsF                   func(context.Context, ids.NodeID, uint32, ids.ID, ids.ID, ids.ID, uint64)
	SendAppRequestF              func(context.Context, set.Set[ids.NodeID], uint32, []byte) error
	SendAppResponseF             func(context.Context, ids.NodeID, uint32, []byte) error
	SendAppErrorF                func(context.Context, ids.NodeID, uint32, int32, string) error
	SendAppGossipF               func(context.Context, common.SendConfig, []byte) error
}

Sender is a test sender

func (*Sender) Default

func (s *Sender) Default(cant bool)

Default set the default callable value to [cant]

func (*Sender) SendAccepted

func (s *Sender) SendAccepted(ctx context.Context, validatorID ids.NodeID, requestID uint32, containerIDs []ids.ID)

SendAccepted calls SendAcceptedF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendAcceptedFrontier

func (s *Sender) SendAcceptedFrontier(ctx context.Context, validatorID ids.NodeID, requestID uint32, containerID ids.ID)

SendAcceptedFrontier calls SendAcceptedFrontierF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendAcceptedStateSummary

func (s *Sender) SendAcceptedStateSummary(ctx context.Context, validatorID ids.NodeID, requestID uint32, summaryIDs []ids.ID)

SendAcceptedStateSummary calls SendAcceptedStateSummaryF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendAncestors

func (s *Sender) SendAncestors(ctx context.Context, vdr ids.NodeID, requestID uint32, containers [][]byte)

SendAncestors calls SendAncestorsF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendAppError

func (s *Sender) SendAppError(ctx context.Context, nodeID ids.NodeID, requestID uint32, code int32, message string) error

SendAppError calls SendAppErrorF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendAppGossip

func (s *Sender) SendAppGossip(
	ctx context.Context,
	config common.SendConfig,
	appGossipBytes []byte,
) error

SendAppGossip calls SendAppGossipF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendAppRequest

func (s *Sender) SendAppRequest(ctx context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, appRequestBytes []byte) error

SendAppRequest calls SendAppRequestF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendAppResponse

func (s *Sender) SendAppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, appResponseBytes []byte) error

SendAppResponse calls SendAppResponseF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendChits

func (s *Sender) SendChits(ctx context.Context, vdr ids.NodeID, requestID uint32, preferredID ids.ID, preferredIDAtHeight ids.ID, acceptedID ids.ID, acceptedHeight uint64)

SendChits calls SendChitsF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendGet

func (s *Sender) SendGet(ctx context.Context, vdr ids.NodeID, requestID uint32, containerID ids.ID)

SendGet calls SendGetF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendGetAccepted

func (s *Sender) SendGetAccepted(ctx context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, containerIDs []ids.ID)

SendGetAccepted calls SendGetAcceptedF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendGetAcceptedFrontier

func (s *Sender) SendGetAcceptedFrontier(ctx context.Context, validatorIDs set.Set[ids.NodeID], requestID uint32)

SendGetAcceptedFrontier calls SendGetAcceptedFrontierF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendGetAcceptedStateSummary

func (s *Sender) SendGetAcceptedStateSummary(ctx context.Context, nodeIDs set.Set[ids.NodeID], requestID uint32, heights []uint64)

SendGetAcceptedStateSummary calls SendGetAcceptedStateSummaryF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendGetAncestors

func (s *Sender) SendGetAncestors(ctx context.Context, validatorID ids.NodeID, requestID uint32, containerID ids.ID)

SendGetAncestors calls SendGetAncestorsF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendGetStateSummaryFrontier

func (s *Sender) SendGetStateSummaryFrontier(ctx context.Context, validatorIDs set.Set[ids.NodeID], requestID uint32)

SendGetStateSummaryFrontier calls SendGetStateSummaryFrontierF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendPullQuery

func (s *Sender) SendPullQuery(ctx context.Context, vdrs set.Set[ids.NodeID], requestID uint32, containerID ids.ID, requestedHeight uint64)

SendPullQuery calls SendPullQueryF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendPushQuery

func (s *Sender) SendPushQuery(ctx context.Context, vdrs set.Set[ids.NodeID], requestID uint32, container []byte, requestedHeight uint64)

SendPushQuery calls SendPushQueryF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendPut

func (s *Sender) SendPut(ctx context.Context, vdr ids.NodeID, requestID uint32, container []byte)

SendPut calls SendPutF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

func (*Sender) SendStateSummaryFrontier

func (s *Sender) SendStateSummaryFrontier(ctx context.Context, validatorID ids.NodeID, requestID uint32, summary []byte)

SendStateSummaryFrontier calls SendStateSummaryFrontierF if it was initialized. If it wasn't initialized and this function shouldn't be called and testing was initialized, then testing will fail.

type SenderStub

type SenderStub struct {
	SentAppRequest, SentAppResponse,
	SentAppGossip chan []byte

	SentAppError chan *common.AppError
}

SenderStub is a stub sender that returns values received on method-specific channels.

func (SenderStub) SendAppError

func (f SenderStub) SendAppError(_ context.Context, _ ids.NodeID, _ uint32, errorCode int32, errorMessage string) error

func (SenderStub) SendAppGossip

func (f SenderStub) SendAppGossip(_ context.Context, _ common.SendConfig, bytes []byte) error

func (SenderStub) SendAppRequest

func (f SenderStub) SendAppRequest(_ context.Context, _ set.Set[ids.NodeID], _ uint32, bytes []byte) error

func (SenderStub) SendAppResponse

func (f SenderStub) SendAppResponse(_ context.Context, _ ids.NodeID, _ uint32, bytes []byte) error

type Timer

type Timer struct {
	T *testing.T

	CantRegisterTimout bool

	RegisterTimeoutF func(time.Duration)
}

Timer is a test timer

func (*Timer) Default

func (t *Timer) Default(cant bool)

Default set the default callable value to [cant]

func (*Timer) RegisterTimeout

func (t *Timer) RegisterTimeout(delay time.Duration)

type VM

type VM struct {
	T *testing.T

	CantInitialize, CantSetState,
	CantShutdown, CantCreateHandlers,
	CantHealthCheck, CantConnected, CantDisconnected, CantVersion,
	CantAppRequest, CantAppResponse, CantAppGossip, CantAppRequestFailed bool

	InitializeF       func(ctx context.Context, chainCtx *snow.Context, db database.Database, genesisBytes []byte, upgradeBytes []byte, configBytes []byte, msgChan chan<- common.Message, fxs []*common.Fx, appSender common.AppSender) error
	SetStateF         func(ctx context.Context, state snow.State) error
	ShutdownF         func(context.Context) error
	CreateHandlersF   func(context.Context) (map[string]http.Handler, error)
	ConnectedF        func(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error
	DisconnectedF     func(ctx context.Context, nodeID ids.NodeID) error
	HealthCheckF      func(context.Context) (interface{}, error)
	AppRequestF       func(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, msg []byte) error
	AppResponseF      func(ctx context.Context, nodeID ids.NodeID, requestID uint32, msg []byte) error
	AppGossipF        func(ctx context.Context, nodeID ids.NodeID, msg []byte) error
	AppRequestFailedF func(ctx context.Context, nodeID ids.NodeID, requestID uint32, appErr *common.AppError) error
	VersionF          func(context.Context) (string, error)
}

VM is a test vm

func (*VM) AppGossip

func (vm *VM) AppGossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error

func (*VM) AppRequest

func (vm *VM) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error

func (*VM) AppRequestFailed

func (vm *VM) AppRequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, appErr *common.AppError) error

func (*VM) AppResponse

func (vm *VM) AppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error

func (*VM) Connected

func (vm *VM) Connected(ctx context.Context, id ids.NodeID, nodeVersion *version.Application) error

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)

func (*VM) Default

func (vm *VM) Default(cant bool)

func (*VM) Disconnected

func (vm *VM) Disconnected(ctx context.Context, id ids.NodeID) error

func (*VM) HealthCheck

func (vm *VM) HealthCheck(ctx context.Context) (interface{}, error)

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx context.Context,
	chainCtx *snow.Context,
	db database.Database,
	genesisBytes,
	upgradeBytes,
	configBytes []byte,
	msgChan chan<- common.Message,
	fxs []*common.Fx,
	appSender common.AppSender,
) error

func (*VM) SetState

func (vm *VM) SetState(ctx context.Context, state snow.State) error

func (*VM) Shutdown

func (vm *VM) Shutdown(ctx context.Context) error

func (*VM) Version

func (vm *VM) Version(ctx context.Context) (string, error)

Jump to

Keyboard shortcuts

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