Documentation ¶
Overview ¶
Package mock provides a mock implementation for the accounting interface.
Index ¶
- func NewAccounting(opts ...Option) accounting.Interface
- type Option
- func WithBalanceFunc(f func(penguin.Address) (*big.Int, error)) Option
- func WithBalanceSurplusFunc(f func(penguin.Address) (*big.Int, error)) Option
- func WithBalancesFunc(f func() (map[string]*big.Int, error)) Option
- func WithCompensatedBalanceFunc(f func(penguin.Address) (*big.Int, error)) Option
- func WithCompensatedBalancesFunc(f func() (map[string]*big.Int, error)) Option
- func WithCreditFunc(f func(peer penguin.Address, price uint64) error) Option
- func WithPrepareDebitFunc(f func(peer penguin.Address, price uint64) accounting.Action) Option
- func WithReleaseFunc(f func(peer penguin.Address, price uint64)) Option
- func WithReserveFunc(f func(ctx context.Context, peer penguin.Address, price uint64) error) Option
- type Service
- func (s *Service) Balance(peer penguin.Address) (*big.Int, error)
- func (s *Service) Balances() (map[string]*big.Int, error)
- func (s *Service) CompensatedBalance(peer penguin.Address) (*big.Int, error)
- func (s *Service) CompensatedBalances() (map[string]*big.Int, error)
- func (s *Service) Credit(peer penguin.Address, price uint64) error
- func (s *Service) PrepareDebit(peer penguin.Address, price uint64) accounting.Action
- func (s *Service) Release(peer penguin.Address, price uint64)
- func (s *Service) Reserve(ctx context.Context, peer penguin.Address, price uint64) error
- func (s *Service) ShadowBalance(peer penguin.Address) (*big.Int, error)
- func (s *Service) SurplusBalance(peer penguin.Address) (*big.Int, error)
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 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 WithCreditFunc ¶
WithCreditFunc sets the mock Credit function
func WithPrepareDebitFunc ¶
WithDebitFunc sets the mock Debit function
func WithReleaseFunc ¶
WithReleaseFunc sets the mock Release function
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the mock Accounting service.
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) PrepareDebit ¶
Debit is the mock function wrapper that calls the set implementation