Documentation ¶
Index ¶
- func RandBytes(n int) []byte
- type DummyHeader
- func (d *DummyHeader) ChainID() string
- func (d *DummyHeader) Hash() header.Hash
- func (d *DummyHeader) Height() int64
- func (d *DummyHeader) IsExpired(period time.Duration) bool
- func (d *DummyHeader) IsRecent(blockTime time.Duration) bool
- func (d *DummyHeader) IsZero() bool
- func (d *DummyHeader) LastHeader() header.Hash
- func (d *DummyHeader) MarshalBinary() ([]byte, error)
- func (d *DummyHeader) New() header.Header
- func (d *DummyHeader) Time() time.Time
- func (d *DummyHeader) UnmarshalBinary(data []byte) error
- func (d *DummyHeader) Validate() error
- func (d *DummyHeader) Verify(header header.Header) error
- type DummySuite
- type Generator
- type Raw
- type Store
- func (m *Store[H]) Append(ctx context.Context, headers ...H) error
- func (m *Store[H]) Get(ctx context.Context, hash header.Hash) (H, error)
- func (m *Store[H]) GetByHeight(ctx context.Context, height uint64) (H, error)
- func (m *Store[H]) GetRangeByHeight(ctx context.Context, from, to uint64) ([]H, error)
- func (m *Store[H]) GetVerifiedRange(ctx context.Context, h H, to uint64) ([]H, error)
- func (m *Store[H]) Has(context.Context, header.Hash) (bool, error)
- func (m *Store[H]) HasAt(_ context.Context, height uint64) bool
- func (m *Store[H]) Head(context.Context) (H, error)
- func (m *Store[H]) Height() uint64
- func (m *Store[H]) Init(context.Context, H) error
- func (m *Store[H]) Start(context.Context) error
- func (m *Store[H]) Stop(context.Context) error
- type Subscriber
- func (mhs *Subscriber[H]) AddValidator(func(context.Context, H) pubsub.ValidationResult) error
- func (mhs *Subscriber[H]) Cancel()
- func (mhs *Subscriber[H]) NextHeader(ctx context.Context) (H, error)
- func (mhs *Subscriber[H]) Stop(context.Context) error
- func (mhs *Subscriber[H]) Subscribe() (header.Subscription[H], error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DummyHeader ¶
type DummyHeader struct { Raw // contains filtered or unexported fields }
func RandDummyHeader ¶
func RandDummyHeader(t *testing.T) *DummyHeader
func (*DummyHeader) ChainID ¶
func (d *DummyHeader) ChainID() string
func (*DummyHeader) Hash ¶
func (d *DummyHeader) Hash() header.Hash
func (*DummyHeader) Height ¶
func (d *DummyHeader) Height() int64
func (*DummyHeader) IsZero ¶
func (d *DummyHeader) IsZero() bool
func (*DummyHeader) LastHeader ¶
func (d *DummyHeader) LastHeader() header.Hash
func (*DummyHeader) MarshalBinary ¶
func (d *DummyHeader) MarshalBinary() ([]byte, error)
func (*DummyHeader) New ¶
func (d *DummyHeader) New() header.Header
func (*DummyHeader) Time ¶
func (d *DummyHeader) Time() time.Time
func (*DummyHeader) UnmarshalBinary ¶
func (d *DummyHeader) UnmarshalBinary(data []byte) error
func (*DummyHeader) Validate ¶
func (d *DummyHeader) Validate() error
func (*DummyHeader) Verify ¶
func (d *DummyHeader) Verify(header header.Header) error
type DummySuite ¶
type DummySuite struct {
// contains filtered or unexported fields
}
DummySuite provides everything you need to test chain of DummyHeaders. If not, please don't hesitate to extend it for your case.
func NewTestSuite ¶
func NewTestSuite(t *testing.T) *DummySuite
NewTestSuite setups a new test suite.
func (*DummySuite) GenDummyHeaders ¶
func (s *DummySuite) GenDummyHeaders(num int) []*DummyHeader
func (*DummySuite) Head ¶
func (s *DummySuite) Head() *DummyHeader
func (*DummySuite) NextHeader ¶
func (s *DummySuite) NextHeader() *DummyHeader
type Store ¶
func NewDummyStore ¶
func NewDummyStore(t *testing.T) *Store[*DummyHeader]
NewDummyStore creates a store for DummyHeader.
func NewStore ¶
NewStore creates a generic mock store supporting different type of Headers based on Generator.
func (*Store[H]) GetByHeight ¶
func (*Store[H]) GetRangeByHeight ¶
func (*Store[H]) GetVerifiedRange ¶
type Subscriber ¶
type Subscriber[H header.Header] struct {
Headers []H
}
func NewDummySubscriber ¶
func NewDummySubscriber() *Subscriber[*DummyHeader]
func (*Subscriber[H]) AddValidator ¶
func (mhs *Subscriber[H]) AddValidator(func(context.Context, H) pubsub.ValidationResult) error
func (*Subscriber[H]) Cancel ¶
func (mhs *Subscriber[H]) Cancel()
func (*Subscriber[H]) NextHeader ¶
func (mhs *Subscriber[H]) NextHeader(ctx context.Context) (H, error)
func (*Subscriber[H]) Subscribe ¶
func (mhs *Subscriber[H]) Subscribe() (header.Subscription[H], error)
Click to show internal directories.
Click to hide internal directories.