tests

package
v0.0.0-...-da72ffe Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateClient

func CreateClient(t *testing.T, ctx context.Context, logger logger.Logger, port int) (*client.Client, error)

func GenerateTestDataKB

func GenerateTestDataKB(sizeKB int, randomData bool) ([]byte, error)

GenerateTestDataKB creates a byte slice of the exact size requested in KB. By default, it uses a repeating pattern for efficiency. Use randomData=true for cryptographically secure random data when testing hashing/encoding.

func GenerateTestDataMB

func GenerateTestDataMB(sizeMB int, randomData bool) ([]byte, error)

GenerateTestDataMB creates a byte slice of the exact size requested in MB. A wrapper around GenerateTestDataKB for convenience.

func ShutdownTestNodes

func ShutdownTestNodes(t *testing.T, nodes []*TestNode) error

ShutdownTestNodes gracefully shuts down all test nodes and cleans up temporary directories.

Types

type TestNode

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

TestNode represents a test node with its configuration and instance.

func (*TestNode) Account

func (t *TestNode) Account() share.Account

func (*TestNode) Config

func (t *TestNode) Config() config.Config

func (*TestNode) Ctx

func (t *TestNode) Ctx() context.Context

func (*TestNode) DBM

func (t *TestNode) DBM() *db.Manager

func (*TestNode) Dir

func (t *TestNode) Dir() string

func (*TestNode) FDB

func (t *TestNode) FDB() *fdb.FDB

func (*TestNode) IsNode

func (t *TestNode) IsNode() bool

func (*TestNode) IsRole

func (t *TestNode) IsRole(role types.Role) bool

func (*TestNode) IsSequencer

func (t *TestNode) IsSequencer() bool

func (*TestNode) IsValidator

func (t *TestNode) IsValidator() bool

func (*TestNode) Logger

func (t *TestNode) Logger() logger.Logger

func (*TestNode) Node

func (t *TestNode) Node() *node.Node

func (*TestNode) PeerID

func (t *TestNode) PeerID() peer.ID

func (*TestNode) RPC

func (t *TestNode) RPC() *rpc.RPC

func (*TestNode) RequiresDKG

func (t *TestNode) RequiresDKG() bool

func (*TestNode) Role

func (t *TestNode) Role() types.Role

func (*TestNode) SendAndReceiveMessage

func (t *TestNode) SendAndReceiveMessage(targetNode *TestNode, transportType types.TransportType, handlerType types.HandlerType, data []byte, timeout time.Duration) ([]byte, error)

SendAndReceiveMessage sends a message to another node and waits for a response. This implementation uses the client package's ResponseHandler for asynchronous but reliable large payload handling.

func (*TestNode) SendMessage

func (t *TestNode) SendMessage(targetNode *TestNode, transportType types.TransportType, handlerType types.HandlerType, data []byte) error

SendMessage sends a message to the target node and returns an error if the send fails.

func (*TestNode) State

func (t *TestNode) State() *state.StateManager

func (*TestNode) WaitForPeersConnected

func (t *TestNode) WaitForPeersConnected(expectedPeerCount int, timeout time.Duration) error

type TestNodes

type TestNodes []*TestNode

func InitializeTestNodes

func InitializeTestNodes(
	t *testing.T,
	ctx context.Context,
	logLevel zapcore.Level,
	signerType types.SignerType,
	nodeRoles []types.Role,
	basePort int,
	transportTypes ...types.TransportType,
) (TestNodes, error)

InitializeTestNodes initializes 'count' number of nodes for testing. Each node is assigned a unique port starting from 'basePort'. DIDs are created with persistence disabled (non-persistent keys).

func (TestNodes) GetBootstrapNode

func (tn TestNodes) GetBootstrapNode() *TestNode

func (TestNodes) GetNodeByIndex

func (t TestNodes) GetNodeByIndex(index int) *TestNode

func (TestNodes) GetNodeByRole

func (tn TestNodes) GetNodeByRole(role types.Role) *TestNode

func (TestNodes) GetNodesByRole

func (tn TestNodes) GetNodesByRole(role types.Role) []*TestNode

func (TestNodes) GetNodesByRoles

func (tn TestNodes) GetNodesByRoles(roles ...types.Role) []*TestNode

Jump to

Keyboard shortcuts

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