Documentation ¶
Index ¶
- Variables
- func RandBytes(n int) []byte
- type DummyHeader
- func (d *DummyHeader) ChainID() string
- func (d *DummyHeader) Hash() header.Hash
- func (d *DummyHeader) Height() uint64
- 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() *DummyHeader
- func (d *DummyHeader) Time() time.Time
- func (d *DummyHeader) UnmarshalBinary(data []byte) error
- func (d *DummyHeader) Validate() error
- func (d *DummyHeader) Verify(hdr *DummyHeader) error
- type DummySuite
- type Generator
- 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]) GetRange(ctx context.Context, from, to uint64) ([]H, error)
- func (m *Store[H]) GetRangeByHeight(ctx context.Context, fromHead 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, ...header.HeadOption[H]) (H, error)
- func (m *Store[H]) Height() uint64
- func (m *Store[H]) Init(context.Context, H) error
- type Subscriber
- func (mhs *Subscriber[H]) Cancel()
- func (mhs *Subscriber[H]) NextHeader(ctx context.Context) (H, error)
- func (mhs *Subscriber[H]) SetVerifier(func(context.Context, H) error) error
- func (mhs *Subscriber[H]) Stop(context.Context) error
- func (mhs *Subscriber[H]) Subscribe() (header.Subscription[H], error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDummyVerify = errors.New("dummy verify error")
Functions ¶
Types ¶
type DummyHeader ¶
type DummyHeader struct { Chainid string PreviousHash header.Hash HeightI uint64 Timestamp time.Time // VerifyFailure allows for testing scenarios where a header would fail // verification. When set to true, it forces a failure. VerifyFailure bool // SoftFailure allows for testing scenarios where a header would fail // verification with SoftFailure set to true SoftFailure bool // 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() uint64
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() *DummyHeader
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(hdr *DummyHeader) 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 ¶
GetRangeByHeight returns headers in range [from; to).
type Subscriber ¶
type Subscriber[H header.Header[H]] struct {
Headers []H
}
func NewDummySubscriber ¶
func NewDummySubscriber() *Subscriber[*DummyHeader]
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]) SetVerifier ¶ added in v0.3.0
func (mhs *Subscriber[H]) SetVerifier(func(context.Context, H) error) error
func (*Subscriber[H]) Subscribe ¶
func (mhs *Subscriber[H]) Subscribe() (header.Subscription[H], error)
Click to show internal directories.
Click to hide internal directories.