mock

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package mock provides a mock implementation of the privatebtc package for testing purposes.

Index

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) Close

func (mock *NodeHandler) Close() error

Close calls CloseFunc.

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) Name

func (mock *NodeHandler) Name() string

Name calls NameFunc.

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) AddPeer

func (mock *RPCClient) AddPeer(ctx context.Context, peer privatebtc.Node) error

AddPeer calls AddPeerFunc.

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

func (mock *RPCClient) CreateWallet(ctx context.Context, walletName string) error

CreateWallet calls CreateWalletFunc.

func (*RPCClient) CreateWalletCalls

func (mock *RPCClient) CreateWalletCalls() []struct {
	Ctx        context.Context
	WalletName string
}

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

func (mock *RPCClient) GetBalance(ctx context.Context) (privatebtc.Balance, error)

GetBalance calls GetBalanceFunc.

func (*RPCClient) GetBalanceCalls

func (mock *RPCClient) GetBalanceCalls() []struct {
	Ctx context.Context
}

GetBalanceCalls gets all the calls that were made to GetBalance. Check the length with:

len(mockedRPCClient.GetBalanceCalls())

func (*RPCClient) GetBestBlockHash

func (mock *RPCClient) GetBestBlockHash(ctx context.Context) (string, error)

GetBestBlockHash calls GetBestBlockHashFunc.

func (*RPCClient) GetBestBlockHashCalls

func (mock *RPCClient) GetBestBlockHashCalls() []struct {
	Ctx context.Context
}

GetBestBlockHashCalls gets all the calls that were made to GetBestBlockHash. Check the length with:

len(mockedRPCClient.GetBestBlockHashCalls())

func (*RPCClient) GetBlockCount

func (mock *RPCClient) GetBlockCount(ctx context.Context) (int, error)

GetBlockCount calls GetBlockCountFunc.

func (*RPCClient) GetBlockCountCalls

func (mock *RPCClient) GetBlockCountCalls() []struct {
	Ctx context.Context
}

GetBlockCountCalls gets all the calls that were made to GetBlockCount. Check the length with:

len(mockedRPCClient.GetBlockCountCalls())

func (*RPCClient) GetCoinbaseValue

func (mock *RPCClient) GetCoinbaseValue(ctx context.Context) (int64, error)

GetCoinbaseValue calls GetCoinbaseValueFunc.

func (*RPCClient) GetCoinbaseValueCalls

func (mock *RPCClient) GetCoinbaseValueCalls() []struct {
	Ctx context.Context
}

GetCoinbaseValueCalls gets all the calls that were made to GetCoinbaseValue. Check the length with:

len(mockedRPCClient.GetCoinbaseValueCalls())

func (*RPCClient) GetConnectionCount

func (mock *RPCClient) GetConnectionCount(ctx context.Context) (int, error)

GetConnectionCount calls GetConnectionCountFunc.

func (*RPCClient) GetConnectionCountCalls

func (mock *RPCClient) GetConnectionCountCalls() []struct {
	Ctx context.Context
}

GetConnectionCountCalls gets all the calls that were made to GetConnectionCount. Check the length with:

len(mockedRPCClient.GetConnectionCountCalls())

func (*RPCClient) GetNewAddress

func (mock *RPCClient) GetNewAddress(ctx context.Context, label string) (string, error)

GetNewAddress calls GetNewAddressFunc.

func (*RPCClient) GetNewAddressCalls

func (mock *RPCClient) GetNewAddressCalls() []struct {
	Ctx   context.Context
	Label string
}

GetNewAddressCalls gets all the calls that were made to GetNewAddress. Check the length with:

len(mockedRPCClient.GetNewAddressCalls())

func (*RPCClient) GetRawMempool

func (mock *RPCClient) GetRawMempool(ctx context.Context) ([]string, error)

GetRawMempool calls GetRawMempoolFunc.

func (*RPCClient) GetRawMempoolCalls

func (mock *RPCClient) GetRawMempoolCalls() []struct {
	Ctx context.Context
}

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

func (mock *RPCClient) GetTransactionCalls() []struct {
	Ctx    context.Context
	TxHash string
}

GetTransactionCalls gets all the calls that were made to GetTransaction. Check the length with:

len(mockedRPCClient.GetTransactionCalls())

func (*RPCClient) ListAddresses

func (mock *RPCClient) ListAddresses(ctx context.Context) ([]string, error)

ListAddresses calls ListAddressesFunc.

func (*RPCClient) ListAddressesCalls

func (mock *RPCClient) ListAddressesCalls() []struct {
	Ctx context.Context
}

ListAddressesCalls gets all the calls that were made to ListAddresses. Check the length with:

len(mockedRPCClient.ListAddressesCalls())

func (*RPCClient) RemovePeer

func (mock *RPCClient) RemovePeer(ctx context.Context, peer privatebtc.Node) error

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())

func (*RPCClient) SendToAddress

func (mock *RPCClient) SendToAddress(ctx context.Context, address string, amount float64) (string, error)

SendToAddress calls SendToAddressFunc.

func (*RPCClient) SendToAddressCalls

func (mock *RPCClient) SendToAddressCalls() []struct {
	Ctx     context.Context
	Address string
	Amount  float64
}

SendToAddressCalls gets all the calls that were made to SendToAddress. Check the length with:

len(mockedRPCClient.SendToAddressCalls())

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())

Jump to

Keyboard shortcuts

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