testqueryclients

package
v0.1.30 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package testqueryclients provides helper functions for contstructing mock AccountQueryClient objects parameterized call arguments, return value(s), and/or expectations thereof. Intended for use in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAddressToApplicationMap

func AddAddressToApplicationMap(
	t *testing.T,
	address string, pubkey cryptotypes.PubKey,
	delegateeAccounts map[string]cryptotypes.PubKey,
)

AddAddressToApplicationMap adds the given address to the addressApplicationMap with the given delegated gateways addresses. It also adds it to the addressAccountMap so that the account will be deemed to exist on chain.

func AddSuppliersWithServiceEndpoints

func AddSuppliersWithServiceEndpoints(
	t *testing.T,
	supplierOperatorAddress, service string,
	endpoints []*sharedtypes.SupplierEndpoint,
)

AddSupplierWithServiceEndpoints adds the given address and ServiceEndpoints to the suppliersProvidedServicesMap to mock it "existing" on chain, it will also remove the address from the map when the test is cleaned up.

func AddToExistingServices added in v0.0.8

func AddToExistingServices(
	t *testing.T,
	service sharedtypes.Service,
)

AddToExistingServices adds the given service to the services map to mock it "existing" on chain, it will also remove the services from the map when the test is cleaned up.

func AddToExistingSessions

func AddToExistingSessions(
	t *testing.T,
	appAddress string,
	serviceId string,
	blockHeight int64,
	supplierOperatorAddresses []string,
)

AddToExistingSessions adds the given session to the sessionsMap to mock it "existing" on chain, it will also remove the sessions from the map when the test is cleaned up.

func NewTestAccountQueryClient

func NewTestAccountQueryClient(
	t *testing.T,
) *mockclient.MockAccountQueryClient

NewTestAccountQueryClient creates a mock of the AccountQueryClient which allows the caller to call GetApplication any times and will return an application with the given address.

func NewTestApplicationQueryClient

func NewTestApplicationQueryClient(
	t *testing.T,
) *mockclient.MockApplicationQueryClient

NewTestApplicationQueryClient creates a mock of the ApplicationQueryClient which allows the caller to call GetApplication any times and will return an application with the given address.

func NewTestBankQueryClientWithBalance added in v0.0.10

func NewTestBankQueryClientWithBalance(t *testing.T, balance int64) *mockclient.MockBankQueryClient

NewTestBankQueryClientWithWithBalance creates a mock of the BankQueryClient that uses the provided balance for its GetBalance() method implementation.

func NewTestProofQueryClient added in v0.0.3

func NewTestProofQueryClient(t *testing.T) *mockclient.MockProofQueryClient

NewTestProofQueryClient creates a mock of the ProofQueryClient which uses the default proof module params for its GetParams() method implementation.

func NewTestProofQueryClientWithParams added in v0.0.8

func NewTestProofQueryClientWithParams(t *testing.T, params client.ProofParams) *mockclient.MockProofQueryClient

NewTestProofQueryClientWithParams creates a mock of the ProofQueryClient that uses the provided proof module params for its GetParams() method implementation.

func NewTestServiceQueryClient added in v0.0.8

func NewTestServiceQueryClient(
	t *testing.T,
) *mockclient.MockServiceQueryClient

NewTestSessionQueryClient creates a mock of the SessionQueryClient which allows the caller to call GetSession any times and will return the session matching the app address, serviceID and the blockHeight passed.

func NewTestSessionQueryClient

func NewTestSessionQueryClient(
	t *testing.T,
) *mockclient.MockSessionQueryClient

NewTestSessionQueryClient creates a mock of the SessionQueryClient which allows the caller to call GetSession any times and will return the session matching the app address, serviceID and the blockHeight passed.

func NewTestSharedQueryClient added in v0.0.3

func NewTestSharedQueryClient(
	t *testing.T,
) *mockclient.MockSharedQueryClient

NewTestSharedQueryClient creates a mock of the SharedQueryClient which uses the default shared module params for its implementation.

func NewTestSupplierQueryClient

