mock

package
v0.8.14 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ABCIApp

type ABCIApp struct {
	App abci.Application
}

ABCIApp will send all abci related request to the named app, so you can test app behavior from a client without needing an entire tendermint node

func (ABCIApp) ABCIInfo

func (a ABCIApp) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error)

func (ABCIApp) ABCIQuery

func (a ABCIApp) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error)

func (ABCIApp) ABCIQueryWithOptions

func (a ABCIApp) ABCIQueryWithOptions(
	ctx context.Context,
	path string,
	data bytes.HexBytes,
	opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)

func (ABCIApp) BroadcastTxAsync

func (a ABCIApp) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

func (ABCIApp) BroadcastTxCommit

func (a ABCIApp) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)

NOTE: Caller should call a.App.Commit() separately, this function does not actually wait for a commit. TODO: Make it wait for a commit and set res.Height appropriately.

func (ABCIApp) BroadcastTxSync

func (a ABCIApp) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

type ABCIMock

type ABCIMock struct {
	Info            Call
	Query           Call
	BroadcastCommit Call
	Broadcast       Call
}

ABCIMock will send all abci related request to the named app, so you can test app behavior from a client without needing an entire tendermint node

func (ABCIMock) ABCIInfo

func (m ABCIMock) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error)

func (ABCIMock) ABCIQuery

func (m ABCIMock) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error)

func (ABCIMock) ABCIQueryWithOptions

func (m ABCIMock) ABCIQueryWithOptions(
	ctx context.Context,
	path string,
	data bytes.HexBytes,
	opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)

func (ABCIMock) BroadcastTxAsync

func (m ABCIMock) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

func (ABCIMock) BroadcastTxCommit

func (m ABCIMock) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)

func (ABCIMock) BroadcastTxSync

func (m ABCIMock) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

type ABCIRecorder

type ABCIRecorder struct {
	Client client.ABCIClient
	Calls  []Call
}

ABCIRecorder can wrap another type (ABCIApp, ABCIMock, or Client) and record all ABCI related calls.

func NewABCIRecorder

func NewABCIRecorder(client client.ABCIClient) *ABCIRecorder

func (*ABCIRecorder) ABCIInfo

func (r *ABCIRecorder) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error)

func (*ABCIRecorder) ABCIQuery

func (r *ABCIRecorder) ABCIQuery(
	ctx context.Context,
	path string,
	data bytes.HexBytes,
) (*ctypes.ResultABCIQuery, error)

func (*ABCIRecorder) ABCIQueryWithOptions

func (r *ABCIRecorder) ABCIQueryWithOptions(
	ctx context.Context,
	path string,
	data bytes.HexBytes,
	opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)

func (*ABCIRecorder) BroadcastTxAsync

func (r *ABCIRecorder) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

func (*ABCIRecorder) BroadcastTxCommit

func (r *ABCIRecorder) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)

func (*ABCIRecorder) BroadcastTxSync

func (r *ABCIRecorder) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

type Call

type Call struct {
	Name     string
	Args     interface{}
	Response interface{}
	Error    error
}

Call is used by recorders to save a call and response. It can also be used to configure mock responses.

func (Call) GetResponse

func (c Call) GetResponse(args interface{}) (interface{}, error)

GetResponse will generate the apporiate response for us, when using the Call struct to configure a Mock handler.

When configuring a response, if only one of Response or Error is set then that will always be returned. If both are set, then we return Response if the Args match the set args, Error otherwise.

type Client

Client wraps arbitrary implementations of the various interfaces.

func New

func New() Client

func (Client) ABCIInfo

func (c Client) ABCIInfo(ctx context.Context) (*ctypes.ResultABCIInfo, error)

func (Client) ABCIQuery

func (c Client) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*ctypes.ResultABCIQuery, error)

func (Client) ABCIQueryWithOptions

func (c Client) ABCIQueryWithOptions(
	ctx context.Context,
	path string,
	data bytes.HexBytes,
	opts client.ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)

func (Client) Block

func (c Client) Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error)

func (Client) BlockByHash

func (c Client) BlockByHash(ctx context.Context, hash []byte) (*ctypes.ResultBlock, error)

func (Client) BlockchainInfo

func (c Client) BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*ctypes.ResultBlockchainInfo, error)

func (Client) BroadcastEvidence

func (c Client) BroadcastEvidence(ctx context.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error)

func (Client) BroadcastTxAsync

func (c Client) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

func (Client) BroadcastTxCommit

func (c Client) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error)

func (Client) BroadcastTxSync

func (c Client) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error)

func (Client) CheckTx

func (c Client) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error)

func (Client) Commit

func (c Client) Commit(ctx context.Context, height *int64) (*ctypes.ResultCommit, error)

func (Client) ConsensusParams

func (c Client) ConsensusParams(ctx context.Context, height *int64) (*ctypes.ResultConsensusParams, error)

func (Client) ConsensusState

func (c Client) ConsensusState(ctx context.Context) (*ctypes.ResultConsensusState, error)

func (Client) DialPeers

func (c Client) DialPeers(
	ctx context.Context,
	peers []string,
	persistent,
	unconditional,
	private bool,
) (*ctypes.ResultDialPeers, error)

func (Client) DialSeeds

func (c Client) DialSeeds(ctx context.Context, seeds []string) (*ctypes.ResultDialSeeds, error)

func (Client) DumpConsensusState

func (c Client) DumpConsensusState(ctx context.Context) (*ctypes.ResultDumpConsensusState, error)

func (Client) Genesis

func (c Client) Genesis(ctx context.Context) (*ctypes.ResultGenesis, error)

func (Client) Health

func (c Client) Health(ctx context.Context) (*ctypes.ResultHealth, error)

func (Client) NetInfo

func (c Client) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, error)

func (Client) Status

func (c Client) Status(ctx context.Context) (*ctypes.ResultStatus, error)

func (Client) Validators

func (c Client) Validators(ctx context.Context, height *int64, page, perPage *int) (*ctypes.ResultValidators, error)

type QueryArgs

type QueryArgs struct {
	Path   string
	Data   bytes.HexBytes
	Height int64
	Prove  bool
}

type StatusMock

type StatusMock struct {
	Call
}

StatusMock returns the result specified by the Call

func (*StatusMock) Status

func (m *StatusMock) Status(ctx context.Context) (*ctypes.ResultStatus, error)

type StatusRecorder

type StatusRecorder struct {
	Client client.StatusClient
	Calls  []Call
}

StatusRecorder can wrap another type (StatusMock, full client) and record the status calls

func NewStatusRecorder

func NewStatusRecorder(client client.StatusClient) *StatusRecorder

func (*StatusRecorder) Status

Jump to

Keyboard shortcuts

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