testda

package
v1.0.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package testda provides test implementations of the DA client interface.

Index

Constants

View Source
const (
	// DefaultMaxBlobSize is the default maximum blob size (7MB).
	DefaultMaxBlobSize = 7 * 1024 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DummyDA

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

DummyDA is a test implementation of the DA client interface. It supports blob storage, height simulation, failure injection, and header retrieval.

func New

func New(opts ...Option) *DummyDA

New creates a new DummyDA with the given options.

func (*DummyDA) Get

func (d *DummyDA) Get(_ context.Context, _ []datypes.ID, _ []byte) ([]datypes.Blob, error)

Get retrieves blobs by ID (stub implementation).

func (*DummyDA) GetDataNamespace

func (d *DummyDA) GetDataNamespace() []byte

GetDataNamespace returns the data namespace.

func (*DummyDA) GetForcedInclusionNamespace

func (d *DummyDA) GetForcedInclusionNamespace() []byte

GetForcedInclusionNamespace returns the forced inclusion namespace.

func (*DummyDA) GetHeaderByHeight

func (d *DummyDA) GetHeaderByHeight(_ context.Context, height uint64) (*Header, error)

GetHeaderByHeight retrieves the header for the given DA height. This mirrors the HeaderAPI.GetByHeight method from the real DA client. Returns nil if no header exists for the given height.

func (*DummyDA) GetHeaderNamespace

func (d *DummyDA) GetHeaderNamespace() []byte

GetHeaderNamespace returns the header namespace.

func (*DummyDA) GetProofs

func (d *DummyDA) GetProofs(_ context.Context, _ []datypes.ID, _ []byte) ([]datypes.Proof, error)

GetProofs returns inclusion proofs (stub implementation).

func (*DummyDA) HasForcedInclusionNamespace

func (d *DummyDA) HasForcedInclusionNamespace() bool

HasForcedInclusionNamespace reports whether forced inclusion is configured.

func (*DummyDA) Height

func (d *DummyDA) Height() uint64

Height returns the current DA height.

func (*DummyDA) Reset

func (d *DummyDA) Reset()

Reset clears all stored blobs, headers, and resets the height.

func (*DummyDA) Retrieve

func (d *DummyDA) Retrieve(_ context.Context, height uint64, namespace []byte) datypes.ResultRetrieve

Retrieve returns blobs stored at the given height and namespace.

func (*DummyDA) SetHeight

func (d *DummyDA) SetHeight(h uint64)

SetHeight sets the DA height directly.

func (*DummyDA) SetSubmitFailure

func (d *DummyDA) SetSubmitFailure(shouldFail bool)

SetSubmitFailure controls whether Submit should return errors.

func (*DummyDA) StartHeightTicker

func (d *DummyDA) StartHeightTicker(interval time.Duration) func()

StartHeightTicker starts a goroutine that increments the height every interval. It returns a function to stop the ticker.

func (*DummyDA) Submit

func (d *DummyDA) Submit(_ context.Context, data [][]byte, _ float64, namespace []byte, _ []byte) datypes.ResultSubmit

Submit stores blobs and returns success or simulated failure.

func (*DummyDA) Validate

func (d *DummyDA) Validate(_ context.Context, ids []datypes.ID, _ []datypes.Proof, _ []byte) ([]bool, error)

Validate validates inclusion proofs.

type Header struct {
	Height    uint64
	Timestamp time.Time
}

Header contains DA layer header information for a given height. This mirrors the structure used by real DA clients like Celestia.

func (*Header) Time

func (h *Header) Time() time.Time

Time returns the block time from the header. This mirrors the jsonrpc.Header.Time() method.

type Option

type Option func(*DummyDA)

Option configures a DummyDA instance.

func WithMaxBlobSize

func WithMaxBlobSize(size uint64) Option

WithMaxBlobSize sets the maximum blob size.

func WithStartHeight

func WithStartHeight(height uint64) Option

WithStartHeight sets the initial DA height.

Jump to

Keyboard shortcuts

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