mock

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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) 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 WithIntervalsResp

func WithIntervalsResp(addrs []swarm.Address, top uint64, err error) Option

WithIntervalsResp 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 PullStorage

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

func NewPullStorage

func NewPullStorage(opts ...Option) *PullStorage

NewPullStorage returns a new PullStorage mock.

func (*PullStorage) Cursors

func (s *PullStorage) Cursors(ctx context.Context) (curs []uint64, err error)

func (*PullStorage) Get

func (s *PullStorage) Get(_ context.Context, _ storage.ModeGet, addrs ...swarm.Address) (chs []swarm.Chunk, err error)

Get chunks.

func (*PullStorage) Has

func (s *PullStorage) Has(_ context.Context, addr swarm.Address) (bool, error)

Has chunks.

func (*PullStorage) IntervalChunks

func (s *PullStorage) IntervalChunks(_ context.Context, bin uint8, from, to uint64, limit int) (chunks []swarm.Address, topmost uint64, err error)

IntervalChunks returns a set of chunk in a requested interval.

func (*PullStorage) Put

func (s *PullStorage) Put(_ context.Context, _ storage.ModePut, chs ...swarm.Chunk) error

Put chunks.

func (*PullStorage) PutCalls

func (s *PullStorage) PutCalls() int

PutCalls returns the amount of times Put was called.

func (*PullStorage) Set

func (s *PullStorage) Set(ctx context.Context, mode storage.ModeSet, addrs ...swarm.Address) error

Set chunks.

func (*PullStorage) SetCalls

func (s *PullStorage) SetCalls() int

SetCalls returns the amount of times Set was called.

Jump to

Keyboard shortcuts

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