func NewTestSupplierQueryClient(
	t *testing.T,
) *mockclient.MockSupplierQueryClient

NewTestSupplierQueryClient creates a mock of the SupplierQueryClient which allows the caller to call GetSupplier any times and will return an application with the given address.

func RemoveAddressFromApplicationMap

func RemoveAddressFromApplicationMap(t *testing.T, address string)

RemoveAddressFromApplicationMap removes the given address from the addressApplicationMap.

func SetServiceRelayDifficultyTargetHash added in v0.0.8

func SetServiceRelayDifficultyTargetHash(t *testing.T,
	serviceId string,
	relayDifficultyTargetHash []byte,
)

AddServiceRelayDifficultyTargetHash sets the relay difficulty target hash for the given service to mock it "existing" on chain. It will also remove the service relay difficulty target hashes from the map when the test is cleaned up.

Types

type MockAccountQueryServer added in v0.0.14

type MockAccountQueryServer struct {
	authtypes.UnimplementedQueryServer
	AccountCallCounter callCounter
}

MockAccountQueryServer is a mock implementation of the authtypes.QueryServer interface that keeps track of the number of times each method is called.

func (*MockAccountQueryServer) Account added in v0.0.14

type MockApplicationQueryServer added in v0.0.14

type MockApplicationQueryServer struct {
	apptypes.UnimplementedQueryServer
	AppCallCounter    callCounter
	ParamsCallCounter callCounter
}

MockApplicationQueryServer is a mock implementation of the apptypes.QueryServer interface that keeps track of the number of times each method is called.

func (*MockApplicationQueryServer) Application added in v0.0.14

func (*MockApplicationQueryServer) Params added in v0.0.14

type MockBankQueryServer added in v0.0.14

type MockBankQueryServer struct {
	banktypes.UnimplementedQueryServer
	BalanceCallCounter callCounter
}

MockBankQueryServer is a mock implementation of the banktypes.QueryServer interface that keeps track of the number of times each method is called.

func (*MockBankQueryServer) Balance added in v0.0.14

type MockProofQueryServer added in v0.0.14

type MockProofQueryServer struct {
	prooftypes.UnimplementedQueryServer
	ParamsCallCounter callCounter
}

MockProofQueryServer is a mock implementation of the prooftypes.QueryServer interface that keeps track of the number of times each method is called.

func (*MockProofQueryServer) Params added in v0.0.14

type MockServiceQueryServer added in v0.0.14

type MockServiceQueryServer struct {
	servicetypes.UnimplementedQueryServer
	ServiceCallCounter               callCounter
	RelayMiningDifficultyCallCounter callCounter
}

MockServiceQueryServer is a mock implementation of the servicetypes.QueryServer interface that keeps track of the number of times each method is called.

func (*MockServiceQueryServer) Service added in v0.0.14

type MockSessionQueryServer added in v0.0.14

type MockSessionQueryServer struct {
	sessiontypes.UnimplementedQueryServer
	SessionCallCounter callCounter
	ParamsCallCounter  callCounter
}

MockSessionQueryServer is a mock implementation of the sessiontypes.QueryServer interface that keeps track of the number of times each method is called.

func (*MockSessionQueryServer) GetSession added in v0.0.14

func (*MockSessionQueryServer) Params added in v0.0.14

type MockSharedQueryServer added in v0.0.14

type MockSharedQueryServer struct {
	sharedtypes.UnimplementedQueryServer
	ParamsCallCounter callCounter
}

MockSharedQueryServer is a mock implementation of the sharedtypes.QueryServer interface that keeps track of the number of times each method is called.

func (*MockSharedQueryServer) Params added in v0.0.14

type MockSupplierQueryServer added in v0.0.14

type MockSupplierQueryServer struct {
	suppliertypes.UnimplementedQueryServer
	SupplierCallCounter callCounter
}

MockSupplierQueryServer is a mock implementation of the suppliertypes.QueryServer interface that keeps track of the number of times each method is called.

func (*MockSupplierQueryServer) Supplier added in v0.0.14

Jump to

Keyboard shortcuts

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