Documentation ¶
Overview ¶
Package mock provides a mock implementation for the accounting interface.
Index ¶
- type Option
- func WithBalanceFunc(f func(swarm.Address) (*big.Int, error)) Option
- func WithBalanceSurplusFunc(f func(swarm.Address) (*big.Int, error)) Option
- func WithBalancesFunc(f func() (map[string]*big.Int, error)) Option
- func WithCompensatedBalanceFunc(f func(swarm.Address) (*big.Int, error)) Option
- func WithCompensatedBalancesFunc(f func() (map[string]*big.Int, error)) Option
- func WithPeerAccountingFunc(f func() (map[string]accounting.PeerInfo, error)) Option
- func WithPrepareCreditFunc(...) Option
- func WithPrepareDebitFunc(f func(peer swarm.Address, price uint64) (accounting.Action, error)) Option
- type Service
- func (s *Service) Balance(peer swarm.Address) (*big.Int, error)
- func (s *Service) Balances() (map[string]*big.Int, error)
- func (s *Service) CompensatedBalance(peer swarm.Address) (*big.Int, error)
- func (s *Service) CompensatedBalances() (map[string]*big.Int, error)
- func (s *Service) Connect(peer swarm.Address, full bool)
- func (s *Service) Disconnect(peer swarm.Address)
- func (s *Service) MakeCreditAction(peer swarm.Address, price uint64) accounting.Action
- func (s *Service) PeerAccounting() (map[string]accounting.PeerInfo, error)
- func (s *Service) PrepareCredit(_ context.Context, peer swarm.Address, price uint64, originated bool) (accounting.Action, error)
- func (s *Service) PrepareDebit(_ context.Context, peer swarm.Address, price uint64) (accounting.Action, error)
- func (s *Service) ShadowBalance(peer swarm.Address) (*big.Int, error)
- func (s *Service) SurplusBalance(peer swarm.Address) (*big.Int, error)
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
}
Option is the option passed to the mock accounting service
func WithBalanceFunc ¶
WithBalanceFunc sets the mock Balance function
func WithBalanceSurplusFunc ¶
WithBalanceSurplusFunc sets the mock SurplusBalance function
func WithBalancesFunc ¶
WithBalancesFunc sets the mock Balances function
func WithCompensatedBalanceFunc ¶
WithCompensatedBalanceFunc sets the mock Balance function
func WithCompensatedBalancesFunc ¶
WithCompensatedBalancesFunc sets the mock Balances function
func WithPeerAccountingFunc ¶
func WithPeerAccountingFunc(f func() (map[string]accounting.PeerInfo, error)) Option
func WithPrepareCreditFunc ¶
func WithPrepareCreditFunc(f func(peer swarm.Address, price uint64, originated bool) (accounting.Action, error)) Option
WithDebitFunc sets the mock Debit function
func WithPrepareDebitFunc ¶
func WithPrepareDebitFunc(f func(peer swarm.Address, price uint64) (accounting.Action, error)) Option
WithDebitFunc sets the mock Debit function
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the mock Accounting service.
func NewAccounting ¶
NewAccounting creates the mock accounting implementation
func (*Service) CompensatedBalance ¶
CompensatedBalance is the mock function wrapper that calls the set implementation
func (*Service) CompensatedBalances ¶
CompensatedBalances is the mock function wrapper that calls the set implementation
func (*Service) Disconnect ¶
func (*Service) MakeCreditAction ¶
func (*Service) PeerAccounting ¶
func (s *Service) PeerAccounting() (map[string]accounting.PeerInfo, error)
func (*Service) PrepareCredit ¶
func (*Service) PrepareDebit ¶
func (s *Service) PrepareDebit(_ context.Context, peer swarm.Address, price uint64) (accounting.Action, error)
Debit is the mock function wrapper that calls the set implementation