Documentation ¶
Overview ¶
Package mock provides a mock implementation of the privatebtc package for testing purposes.
Index ¶
- type NodeHandler
- func (mock *NodeHandler) Close() error
- func (mock *NodeHandler) CloseCalls() []struct{}
- func (mock *NodeHandler) HostRPCPort() string
- func (mock *NodeHandler) HostRPCPortCalls() []struct{}
- func (mock *NodeHandler) InternalIP() string
- func (mock *NodeHandler) InternalIPCalls() []struct{}
- func (mock *NodeHandler) Name() string
- func (mock *NodeHandler) NameCalls() []struct{}
- type NodeService
- type RPCClient
- func (mock *RPCClient) AddPeer(ctx context.Context, peer privatebtc.Node) error
- func (mock *RPCClient) AddPeerCalls() []struct{ ... }
- func (mock *RPCClient) CreateWallet(ctx context.Context, walletName string) error
- func (mock *RPCClient) CreateWalletCalls() []struct{ ... }
- func (mock *RPCClient) GenerateToAddress(ctx context.Context, numBlocks int64, address string) ([]string, error)
- func (mock *RPCClient) GenerateToAddressCalls() []struct{ ... }
- func (mock *RPCClient) GetBalance(ctx context.Context) (privatebtc.Balance, error)
- func (mock *RPCClient) GetBalanceCalls() []struct{ ... }
- func (mock *RPCClient) GetBestBlockHash(ctx context.Context) (string, error)
- func (mock *RPCClient) GetBestBlockHashCalls() []struct{ ... }
- func (mock *RPCClient) GetBlockCount(ctx context.Context) (int, error)
- func (mock *RPCClient) GetBlockCountCalls() []struct{ ... }
- func (mock *RPCClient) GetCoinbaseValue(ctx context.Context) (int64, error)
- func (mock *RPCClient) GetCoinbaseValueCalls() []struct{ ... }
- func (mock *RPCClient) GetConnectionCount(ctx context.Context) (int, error)
- func (mock *RPCClient) GetConnectionCountCalls() []struct{ ... }
- func (mock *RPCClient) GetNewAddress(ctx context.Context, label string) (string, error)
- func (mock *RPCClient) GetNewAddressCalls() []struct{ ... }
- func (mock *RPCClient) GetRawMempool(ctx context.Context) ([]string, error)
- func (mock *RPCClient) GetRawMempoolCalls() []struct{ ... }
- func (mock *RPCClient) GetTransaction(ctx context.Context, txHash string) (*privatebtc.Transaction, error)
- func (mock *RPCClient) GetTransactionCalls() []struct{ ... }
- func (mock *RPCClient) ListAddresses(ctx context.Context) ([]string, error)
- func (mock *RPCClient) ListAddressesCalls() []struct{ ... }
- func (mock *RPCClient) RemovePeer(ctx context.Context, peer privatebtc.Node) error
- func (mock *RPCClient) RemovePeerCalls() []struct{ ... }
- func (mock *RPCClient) SendCustomTransaction(ctx context.Context, inputs []privatebtc.TransactionVin, ...) (string, error)
- func (mock *RPCClient) SendCustomTransactionCalls() []struct{ ... }
- func (mock *RPCClient) SendToAddress(ctx context.Context, address string, amount float64) (string, error)
- func (mock *RPCClient) SendToAddressCalls() []struct{ ... }
- type RPCClientFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NodeHandler ¶
type NodeHandler struct { // CloseFunc mocks the Close method. CloseFunc func() error // HostRPCPortFunc mocks the HostRPCPort method. HostRPCPortFunc func() string // InternalIPFunc mocks the InternalIP method. InternalIPFunc func() string // NameFunc mocks the Name method. NameFunc func() string // contains filtered or unexported fields }
NodeHandler is a mock implementation of privatebtc.NodeHandler.
func TestSomethingThatUsesNodeHandler(t *testing.T) { // make and configure a mocked privatebtc.NodeHandler mockedNodeHandler := &NodeHandler{ CloseFunc: func() error { panic("mock out the Close method") }, HostRPCPortFunc: func() string { panic("mock out the HostRPCPort method") }, InternalIPFunc: func() string { panic("mock out the InternalIP method") }, NameFunc: func() string { panic("mock out the Name method") }, } // use mockedNodeHandler in code that requires privatebtc.NodeHandler // and then make assertions. }
func (*NodeHandler) CloseCalls ¶
func (mock *NodeHandler) CloseCalls() []struct { }
CloseCalls gets all the calls that were made to Close. Check the length with:
len(mockedNodeHandler.CloseCalls())
func (*NodeHandler) HostRPCPort ¶
func (mock *NodeHandler) HostRPCPort() string
HostRPCPort calls HostRPCPortFunc.
func (*NodeHandler) HostRPCPortCalls ¶
func (mock *NodeHandler) HostRPCPortCalls() []struct { }
HostRPCPortCalls gets all the calls that were made to HostRPCPort. Check the length with:
len(mockedNodeHandler.HostRPCPortCalls())
func (*NodeHandler) InternalIP ¶
func (mock *NodeHandler) InternalIP() string
InternalIP calls InternalIPFunc.
func (*NodeHandler) InternalIPCalls ¶
func (mock *NodeHandler) InternalIPCalls() []struct { }
InternalIPCalls gets all the calls that were made to InternalIP. Check the length with:
len(mockedNodeHandler.InternalIPCalls())
func (*NodeHandler) NameCalls ¶
func (mock *NodeHandler) NameCalls() []struct { }
NameCalls gets all the calls that were made to Name. Check the length with:
len(mockedNodeHandler.NameCalls())
type NodeService ¶
type NodeService struct { // CreateNodesFunc mocks the CreateNodes method. CreateNodesFunc func(ctx context.Context, nodeRequests []privatebtc.CreateNodeRequest) ([]privatebtc.NodeHandler, error) // contains filtered or unexported fields }
NodeService is a mock implementation of privatebtc.NodeService.
func TestSomethingThatUsesNodeService(t *testing.T) { // make and configure a mocked privatebtc.NodeService mockedNodeService := &NodeService{ CreateNodesFunc: func(ctx context.Context, nodeRequests []privatebtc.CreateNodeRequest) ([]privatebtc.NodeHandler, error) { panic("mock out the CreateNodes method") }, } // use mockedNodeService in code that requires privatebtc.NodeService // and then make assertions. }
func (*NodeService) CreateNodes ¶
func (mock *NodeService) CreateNodes(ctx context.Context, nodeRequests []privatebtc.CreateNodeRequest) ([]privatebtc.NodeHandler, error)
CreateNodes calls CreateNodesFunc.
func (*NodeService) CreateNodesCalls ¶
func (mock *NodeService) CreateNodesCalls() []struct { Ctx context.Context NodeRequests []privatebtc.CreateNodeRequest }
CreateNodesCalls gets all the calls that were made to CreateNodes. Check the length with:
len(mockedNodeService.CreateNodesCalls())
type RPCClient ¶
type RPCClient struct { // AddPeerFunc mocks the AddPeer method. AddPeerFunc func(ctx context.Context, peer privatebtc.Node) error // CreateWalletFunc mocks the CreateWallet method. CreateWalletFunc func(ctx context.Context, walletName string) error // GenerateToAddressFunc mocks the GenerateToAddress method. GenerateToAddressFunc func(ctx context.Context, numBlocks int64, address string) ([]string, error) // GetBalanceFunc mocks the GetBalance method. GetBalanceFunc func(ctx context.Context) (privatebtc.Balance, error) // GetBestBlockHashFunc mocks the GetBestBlockHash method. GetBestBlockHashFunc func(ctx context.Context) (string, error) // GetBlockCountFunc mocks the GetBlockCount method. GetBlockCountFunc func(ctx context.Context) (int, error) // GetCoinbaseValueFunc mocks the GetCoinbaseValue method. GetCoinbaseValueFunc func(ctx context.Context) (int64, error) // GetConnectionCountFunc mocks the GetConnectionCount method. GetConnectionCountFunc func(ctx context.Context) (int, error) // GetNewAddressFunc mocks the GetNewAddress method. GetNewAddressFunc func(ctx context.Context, label string) (string, error) // GetRawMempoolFunc mocks the GetRawMempool method. GetRawMempoolFunc func(ctx context.Context) ([]string, error) // GetTransactionFunc mocks the GetTransaction method. GetTransactionFunc func(ctx context.Context, txHash string) (*privatebtc.Transaction, error) // ListAddressesFunc mocks the ListAddresses method. ListAddressesFunc func(ctx context.Context) ([]string, error) // RemovePeerFunc mocks the RemovePeer method. RemovePeerFunc func(ctx context.Context, peer privatebtc.Node) error // SendCustomTransactionFunc mocks the SendCustomTransaction method. SendCustomTransactionFunc func(ctx context.Context, inputs []privatebtc.TransactionVin, amounts map[string]float64) (string, error) // SendToAddressFunc mocks the SendToAddress method. SendToAddressFunc func(ctx context.Context, address string, amount float64) (string, error) // contains filtered or unexported fields }
RPCClient is a mock implementation of privatebtc.RPCClient.
func TestSomethingThatUsesRPCClient(t *testing.T) { // make and configure a mocked privatebtc.RPCClient mockedRPCClient := &RPCClient{ AddPeerFunc: func(ctx context.Context, peer privatebtc.Node) error { panic("mock out the AddPeer method") }, CreateWalletFunc: func(ctx context.Context, walletName string) error { panic("mock out the CreateWallet method") }, GenerateToAddressFunc: func(ctx context.Context, numBlocks int64, address string) ([]string, error) { panic("mock out the GenerateToAddress method") }, GetBalanceFunc: func(ctx context.Context) (privatebtc.Balance, error) { panic("mock out the GetBalance method") }, GetBestBlockHashFunc: func(ctx context.Context) (string, error) { panic("mock out the GetBestBlockHash method") }, GetBlockCountFunc: func(ctx context.Context) (int, error) { panic("mock out the GetBlockCount method") }, GetCoinbaseValueFunc: func(ctx context.Context) (int64, error) { panic("mock out the GetCoinbaseValue method") }, GetConnectionCountFunc: func(ctx context.Context) (int, error) { panic("mock out the GetConnectionCount method") }, GetNewAddressFunc: func(ctx context.Context, label string) (string, error) { panic("mock out the GetNewAddress method") }, GetRawMempoolFunc: func(ctx context.Context) ([]string, error) { panic("mock out the GetRawMempool method") }, GetTransactionFunc: func(ctx context.Context, txHash string) (*privatebtc.Transaction, error) { panic("mock out the GetTransaction method") }, ListAddressesFunc: func(ctx context.Context) ([]string, error) { panic("mock out the ListAddresses method") }, RemovePeerFunc: func(ctx context.Context, peer privatebtc.Node) error { panic("mock out the RemovePeer method") }, SendCustomTransactionFunc: func(ctx context.Context, inputs []privatebtc.TransactionVin, amounts map[string]float64) (string, error) { panic("mock out the SendCustomTransaction method") }, SendToAddressFunc: func(ctx context.Context, address string, amount float64) (string, error) { panic("mock out the SendToAddress method") }, } // use mockedRPCClient in code that requires privatebtc.RPCClient // and then make assertions. }
func (*RPCClient) AddPeerCalls ¶
func (mock *RPCClient) AddPeerCalls() []struct { Ctx context.Context Peer privatebtc.Node }
AddPeerCalls gets all the calls that were made to AddPeer. Check the length with:
len(mockedRPCClient.AddPeerCalls())
func (*RPCClient) CreateWallet ¶
CreateWallet calls CreateWalletFunc.
func (*RPCClient) CreateWalletCalls ¶
CreateWalletCalls gets all the calls that were made to CreateWallet. Check the length with:
len(mockedRPCClient.CreateWalletCalls())
func (*RPCClient) GenerateToAddress ¶
func (mock *RPCClient) GenerateToAddress(ctx context.Context, numBlocks int64, address string) ([]string, error)
GenerateToAddress calls GenerateToAddressFunc.
func (*RPCClient) GenerateToAddressCalls ¶
func (mock *RPCClient) GenerateToAddressCalls() []struct { Ctx context.Context NumBlocks int64 Address string }
GenerateToAddressCalls gets all the calls that were made to GenerateToAddress. Check the length with:
len(mockedRPCClient.GenerateToAddressCalls())
func (*RPCClient) GetBalance ¶
GetBalance calls GetBalanceFunc.
func (*RPCClient) GetBalanceCalls ¶
GetBalanceCalls gets all the calls that were made to GetBalance. Check the length with:
len(mockedRPCClient.GetBalanceCalls())
func (*RPCClient) GetBestBlockHash ¶
GetBestBlockHash calls GetBestBlockHashFunc.
func (*RPCClient) GetBestBlockHashCalls ¶
GetBestBlockHashCalls gets all the calls that were made to GetBestBlockHash. Check the length with:
len(mockedRPCClient.GetBestBlockHashCalls())
func (*RPCClient) GetBlockCount ¶
GetBlockCount calls GetBlockCountFunc.
func (*RPCClient) GetBlockCountCalls ¶
GetBlockCountCalls gets all the calls that were made to GetBlockCount. Check the length with:
len(mockedRPCClient.GetBlockCountCalls())
func (*RPCClient) GetCoinbaseValue ¶
GetCoinbaseValue calls GetCoinbaseValueFunc.
func (*RPCClient) GetCoinbaseValueCalls ¶
GetCoinbaseValueCalls gets all the calls that were made to GetCoinbaseValue. Check the length with:
len(mockedRPCClient.GetCoinbaseValueCalls())
func (*RPCClient) GetConnectionCount ¶
GetConnectionCount calls GetConnectionCountFunc.
func (*RPCClient) GetConnectionCountCalls ¶
GetConnectionCountCalls gets all the calls that were made to GetConnectionCount. Check the length with:
len(mockedRPCClient.GetConnectionCountCalls())
func (*RPCClient) GetNewAddress ¶
GetNewAddress calls GetNewAddressFunc.
func (*RPCClient) GetNewAddressCalls ¶
GetNewAddressCalls gets all the calls that were made to GetNewAddress. Check the length with:
len(mockedRPCClient.GetNewAddressCalls())
func (*RPCClient) GetRawMempool ¶
GetRawMempool calls GetRawMempoolFunc.
func (*RPCClient) GetRawMempoolCalls ¶
GetRawMempoolCalls gets all the calls that were made to GetRawMempool. Check the length with:
len(mockedRPCClient.GetRawMempoolCalls())
func (*RPCClient) GetTransaction ¶
func (mock *RPCClient) GetTransaction(ctx context.Context, txHash string) (*privatebtc.Transaction, error)
GetTransaction calls GetTransactionFunc.
func (*RPCClient) GetTransactionCalls ¶
GetTransactionCalls gets all the calls that were made to GetTransaction. Check the length with:
len(mockedRPCClient.GetTransactionCalls())
func (*RPCClient) ListAddresses ¶
ListAddresses calls ListAddressesFunc.
func (*RPCClient) ListAddressesCalls ¶
ListAddressesCalls gets all the calls that were made to ListAddresses. Check the length with:
len(mockedRPCClient.ListAddressesCalls())
func (*RPCClient) RemovePeer ¶
RemovePeer calls RemovePeerFunc.
func (*RPCClient) RemovePeerCalls ¶
func (mock *RPCClient) RemovePeerCalls() []struct { Ctx context.Context Peer privatebtc.Node }
RemovePeerCalls gets all the calls that were made to RemovePeer. Check the length with:
len(mockedRPCClient.RemovePeerCalls())
func (*RPCClient) SendCustomTransaction ¶
func (mock *RPCClient) SendCustomTransaction(ctx context.Context, inputs []privatebtc.TransactionVin, amounts map[string]float64) (string, error)
SendCustomTransaction calls SendCustomTransactionFunc.
func (*RPCClient) SendCustomTransactionCalls ¶
func (mock *RPCClient) SendCustomTransactionCalls() []struct { Ctx context.Context Inputs []privatebtc.TransactionVin Amounts map[string]float64 }
SendCustomTransactionCalls gets all the calls that were made to SendCustomTransaction. Check the length with:
len(mockedRPCClient.SendCustomTransactionCalls())
type RPCClientFactory ¶
type RPCClientFactory struct { // NewRPCClientFunc mocks the NewRPCClient method. NewRPCClientFunc func(hostRPCPort string, rpcUser string, rpcPass string) (privatebtc.RPCClient, error) // contains filtered or unexported fields }
RPCClientFactory is a mock implementation of privatebtc.RPCClientFactory.
func TestSomethingThatUsesRPCClientFactory(t *testing.T) { // make and configure a mocked privatebtc.RPCClientFactory mockedRPCClientFactory := &RPCClientFactory{ NewRPCClientFunc: func(hostRPCPort string, rpcUser string, rpcPass string) (privatebtc.RPCClient, error) { panic("mock out the NewRPCClient method") }, } // use mockedRPCClientFactory in code that requires privatebtc.RPCClientFactory // and then make assertions. }
func (*RPCClientFactory) NewRPCClient ¶
func (mock *RPCClientFactory) NewRPCClient(hostRPCPort string, rpcUser string, rpcPass string) (privatebtc.RPCClient, error)
NewRPCClient calls NewRPCClientFunc.
func (*RPCClientFactory) NewRPCClientCalls ¶
func (mock *RPCClientFactory) NewRPCClientCalls() []struct { HostRPCPort string RpcUser string RpcPass string }
NewRPCClientCalls gets all the calls that were made to NewRPCClient. Check the length with:
len(mockedRPCClientFactory.NewRPCClientCalls())