testutil

package
v0.0.0-...-21e1f9a Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrContentNotFound = fmt.Errorf("content not found")
)

TestErrors defines common test errors

Functions

func CreateTestCheckpoint

func CreateTestCheckpoint(epoch int64, root string) *types.Checkpoint

CreateTestCheckpoint creates a test checkpoint

func CreateTestReportEvent

func CreateTestReportEvent(from, to *TestKeyPair, context, reasonCode string) (*events.Event, error)

CreateTestReportEvent creates a test report event

func CreateTestRuleset

func CreateTestRuleset() *types.Ruleset

CreateTestRuleset creates a test ruleset with sensible defaults

func CreateTestScoreRecord

func CreateTestScoreRecord(did, context string, score float64) *types.ScoreRecord

CreateTestScoreRecord creates a test score record

func CreateTestVouchEvent

func CreateTestVouchEvent(from, to *TestKeyPair, context string) (*events.Event, error)

CreateTestVouchEvent creates a test vouch event

func CreateVouchChain

func CreateVouchChain(network []*TestKeyPair, context string) ([]*events.Event, error)

CreateVouchChain creates a chain of vouches between test identities

func GenerateRandomSeed

func GenerateRandomSeed() ([]byte, error)

GenerateRandomSeed generates a random seed for testing

func GenerateTestSeed

func GenerateTestSeed(identifier string) []byte

GenerateTestSeed generates a deterministic test seed

Types

type MockCheckpointService

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

MockCheckpointService provides mock checkpoint functionality

func NewMockCheckpointService

func NewMockCheckpointService() *MockCheckpointService

func (*MockCheckpointService) CreateCheckpoint

func (m *MockCheckpointService) CreateCheckpoint(ctx context.Context, treeRoot string, treeID string, epoch int64) (*types.Checkpoint, error)

func (*MockCheckpointService) GetCheckpoint

func (m *MockCheckpointService) GetCheckpoint(ctx context.Context, epoch int64) (*types.Checkpoint, error)

func (*MockCheckpointService) GetLatestCheckpoint

func (m *MockCheckpointService) GetLatestCheckpoint(ctx context.Context) (*types.Checkpoint, error)

func (*MockCheckpointService) SubmitPartialSignature

func (m *MockCheckpointService) SubmitPartialSignature(ctx context.Context, checkpointData []byte, signerIndex int, signature []byte) error

func (*MockCheckpointService) VerifyCheckpoint

func (m *MockCheckpointService) VerifyCheckpoint(ctx context.Context, checkpoint *types.Checkpoint) (bool, error)

type MockEventService

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

MockEventService provides a mock event service for testing

func NewMockEventService

func NewMockEventService() *MockEventService

NewMockEventService creates a new mock event service

func (*MockEventService) GetEvent

func (m *MockEventService) GetEvent(ctx context.Context, c ipfscid.Cid) (*events.Event, error)

func (*MockEventService) GetEventsByDID

func (m *MockEventService) GetEventsByDID(ctx context.Context, did string, eventType events.EventType, limit int) ([]*events.Event, error)

func (*MockEventService) SubmitEvent

func (m *MockEventService) SubmitEvent(ctx context.Context, event *events.Event) (*types.EventReceipt, error)

func (*MockEventService) ValidateEvent

func (m *MockEventService) ValidateEvent(ctx context.Context, event *events.Event) error

type MockScorerService

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

MockScorerService provides a mock scorer service for testing

func NewMockScorerService

func NewMockScorerService() *MockScorerService

NewMockScorerService creates a new mock scorer service

func (*MockScorerService) ComputeScore

func (m *MockScorerService) ComputeScore(ctx context.Context, did, context string) (*types.ScoreRecord, error)

func (*MockScorerService) GenerateThresholdProof

func (m *MockScorerService) GenerateThresholdProof(ctx context.Context, did, context string, threshold float64, nonce string) (*types.ThresholdProof, error)

func (*MockScorerService) GetScore

func (m *MockScorerService) GetScore(ctx context.Context, did, context string) (*types.ScoreRecord, error)

func (*MockScorerService) SetScore

func (m *MockScorerService) SetScore(did, context string, score float64)

SetScore allows tests to set specific scores

func (*MockScorerService) UpdateScores

func (m *MockScorerService) UpdateScores(ctx context.Context, eventCIDs []ipfscid.Cid) error

func (*MockScorerService) VerifyThresholdProof

func (m *MockScorerService) VerifyThresholdProof(ctx context.Context, proof *types.ThresholdProof) (bool, error)

type MockStorageService

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

MockStorageService provides an in-memory storage implementation for testing

func NewMockStorageService

func NewMockStorageService() *MockStorageService

NewMockStorageService creates a new mock storage service

func (*MockStorageService) Delete

func (m *MockStorageService) Delete(ctx context.Context, c ipfscid.Cid) error

func (*MockStorageService) Get

func (m *MockStorageService) Get(ctx context.Context, c ipfscid.Cid) ([]byte, error)

func (*MockStorageService) Has

func (*MockStorageService) Index

func (m *MockStorageService) Index(ctx context.Context, c ipfscid.Cid, metadata map[string]interface{}) error

func (*MockStorageService) Put

func (m *MockStorageService) Put(ctx context.Context, data []byte) (ipfscid.Cid, error)

func (*MockStorageService) Size

type TestEventValidator

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

TestEventValidator provides validation utilities for tests

func NewTestEventValidator

func NewTestEventValidator() *TestEventValidator

NewTestEventValidator creates a new test event validator

func (*TestEventValidator) ValidateEventSignature

func (v *TestEventValidator) ValidateEventSignature(event *events.Event) (bool, error)

ValidateEventSignature validates an event signature against its DID

type TestKeyPair

type TestKeyPair struct {
	KeyPair *crypto.Ed25519KeyPair
	DID     *didvc.DID
	Signer  *crypto.Ed25519Signer
}

TestKeyPair represents a test key pair with DID

func CreateTestNetwork

func CreateTestNetwork(size int) ([]*TestKeyPair, error)

CreateTestNetwork creates a set of interconnected test key pairs

func NewTestKeyPair

func NewTestKeyPair() (*TestKeyPair, error)

NewTestKeyPair creates a new test key pair with associated DID

func NewTestKeyPairFromSeed

func NewTestKeyPairFromSeed(seed []byte) (*TestKeyPair, error)

NewTestKeyPairFromSeed creates a test key pair from a deterministic seed

Jump to

Keyboard shortcuts

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