llotest

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package llotest provides test doubles for hosts that run the LLO OCR3.1 reporting plugin outside of libocr (benchmarks, simulation harnesses, integration tests).

The plugin disseminates stream values exclusively through blobs, so a host that passes a nil ocr3_1types.BlobBroadcastFetcher to PluginFactory.NewReportingPlugin gets a plugin whose observations never carry stream values (the blob pump detects the nil and stays inert rather than panicking). Such hosts should pass BlobBroadcastFetcher from this package instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBlobHandle

func NewBlobHandle(payload []byte) (ocr3_1types.BlobHandle, error)

NewBlobHandle returns a syntactically valid BlobHandle addressing payload, for tests that need a handle without a broadcaster (e.g. to build an observation referencing an unfetchable blob).

Types

type BlobBroadcastFetcher

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

BlobBroadcastFetcher is an in-memory, content-addressed ocr3_1types.BlobBroadcastFetcher. Broadcast payloads are stored keyed by the handle they are addressed with, so any number of blobs may be in flight and each handle fetches back exactly its own payload.

A real BlobHandle cannot be constructed outside libocr (the concrete type lives in an internal package), but one can be unmarshaled from a syntactically valid encoding, which is what this type does: a LightCertifiedBlob handle whose chunk-digests root is the SHA-256 of the payload. Handles are therefore distinct per payload and stable across re-broadcasts of identical payloads. There is no certification, no chunking and no expiry: expiration hints are recorded for assertions but never acted on.

It is safe for concurrent use, which matters because the plugin broadcasts from its blob pump goroutine and fetches from the round goroutines. A single instance may be shared by every oracle in a simulated DON, which models a network where every broadcast blob is fetchable by every peer.

func NewBlobBroadcastFetcher

func NewBlobBroadcastFetcher() *BlobBroadcastFetcher

NewBlobBroadcastFetcher returns an empty in-memory broadcaster/fetcher.

func (*BlobBroadcastFetcher) Blobs

func (b *BlobBroadcastFetcher) Blobs() int

Blobs reports how many distinct payloads are stored.

func (*BlobBroadcastFetcher) BroadcastBlob

BroadcastBlob stores the payload and returns a handle addressing it.

func (*BlobBroadcastFetcher) BroadcastBytes

func (b *BlobBroadcastFetcher) BroadcastBytes() int

BroadcastBytes reports the total payload bytes of successful broadcasts. It lets a benchmark account for the bytes that left the observation when stream values moved into a blob.

func (*BlobBroadcastFetcher) Broadcasts

func (b *BlobBroadcastFetcher) Broadcasts() int

Broadcasts reports how many times BroadcastBlob was called, including failed calls.

func (*BlobBroadcastFetcher) ExpirationHint

func (b *BlobBroadcastFetcher) ExpirationHint(payload []byte) ocr3_1types.BlobExpirationHint

ExpirationHint returns the hint the payload was most recently broadcast with, or nil if the payload was never broadcast.

func (*BlobBroadcastFetcher) FetchBlob

func (b *BlobBroadcastFetcher) FetchBlob(_ context.Context, handle ocr3_1types.BlobHandle) ([]byte, error)

FetchBlob returns the payload the handle addresses.

func (*BlobBroadcastFetcher) Fetches

func (b *BlobBroadcastFetcher) Fetches() int

Fetches reports how many times FetchBlob was called.

func (*BlobBroadcastFetcher) Hints

Hints returns the expiration hints of all successful broadcasts, in call order. Unlike ExpirationHint it distinguishes repeat broadcasts of an identical payload, which are content-addressed to the same handle.

func (*BlobBroadcastFetcher) SetBroadcastError

func (b *BlobBroadcastFetcher) SetBroadcastError(err error)

SetBroadcastError makes every subsequent BroadcastBlob fail with err (nil clears it), for exercising the plugin's broadcast-failure path: a round whose blob could not be broadcast carries no stream values.

func (*BlobBroadcastFetcher) WaitForBroadcast

func (b *BlobBroadcastFetcher) WaitForBroadcast(ctx context.Context, after int) error

WaitForBroadcast blocks until BroadcastBlob has been called more than after times, i.e. until the plugin's blob pump has completed a cycle since the caller sampled Broadcasts().

Hosts that drive the plugin outside libocr need this: the pump gathers stream values on its own goroutine, off the round path, so a driver that spins rounds in a tight loop outruns it and every round observes no stream values. Waiting for a broadcast between rounds is the host-side equivalent of the wall-clock gap a real OCR round has.

It returns ctx.Err() (wrapped) if the context ends first.

Jump to

Keyboard shortcuts

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