mock

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: BSD-3-Clause Imports: 5 Imported by: 2

Documentation

Overview

Package mock provides a mock implementation for the accounting interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAccounting

func NewAccounting(opts ...Option) accounting.Interface

NewAccounting creates the mock accounting implementation

Types

type MockPricer

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

func NewPricer

func NewPricer(price, peerPrice uint64) *MockPricer

func (*MockPricer) PeerPrice

func (pricer *MockPricer) PeerPrice(peer, chunk swarm.Address) uint64

func (*MockPricer) Price

func (pricer *MockPricer) Price(chunk swarm.Address) uint64

type Option

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

Option is the option passed to the mock accounting service

func WithBalanceFunc

func WithBalanceFunc(f func(swarm.Address) (*big.Int, error)) Option

WithBalanceFunc sets the mock Balance function

func WithBalanceSurplusFunc added in v0.4.0

func WithBalanceSurplusFunc(f func(swarm.Address) (*big.Int, error)) Option

WithBalanceSurplusFunc sets the mock SurplusBalance function

func WithBalancesFunc

func WithBalancesFunc(f func() (map[string]*big.Int, error)) Option

WithBalancesFunc sets the mock Balances function

func WithCompensatedBalanceFunc added in v0.4.0

func WithCompensatedBalanceFunc(f func(swarm.Address) (*big.Int, error)) Option

WithCompensatedBalanceFunc sets the mock Balance function

func WithCompensatedBalancesFunc added in v0.4.0

func WithCompensatedBalancesFunc(f func() (map[string]*big.Int, error)) Option

WithCompensatedBalancesFunc sets the mock Balances function

func WithCreditFunc

func WithCreditFunc(f func(peer swarm.Address, price uint64) error) Option

WithCreditFunc sets the mock Credit function

func WithDebitFunc

func WithDebitFunc(f func(peer swarm.Address, price uint64) error) Option

WithDebitFunc sets the mock Debit function

func WithReleaseFunc

func WithReleaseFunc(f func(peer swarm.Address, price uint64)) Option

WithReleaseFunc sets the mock Release function

func WithReserveFunc

func WithReserveFunc(f func(ctx context.Context, peer swarm.Address, price uint64) error) Option

WithReserveFunc sets the mock Reserve function

type Service

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

Service is the mock Accounting service.

func (*Service) Balance

func (s *Service) Balance(peer swarm.Address) (*big.Int, error)

Balance is the mock function wrapper that calls the set implementation

func (*Service) Balances

func (s *Service) Balances() (map[string]*big.Int, error)

Balances is the mock function wrapper that calls the set implementation

func (*Service) CompensatedBalance added in v0.4.0

func (s *Service) CompensatedBalance(peer swarm.Address) (*big.Int, error)

CompensatedBalance is the mock function wrapper that calls the set implementation

func (*Service) CompensatedBalances added in v0.4.0

func (s *Service) CompensatedBalances() (map[string]*big.Int, error)

CompensatedBalances is the mock function wrapper that calls the set implementation

func (*Service) Credit

func (s *Service) Credit(peer swarm.Address, price uint64) error

Credit is the mock function wrapper that calls the set implementation

func (*Service) Debit

func (s *Service) Debit(peer swarm.Address, price uint64) error

Debit is the mock function wrapper that calls the set implementation

func (*Service) Release

func (s *Service) Release(peer swarm.Address, price uint64)

Release is the mock function wrapper that calls the set implementation

func (*Service) Reserve

func (s *Service) Reserve(ctx context.Context, peer swarm.Address, price uint64) error

Reserve is the mock function wrapper that calls the set implementation

func (*Service) SurplusBalance added in v0.4.0

func (s *Service) SurplusBalance(peer swarm.Address) (*big.Int, error)

Jump to

Keyboard shortcuts

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