keeper

package
v0.0.0-...-192d3b1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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"
	TestSupplierAddress = sample.AccAddress()
	TestSupplier        = sharedtypes.Supplier{
		Address: TestSupplierAddress,
		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

func AddAccToAccMapCoins(t *testing.T, addr, denom string, amount uint64)

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

func AddGatewayToStakedGatewayMap(t *testing.T, gatewayAddr string)

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

func ApplicationKeeper(t testing.TB) (keeper.Keeper, context.Context)

func GatewayKeeper

func GatewayKeeper(t testing.TB) (keeper.Keeper, context.Context)

func ProofKeeper

func ProofKeeper(t testing.TB) (keeper.Keeper, context.Context)

ProofKeeper is a helper function to create a proof keeper and a context. It uses mocked dependencies only.

func RemoveGatewayFromStakedGatewayMap

func RemoveGatewayFromStakedGatewayMap(t *testing.T, gatewayAddr string)

RemoveGatewayFromStakedGatewayMap removes the given gateway address from the staked gateway map for use in the application's mocked gateway keeper

func ServiceKeeper

func ServiceKeeper(t testing.TB) (keeper.Keeper, context.Context)

func SessionKeeper

func SessionKeeper(t testing.TB) (keeper.Keeper, context.Context)

func SetBlockHash

func SetBlockHash(ctx context.Context, hash []byte) context.Context

SetBlockHash updates the block hash for the given context and returns the updated context.

func SetBlockHeight

func SetBlockHeight(ctx context.Context, height int64) context.Context

SetBlockHeight updates the block height for the given context and returns the updated context.

func SupplierKeeper

func SupplierKeeper(t testing.TB) (keeper.Keeper, context.Context)

func TokenomicsKeeper

func TokenomicsKeeper(t testing.TB) (
	tokenomicsKeeper tokenomicskeeper.Keeper,
	ctx context.Context,
	appAddr string,
	supplierAddr string,
)

Types

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

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,
	supplierAddr 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 TokenomicsKeepersOpt

type TokenomicsKeepersOpt 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.

type TokenomicsModuleKeepers

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,
	opts ...TokenomicsKeepersOpt,
) (_ 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.

Jump to

Keyboard shortcuts

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