Documentation ¶
Index ¶
- func New() *mockStorer
- func NewWithChunkStore(cs storage.ChunkStore) *mockStorer
- func NewWithDebugInfo(info storer.Info) *mockStorer
- type Option
- func WithChunks(chs ...swarm.Chunk) Option
- func WithCursors(c []uint64, e uint64) Option
- func WithCursorsErr(e error) Option
- func WithEvilChunk(addr swarm.Address, ch swarm.Chunk) Option
- func WithPutHook(f func(swarm.Chunk) error) Option
- func WithRadius(r uint8) Option
- func WithReserveSize(s int) Option
- func WithSample(s storer.Sample) Option
- func WithSubscribeResp(chunks []*storer.BinC, err error) Option
- type ReserveStore
- func (s *ReserveStore) EvictBatch(ctx context.Context, batchID []byte) error
- func (s *ReserveStore) IsFullySynced() bool
- func (s *ReserveStore) IsWithinStorageRadius(addr swarm.Address) bool
- func (s *ReserveStore) PutCalls() int
- func (s *ReserveStore) ReserveGet(ctx context.Context, addr swarm.Address, batchID []byte) (swarm.Chunk, error)
- func (s *ReserveStore) ReserveHas(addr swarm.Address, batchID []byte) (bool, error)
- func (s *ReserveStore) ReserveLastBinIDs() (curs []uint64, epoch uint64, err error)
- func (s *ReserveStore) ReservePutter() storage.Putter
- func (s *ReserveStore) ReserveSample(context.Context, []byte, uint8, uint64, *big.Int) (storer.Sample, error)
- func (s *ReserveStore) ReserveSize() int
- func (s *ReserveStore) SetCalls() int
- func (s *ReserveStore) SetStorageRadius(r uint8)
- func (s *ReserveStore) StorageRadius() uint8
- func (s *ReserveStore) SubscribeBin(ctx context.Context, bin uint8, start uint64) (<-chan *storer.BinC, func(), <-chan error)
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 ¶
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithChunks ¶
WithChunks mocks the set of chunks that the store is aware of (used in Get and Has calls).
func WithCursors ¶
func WithCursorsErr ¶
func WithEvilChunk ¶
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 WithRadius ¶
func WithReserveSize ¶
func WithSample ¶
func WithSubscribeResp ¶
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 ¶
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 (*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.