mockstorer

package
v1.18.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: BSD-3-Clause Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *mockStorer

New returns a mock storer implementation that is designed to be used for the unit tests.

func NewWithChunkStore

func NewWithChunkStore(cs storage.ChunkStore) *mockStorer

func NewWithDebugInfo

func NewWithDebugInfo(info storer.Info) *mockStorer

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithChunks

func WithChunks(chs ...swarm.Chunk) Option

WithChunks mocks the set of chunks that the store is aware of (used in Get and Has calls).

func WithCursors

func WithCursors(c []uint64, e uint64) Option

func WithCursorsErr

func WithCursorsErr(e error) Option

func WithEvilChunk

func WithEvilChunk(addr swarm.Address, ch swarm.Chunk) Option

WithEvilChunk allows to inject a malicious chunk (request a certain address of a chunk, but get another), in order to mock unsolicited chunk delivery.

func WithPutHook

func WithPutHook(f func(swarm.Chunk) error) Option

func WithRadius

func WithRadius(r uint8) Option

func WithReserveSize

func WithReserveSize(s int) Option

func WithSample

func WithSample(s storer.Sample) Option

func WithSubscribeResp

func WithSubscribeResp(chunks []*storer.BinC, err error) Option

WithSubscribeResp mocks a desired response when calling IntervalChunks method. Different possible responses for subsequent responses in multi-call scenarios are possible (i.e. first call yields a,b,c, second call yields d,e,f). Mock maintains state of current call using chunksCalls counter.

type ReserveStore

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

func NewReserve

func NewReserve(opts ...Option) *ReserveStore

NewReserve returns a new Reserve mock.

func (*ReserveStore) EvictBatch

func (s *ReserveStore) EvictBatch(ctx context.Context, batchID []byte) error

func (*ReserveStore) IsFullySynced

func (s *ReserveStore) IsFullySynced() bool

func (*ReserveStore) IsWithinStorageRadius

func (s *ReserveStore) IsWithinStorageRadius(addr swarm.Address) bool

func (*ReserveStore) PutCalls

func (s *ReserveStore) PutCalls() int

PutCalls returns the amount of times Put was called.

func (*ReserveStore) ReserveGet

func (s *ReserveStore) ReserveGet(ctx context.Context, addr swarm.Address, batchID []byte) (swarm.Chunk, error)

Get chunks.

func (*ReserveStore) ReserveHas

func (s *ReserveStore) ReserveHas(addr swarm.Address, batchID []byte) (bool, error)

Has chunks.

func (*ReserveStore) ReserveLastBinIDs

func (s *ReserveStore) ReserveLastBinIDs() (curs []uint64, epoch uint64, err error)

func (*ReserveStore) ReservePutter

func (s *ReserveStore) ReservePutter() storage.Putter

Put chunks.

func (*ReserveStore) ReserveSample

func (s *ReserveStore) ReserveSample(context.Context, []byte, uint8, uint64, *big.Int) (storer.Sample, error)

func (*ReserveStore) ReserveSize

func (s *ReserveStore) ReserveSize() int

func (*ReserveStore) SetCalls

func (s *ReserveStore) SetCalls() int

SetCalls returns the amount of times Set was called.

func (*ReserveStore) SetStorageRadius

func (s *ReserveStore) SetStorageRadius(r uint8)

func (*ReserveStore) StorageRadius

func (s *ReserveStore) StorageRadius() uint8

func (*ReserveStore) SubscribeBin

func (s *ReserveStore) SubscribeBin(ctx context.Context, bin uint8, start uint64) (<-chan *storer.BinC, func(), <-chan error)

IntervalChunks returns a set of chunk in a requested interval.

Jump to

Keyboard shortcuts

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