mockstorer

package
v2.3.0-rc9 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 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 DelayedStore

type DelayedStore struct {
	storage.ChunkStore
	// contains filtered or unexported fields
}

func NewDelayedStore

func NewDelayedStore(s storage.ChunkStore) *DelayedStore

func (*DelayedStore) Delay

func (d *DelayedStore) Delay(addr swarm.Address, delay time.Duration)

func (*DelayedStore) Get

func (d *DelayedStore) Get(ctx context.Context, addr swarm.Address) (ch swarm.Chunk, err error)

type ForgettingStore

type ForgettingStore struct {
	storage.ChunkStore
	// contains filtered or unexported fields
}

func NewForgettingStore

func NewForgettingStore(s storage.ChunkStore) *ForgettingStore

func (*ForgettingStore) Get

func (f *ForgettingStore) Get(ctx context.Context, addr swarm.Address) (ch swarm.Chunk, err error)

Get implements the ChunkStore interface. if in recording phase, record the chunk address as miss and returns Get on the embedded store if in forgetting phase, returns ErrNotFound if the chunk address is recorded as miss

func (*ForgettingStore) Miss

func (f *ForgettingStore) Miss(addr swarm.Address)

func (*ForgettingStore) Missed

func (f *ForgettingStore) Missed() int

func (*ForgettingStore) Put

func (f *ForgettingStore) Put(ctx context.Context, ch swarm.Chunk) (err error)

Put implements the ChunkStore interface.

func (*ForgettingStore) Record

func (f *ForgettingStore) Record()

func (*ForgettingStore) Reset

func (f *ForgettingStore) Reset()

func (*ForgettingStore) Stored

func (f *ForgettingStore) Stored() int64

func (*ForgettingStore) Unmiss

func (f *ForgettingStore) Unmiss(addr swarm.Address)

func (*ForgettingStore) Unrecord

func (f *ForgettingStore) Unrecord()

type Option

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

func WithCapacityDoubling added in v2.3.0

func WithCapacityDoubling(s int) Option

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) CommittedDepth added in v2.3.0

func (s *ReserveStore) CommittedDepth() uint8

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, stampHash []byte) (swarm.Chunk, error)

Get chunks.

func (*ReserveStore) ReserveHas

func (s *ReserveStore) ReserveHas(addr swarm.Address, batchID []byte, stampHash []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