Documentation
¶
Index ¶
- Variables
- func AddAccToAccMapCoins(t *testing.T, addr, denom string, amount uint64)
- func AddGatewayToStakedGatewayMap(t *testing.T, gatewayAddr string)
- func ApplicationKeeper(t testing.TB) (keeper.Keeper, context.Context)
- func AssertDefaultParamsEqualExceptFields[P any](t *testing.T, expectedParams P, actualParams P, exceptFields ...string)
- func GatewayKeeper(t testing.TB) (keeper.Keeper, context.Context)
- func ProofKeeper(t testing.TB) (keeper.Keeper, context.Context)
- func RemoveGatewayFromStakedGatewayMap(t *testing.T, gatewayAddr string)
- func ServiceKeeper(t testing.TB) (keeper.Keeper, context.Context)
- func SessionKeeper(t testing.TB) (keeper.Keeper, context.Context)
- func SetBlockHash(ctx context.Context, hash []byte) context.Context
- func SetBlockHeight(ctx context.Context, height int64) context.Context
- func SharedKeeper(t testing.TB) (keeper.Keeper, sdk.Context)
- func TokenomicsKeeper(t testing.TB) (tokenomicsKeeper tokenomicskeeper.Keeper, ctx context.Context)
- func TokenomicsKeeperWithActorAddrs(t testing.TB) (tokenomicsKeeper tokenomicskeeper.Keeper, ctx context.Context, appAddr string, ...)
- type ApplicationModuleKeepers
- type ProofKeepersOpt
- type ProofModuleKeepers
- type SupplierModuleKeepers
- type TokenomicsModuleKeepers
- type TokenomicsModuleKeepersOpt
Constants ¶
This section is empty.
Variables ¶
var ( TestServiceId1 = "svc1" // staked for by app1 & supplier1 TestServiceId11 = "svc11" // staked for by app1 TestServiceId2 = "svc2" // staked for by app2 & supplier1 TestServiceId22 = "svc22" // staked for by app2 TestServiceId12 = "svc12" // staked for by app1, app2 & supplier1 TestApp1Address = "pokt1mdccn4u38eyjdxkk4h0jaddw4n3c72u82m5m9e" // Generated via sample.AccAddress() TestApp1 = apptypes.Application{ Address: TestApp1Address, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ { Service: &sharedtypes.Service{Id: TestServiceId1}, }, { Service: &sharedtypes.Service{Id: TestServiceId11}, }, { Service: &sharedtypes.Service{Id: TestServiceId12}, }, }, } TestApp2Address = "pokt133amv5suh75zwkxxcq896azvmmwszg99grvk9f" // Generated via sample.AccAddress() TestApp2 = apptypes.Application{ Address: TestApp1Address, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, ServiceConfigs: []*sharedtypes.ApplicationServiceConfig{ { Service: &sharedtypes.Service{Id: TestServiceId2}, }, { Service: &sharedtypes.Service{Id: TestServiceId22}, }, { Service: &sharedtypes.Service{Id: TestServiceId12}, }, }, } TestSupplierUrl = "http://olshansky.info" TestSupplierOperatorAddress = sample.AccAddress() TestSupplier = sharedtypes.Supplier{ OperatorAddress: TestSupplierOperatorAddress, Stake: &sdk.Coin{Denom: "upokt", Amount: math.NewInt(100)}, Services: []*sharedtypes.SupplierServiceConfig{ { Service: &sharedtypes.Service{Id: TestServiceId1}, Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: TestSupplierUrl, RpcType: sharedtypes.RPCType_JSON_RPC, Configs: make([]*sharedtypes.ConfigOption, 0), }, }, }, { Service: &sharedtypes.Service{Id: TestServiceId2}, Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: TestSupplierUrl, RpcType: sharedtypes.RPCType_GRPC, Configs: make([]*sharedtypes.ConfigOption, 0), }, }, }, { Service: &sharedtypes.Service{Id: TestServiceId12}, Endpoints: []*sharedtypes.SupplierEndpoint{ { Url: TestSupplierUrl, RpcType: sharedtypes.RPCType_GRPC, Configs: make([]*sharedtypes.ConfigOption, 0), }, }, }, }, } )
Functions ¶
func AddAccToAccMapCoins ¶
AddAccToAccMapCoins adds to the mapAccAddrCoins map the coins specified as parameters, to the function under the address specified. When it cleans up it deletes the entry in the map for the provided address.
func AddGatewayToStakedGatewayMap ¶
AddGatewayToStakedGatewayMap adds the given gateway address to the staked gateway map for use in the application's mocked gateway keeper and ensures that it is removed from the map when the test is complete
func ApplicationKeeper ¶
ApplicationKeeper creates a new application keeper for testing and returns the keeper and context.
func AssertDefaultParamsEqualExceptFields ¶ added in v0.0.3
func AssertDefaultParamsEqualExceptFields[P any]( t *testing.T, expectedParams P, actualParams P, exceptFields ...string, )
AssertDefaultParamsEqualExceptFields asserts that the expectedParams and actualParams are equal except for the fields specified in exceptFields. expectedParams and actualParams MUST be reference types (e.g. pionters).
func ProofKeeper ¶
ProofKeeper is a helper function to create a proof keeper and a context. It uses mocked dependencies only.
func RemoveGatewayFromStakedGatewayMap ¶
RemoveGatewayFromStakedGatewayMap removes the given gateway address from the staked gateway map for use in the application's mocked gateway keeper
func SetBlockHash ¶
SetBlockHash updates the block hash for the given context and returns the updated context.
func SetBlockHeight ¶
SetBlockHeight updates the block height for the given context and returns the updated context.
func TokenomicsKeeper ¶
func TokenomicsKeeperWithActorAddrs ¶ added in v0.0.3
func TokenomicsKeeperWithActorAddrs(t testing.TB) ( tokenomicsKeeper tokenomicskeeper.Keeper, ctx context.Context, appAddr string, supplierOperatorAddr string, service *sharedtypes.Service, )
TODO_TECHDEBT: Remove this and force everyone to use NewTokenomicsModuleKeepers. There is a difference in the method signatures and mocking, which was simply a result of the evolution of the testutil package. TODO_REFACTOR(@Olshansk): Rather than making `service`, `appAddr` and `supplierOperatorAddr` explicit params, make them passable by the caller as options.
Types ¶
type ApplicationModuleKeepers ¶ added in v0.0.7
ApplicationModuleKeepers is a struct that contains the keepers needed for testing the application module.
func NewApplicationModuleKeepers ¶ added in v0.0.7
func NewApplicationModuleKeepers(t testing.TB) (ApplicationModuleKeepers, context.Context)
NewApplicationModuleKeepers creates a new application keeper for testing along with its dependencies then returns the application module keepers and context.
type ProofKeepersOpt ¶
type ProofKeepersOpt func(context.Context, *ProofModuleKeepers) context.Context
ProofKeepersOpt is a function which receives and potentially modifies the context and proof keepers during construction of the aggregation.
func WithBlockHash ¶
func WithBlockHash(hash []byte) ProofKeepersOpt
WithBlockHash sets the initial block hash for the context and returns the updated context.
func WithBlockHeight ¶
func WithBlockHeight(height int64) ProofKeepersOpt
WithBlockHeight sets the initial block height for the context and returns the updated context.
type ProofModuleKeepers ¶
type ProofModuleKeepers struct { *keeper.Keeper prooftypes.SessionKeeper prooftypes.SupplierKeeper prooftypes.ApplicationKeeper prooftypes.AccountKeeper Codec *codec.ProtoCodec }
ProofModuleKeepers is an aggregation of the proof keeper and all its dependency keepers, and the codec that they share. Each keeper is embedded such that the ProofModuleKeepers implements all the interfaces of the keepers. To call a method which is common to multiple keepers (e.g. `#SetParams()`), the field corresponding to the desired keeper on which to call the method MUST be specified (e.g. `keepers.AccountKeeper#SetParams()`).
func NewProofModuleKeepers ¶
func NewProofModuleKeepers(t testing.TB, opts ...ProofKeepersOpt) (_ *ProofModuleKeepers, ctx context.Context)
NewProofModuleKeepers is a helper function to create a proof keeper and a context. It uses real dependencies for all keepers except the bank keeper, which is mocked as it's not used directly by the proof keeper or its dependencies.
func (*ProofModuleKeepers) AddServiceActors ¶
func (keepers *ProofModuleKeepers) AddServiceActors( ctx context.Context, t *testing.T, service *sharedtypes.Service, supplierOperatorAddr string, appAddr string, )
AddServiceActors adds a supplier and an application for a specific service so a successful session can be generated for testing purposes.
func (*ProofModuleKeepers) GetSessionHeader ¶
func (keepers *ProofModuleKeepers) GetSessionHeader( ctx context.Context, t *testing.T, appAddr string, service *sharedtypes.Service, blockHeight int64, ) *sessiontypes.SessionHeader
GetSessionHeader is a helper to retrieve the session header for a specific (app, service, height).
type SupplierModuleKeepers ¶ added in v0.0.6
type SupplierModuleKeepers struct { *keeper.Keeper // Tracks the amount of funds returned to the supplier owner when the supplier is unbonded. SupplierUnstakedFundsMap map[string]int64 }
SupplierModuleKeepers is a struct that contains the keepers needed for testing the supplier module.
func SupplierKeeper ¶
func SupplierKeeper(t testing.TB) (SupplierModuleKeepers, context.Context)
type TokenomicsModuleKeepers ¶
type TokenomicsModuleKeepers struct { *tokenomicskeeper.Keeper tokenomicstypes.AccountKeeper tokenomicstypes.BankKeeper tokenomicstypes.ApplicationKeeper tokenomicstypes.SupplierKeeper tokenomicstypes.ProofKeeper tokenomicstypes.SessionKeeper tokenomicstypes.ServiceKeeper Codec *codec.ProtoCodec }
TokenomicsModuleKeepers is an aggregation of the tokenomics keeper, all its dependency keepers, and the codec that they share. Each keeper is embedded such that the TokenomicsModuleKeepers implements all the interfaces of the keepers. To call a method which is common to multiple keepers (e.g. `#SetParams()`), the field corresponding to the desired keeper on which to call the method MUST be specified (e.g. `keepers.AccountKeeper#SetParams()`).
func NewTokenomicsModuleKeepers ¶
func NewTokenomicsModuleKeepers( t testing.TB, logger log.Logger, opts ...TokenomicsModuleKeepersOpt, ) (_ TokenomicsModuleKeepers, ctx context.Context)
NewTokenomicsModuleKeepers is a helper function to create a tokenomics keeper and a context. It uses real dependencies for all upstream keepers.
type TokenomicsModuleKeepersOpt ¶ added in v0.0.5
type TokenomicsModuleKeepersOpt func(context.Context, *TokenomicsModuleKeepers) context.Context
TokenomicsKeepersOpt is a function which receives and potentially modifies the context and tokenomics keepers during construction of the aggregation.
func WithService ¶ added in v0.0.6
func WithService(service sharedtypes.Service) TokenomicsModuleKeepersOpt