testutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeMasterPublicKey

func ComputeMasterPublicKey(cluster *TestCluster) types.G2Point

ComputeMasterPublicKey computes the master public key from all node commitments

func CreateTestAcknowledgements

func CreateTestAcknowledgements(t *testing.T, n int, epoch int64, dealerID int64) []*types.Acknowledgement

CreateTestAcknowledgements creates n test acknowledgements with specified epoch and dealer

func CreateTestCommitments

func CreateTestCommitments(t *testing.T, n int) []types.G2Point

CreateTestCommitments creates n test commitments (G2 points)

func CreateTestOperators

func CreateTestOperators(t *testing.T, numOperators int) []*peering.OperatorSetPeer

CreateTestOperators creates test operators from ChainConfig data

func CreateTestShare

func CreateTestShare(value uint64) *fr.Element

CreateTestShare creates a test share with a specific value

func WaitForDKGCompletion

func WaitForDKGCompletion(cluster *TestCluster, timeout time.Duration) bool

WaitForDKGCompletion polls nodes until all have completed DKG

func WaitForReshare

func WaitForReshare(cluster *TestCluster, initialVersions map[int]int64, timeout time.Duration) bool

WaitForReshare waits for nodes to complete a reshare (key version change) It automatically emits a block to trigger the reshare

Types

type MockChainPoller

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

MockChainPoller implements IChainPoller for testing It broadcasts blocks to multiple handlers without actually polling the chain

func NewMockChainPoller

func NewMockChainPoller(
	blockHandlers []blockHandler.IBlockHandler,
	blockInterval uint64,
	logger *zap.Logger,
) *MockChainPoller

NewMockChainPoller creates a new mock chain poller that broadcasts to multiple handlers blockInterval determines how many blocks to skip per emission (e.g., 5 for every 5th block)

func (*MockChainPoller) EmitBlock

func (m *MockChainPoller) EmitBlock() error

EmitBlock emits a single block to all registered block handlers The block number is automatically incremented based on blockInterval

func (*MockChainPoller) EmitBlockAtNumber

func (m *MockChainPoller) EmitBlockAtNumber(blockNumber uint64) error

EmitBlockAtNumber emits a block with a specific block number to all handlers This is useful for testing specific interval boundaries

func (*MockChainPoller) GetCurrentBlock

func (m *MockChainPoller) GetCurrentBlock() uint64

GetCurrentBlock returns the current block number

func (*MockChainPoller) SetCurrentBlock

func (m *MockChainPoller) SetCurrentBlock(blockNumber uint64)

SetCurrentBlock sets the current block number (useful for test setup)

func (*MockChainPoller) Start

func (m *MockChainPoller) Start(ctx context.Context) error

Start implements IChainPoller.Start It starts the mock poller but doesn't automatically emit blocks

func (*MockChainPoller) Stop

func (m *MockChainPoller) Stop()

Stop stops the mock poller

type TestCluster

type TestCluster struct {
	Nodes        []*node.Node
	Servers      []*httptest.Server
	ServerURLs   []string
	NumNodes     int
	MasterPubKey types.G2Point
	MockPoller   *MockChainPoller // Exposed for test control
}

TestCluster represents a cluster of KMS nodes for testing

func NewTestCluster

func NewTestCluster(t *testing.T, numNodes int) *TestCluster

NewTestCluster creates a test cluster of KMS nodes with completed DKG

func (*TestCluster) Close

func (c *TestCluster) Close()

Close shuts down all nodes in the cluster

func (*TestCluster) GetMasterPublicKey

func (c *TestCluster) GetMasterPublicKey() types.G2Point

GetMasterPublicKey returns the master public key

func (*TestCluster) GetServerURLs

func (c *TestCluster) GetServerURLs() []string

GetServerURLs returns the list of server URLs

Jump to

Keyboard shortcuts

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