mock

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package mock provides a mock implementation for the bookkeeper interface.

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
}

Option is the option passed to the mock bookkeeper service

func WithBalanceFunc

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

WithBalanceFunc sets the mock Balance function

func WithBalanceSurplusFunc

func WithBalanceSurplusFunc(f func(cluster.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

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

WithCompensatedBalanceFunc sets the mock Balance function

func WithCompensatedBalancesFunc

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

WithCompensatedBalancesFunc sets the mock Balances function

func WithPeerAccountingFunc

func WithPeerAccountingFunc(f func() (map[string]bookkeeper.PeerInfo, error)) Option

func WithPrepareCreditFunc

func WithPrepareCreditFunc(f func(peer cluster.Address, price uint64, originated bool) (bookkeeper.Action, error)) Option

WithDebitFunc sets the mock Debit function

func WithPrepareDebitFunc

func WithPrepareDebitFunc(f func(peer cluster.Address, price uint64) (bookkeeper.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

func NewAccounting(opts ...Option) *Service

NewAccounting creates the mock bookkeeper implementation

func (*Service) Balance

func (s *Service) Balance(peer cluster.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

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

CompensatedBalance is the mock function wrapper that calls the set implementation

func (*Service) CompensatedBalances

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

CompensatedBalances is the mock function wrapper that calls the set implementation

func (*Service) Connect

func (s *Service) Connect(peer cluster.Address, full bool)

func (*Service) Disconnect

func (s *Service) Disconnect(peer cluster.Address)

func (*Service) MakeCreditAction

func (s *Service) MakeCreditAction(peer cluster.Address, price uint64) bookkeeper.Action

func (*Service) PeerAccounting

func (s *Service) PeerAccounting() (map[string]bookkeeper.PeerInfo, error)

func (*Service) PrepareCredit

func (s *Service) PrepareCredit(_ context.Context, peer cluster.Address, price uint64, originated bool) (bookkeeper.Action, error)

func (*Service) PrepareDebit

func (s *Service) PrepareDebit(_ context.Context, peer cluster.Address, price uint64) (bookkeeper.Action, error)

Debit is the mock function wrapper that calls the set implementation

func (*Service) ShadowBalance

func (s *Service) ShadowBalance(peer cluster.Address) (*big.Int, error)

func (*Service) SurplusBalance

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

Jump to

Keyboard shortcuts

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