Documentation ¶
Overview ¶
This package is only intended to be used for testing core IBC. In order to maintain secure testing, we need to do message passing and execution which requires connecting an IBC application module that fulfills all the callbacks. We cannot connect to ibc-transfer which does not support all channel types so instead we create a mock application module which does nothing. It simply return nil in all cases so no error ever occurs. It is intended to be as minimal and lightweight as possible and should never import simapp.
Index ¶
- Constants
- Variables
- func GetMockAckCanaryCapabilityName(packet channeltypes.Packet) string
- func GetMockRecvCanaryCapabilityName(packet channeltypes.Packet) string
- func GetMockTimeoutCanaryCapabilityName(packet channeltypes.Packet) string
- func NewMockAckPacketEvent() sdk.Event
- func NewMockRecvPacketEvent() sdk.Event
- func NewMockTimeoutPacketEvent() sdk.Event
- type AppModule
- func (AppModule) ConsensusVersion() uint64
- func (AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage
- func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate
- func (AppModule) IsAppModule()
- func (AppModule) IsOnePerModuleType()
- func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry)
- func (AppModule) RegisterServices(module.Configurator)
- type AppModuleBasic
- func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage
- func (AppModuleBasic) GetQueryCmd() *cobra.Command
- func (AppModuleBasic) GetTxCmd() *cobra.Command
- func (AppModuleBasic) Name() string
- func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux)
- func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)
- func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino)
- func (AppModuleBasic) ValidateGenesis(codec.JSONCodec, client.TxEncodingConfig, json.RawMessage) error
- type BlockUpgradeMiddleware
- func (BlockUpgradeMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool)
- func (im BlockUpgradeMiddleware) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, ...) error
- func (im BlockUpgradeMiddleware) OnChanCloseConfirm(ctx sdk.Context, portID, channelID string) error
- func (im BlockUpgradeMiddleware) OnChanCloseInit(ctx sdk.Context, portID, channelID string) error
- func (im BlockUpgradeMiddleware) OnChanOpenAck(ctx sdk.Context, portID string, channelID string, counterpartyChannelID string, ...) error
- func (im BlockUpgradeMiddleware) OnChanOpenConfirm(ctx sdk.Context, portID, channelID string) error
- func (im BlockUpgradeMiddleware) OnChanOpenInit(ctx sdk.Context, order channeltypes.Order, connectionHops []string, ...) (string, error)
- func (im BlockUpgradeMiddleware) OnChanOpenTry(ctx sdk.Context, order channeltypes.Order, connectionHops []string, ...) (version string, err error)
- func (im BlockUpgradeMiddleware) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) exported.Acknowledgement
- func (im BlockUpgradeMiddleware) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error
- func (BlockUpgradeMiddleware) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability, sourcePort string, ...) (uint64, error)
- func (BlockUpgradeMiddleware) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet exported.PacketI, ...) error
- type EmptyAcknowledgement
- type IBCApp
- type IBCModule
- func (im IBCModule) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, ...) error
- func (im IBCModule) OnChanCloseConfirm(ctx sdk.Context, portID, channelID string) error
- func (im IBCModule) OnChanCloseInit(ctx sdk.Context, portID, channelID string) error
- func (im IBCModule) OnChanOpenAck(ctx sdk.Context, portID string, channelID string, counterpartyChannelID string, ...) error
- func (im IBCModule) OnChanOpenConfirm(ctx sdk.Context, portID, channelID string) error
- func (im IBCModule) OnChanOpenInit(ctx sdk.Context, order channeltypes.Order, connectionHops []string, ...) (string, error)
- func (im IBCModule) OnChanOpenTry(ctx sdk.Context, order channeltypes.Order, connectionHops []string, ...) (version string, err error)
- func (im IBCModule) OnChanUpgradeAck(ctx sdk.Context, portID, channelID, counterpartyVersion string) error
- func (im IBCModule) OnChanUpgradeInit(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, ...) (string, error)
- func (im IBCModule) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, ...)
- func (im IBCModule) OnChanUpgradeTry(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, ...) (string, error)
- func (im IBCModule) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) exported.Acknowledgement
- func (im IBCModule) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error
- func (IBCModule) UnmarshalPacketData(bz []byte) (interface{}, error)
- type KeyPath
- type PV
- type PortKeeper
Constants ¶
const ( MockEventType = "mock-event-type" MockEventTypeRecvPacket = "mock-recv-packet" MockEventTypeAckPacket = "mock-ack-packet" MockEventTypeTimeoutPacket = "mock-timeout" MockAttributeKey1 = "mock-attribute-key-1" MockAttributeKey2 = "mock-attribute-key-2" MockAttributeValue1 = "mock-attribute-value-1" MockAttributeValue2 = "mock-attribute-value-2" )
const ( ModuleName = "mock" MemStoreKey = "memory:mock" PortID = ModuleName Version = "mock-version" )
const (
MockBlockUpgrade = "mockblockupgrade"
)
Variables ¶
var ( MockAcknowledgement = channeltypes.NewResultAcknowledgement([]byte("mock acknowledgement")) MockFailAcknowledgement = channeltypes.NewErrorAcknowledgement(fmt.Errorf("mock failed acknowledgement")) MockPacketData = []byte("mock packet data") MockFailPacketData = []byte("mock failed packet data") MockAsyncPacketData = []byte("mock async packet data") MockRecvCanaryCapabilityName = "mock receive canary capability name" MockAckCanaryCapabilityName = "mock acknowledgement canary capability name" MockTimeoutCanaryCapabilityName = "mock timeout canary capability name" UpgradeVersion = fmt.Sprintf("%s-v2", Version) // MockApplicationCallbackError should be returned when an application callback should fail. It is possible to // test that this error was returned using ErrorIs. MockApplicationCallbackError error = &applicationCallbackError{} )
var ( TestKey = []byte("test-key") TestValue = []byte("test-value") )
Functions ¶
func GetMockAckCanaryCapabilityName ¶
func GetMockAckCanaryCapabilityName(packet channeltypes.Packet) string
GetMockAckCanaryCapabilityName generates a capability name for OnAcknowledgementPacket functionality.
func GetMockRecvCanaryCapabilityName ¶
func GetMockRecvCanaryCapabilityName(packet channeltypes.Packet) string
GetMockRecvCanaryCapabilityName generates a capability name for testing OnRecvPacket functionality.
func GetMockTimeoutCanaryCapabilityName ¶
func GetMockTimeoutCanaryCapabilityName(packet channeltypes.Packet) string
GetMockTimeoutCanaryCapabilityName generates a capability name for OnTimeoutacket functionality.
func NewMockAckPacketEvent ¶
NewMockAckPacketEvent returns a mock acknowledgement packet event
func NewMockRecvPacketEvent ¶
NewMockRecvPacketEvent returns a mock receive packet event
func NewMockTimeoutPacketEvent ¶
NewMockTimeoutPacketEvent emits a mock timeout packet event
Types ¶
type AppModule ¶
type AppModule struct { AppModuleBasic // contains filtered or unexported fields }
AppModule represents the AppModule for the mock module.
func NewAppModule ¶
func NewAppModule(pk PortKeeper) AppModule
NewAppModule returns a mock AppModule instance.
func (AppModule) ConsensusVersion ¶
ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ExportGenesis ¶
ExportGenesis implements the AppModule interface.
func (AppModule) InitGenesis ¶
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate
InitGenesis implements the AppModule interface.
func (AppModule) IsAppModule ¶
func (AppModule) IsAppModule()
IsAppModule implements the appmodule.AppModule interface.
func (AppModule) IsOnePerModuleType ¶
func (AppModule) IsOnePerModuleType()
IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (AppModule) RegisterInvariants ¶
func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry)
RegisterInvariants implements the AppModule interface.
func (AppModule) RegisterServices ¶
func (AppModule) RegisterServices(module.Configurator)
RegisterServices implements the AppModule interface.
type AppModuleBasic ¶
type AppModuleBasic struct{}
AppModuleBasic is the mock AppModuleBasic.
func (AppModuleBasic) DefaultGenesis ¶
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage
DefaultGenesis implements AppModuleBasic interface.
func (AppModuleBasic) GetQueryCmd ¶
func (AppModuleBasic) GetQueryCmd() *cobra.Command
GetQueryCmd implements AppModuleBasic interface.
func (AppModuleBasic) GetTxCmd ¶
func (AppModuleBasic) GetTxCmd() *cobra.Command
GetTxCmd implements AppModuleBasic interface.
func (AppModuleBasic) Name ¶
func (AppModuleBasic) Name() string
Name implements AppModuleBasic interface.
func (AppModuleBasic) RegisterGRPCGatewayRoutes ¶
func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux)
RegisterGRPCGatewayRoutes implements AppModuleBasic interface.
func (AppModuleBasic) RegisterInterfaces ¶
func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry)
RegisterInterfaces implements AppModuleBasic interface.
func (AppModuleBasic) RegisterLegacyAminoCodec ¶
func (AppModuleBasic) RegisterLegacyAminoCodec(*codec.LegacyAmino)
RegisterLegacyAminoCodec implements AppModuleBasic interface.
func (AppModuleBasic) ValidateGenesis ¶
func (AppModuleBasic) ValidateGenesis(codec.JSONCodec, client.TxEncodingConfig, json.RawMessage) error
ValidateGenesis implements the AppModuleBasic interface.
type BlockUpgradeMiddleware ¶
type BlockUpgradeMiddleware struct { IBCApp *IBCApp // base application of an IBC middleware stack // contains filtered or unexported fields }
BlockUpgradeMiddleware does not implement the UpgradeableModule interface
func NewBlockUpgradeMiddleware ¶
func NewBlockUpgradeMiddleware(appModule *AppModule, app *IBCApp) BlockUpgradeMiddleware
NewIBCModule creates a new IBCModule given the underlying mock IBC application and scopedKeeper.
func (BlockUpgradeMiddleware) GetAppVersion ¶
func (BlockUpgradeMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool)
GetAppVersion returns the application version of the underlying application
func (BlockUpgradeMiddleware) OnAcknowledgementPacket ¶
func (im BlockUpgradeMiddleware) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress) error
OnAcknowledgementPacket implements the IBCModule interface.
func (BlockUpgradeMiddleware) OnChanCloseConfirm ¶
func (im BlockUpgradeMiddleware) OnChanCloseConfirm(ctx sdk.Context, portID, channelID string) error
OnChanCloseConfirm implements the IBCModule interface.
func (BlockUpgradeMiddleware) OnChanCloseInit ¶
func (im BlockUpgradeMiddleware) OnChanCloseInit(ctx sdk.Context, portID, channelID string) error
OnChanCloseInit implements the IBCModule interface.
func (BlockUpgradeMiddleware) OnChanOpenAck ¶
func (im BlockUpgradeMiddleware) OnChanOpenAck(ctx sdk.Context, portID string, channelID string, counterpartyChannelID string, counterpartyVersion string) error
OnChanOpenAck implements the IBCModule interface.
func (BlockUpgradeMiddleware) OnChanOpenConfirm ¶
func (im BlockUpgradeMiddleware) OnChanOpenConfirm(ctx sdk.Context, portID, channelID string) error
OnChanOpenConfirm implements the IBCModule interface.
func (BlockUpgradeMiddleware) OnChanOpenInit ¶
func (im BlockUpgradeMiddleware) OnChanOpenInit( ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, chanCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string, ) (string, error)
OnChanOpenInit implements the IBCModule interface.
func (BlockUpgradeMiddleware) OnChanOpenTry ¶
func (im BlockUpgradeMiddleware) OnChanOpenTry( ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, chanCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string, ) (version string, err error)
OnChanOpenTry implements the IBCModule interface.
func (BlockUpgradeMiddleware) OnRecvPacket ¶
func (im BlockUpgradeMiddleware) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) exported.Acknowledgement
OnRecvPacket implements the IBCModule interface.
func (BlockUpgradeMiddleware) OnTimeoutPacket ¶
func (im BlockUpgradeMiddleware) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error
OnTimeoutPacket implements the IBCModule interface.
func (BlockUpgradeMiddleware) SendPacket ¶
func (BlockUpgradeMiddleware) SendPacket( ctx sdk.Context, chanCap *capabilitytypes.Capability, sourcePort string, sourceChannel string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, data []byte, ) (uint64, error)
SendPacket implements the ICS4 Wrapper interface
func (BlockUpgradeMiddleware) WriteAcknowledgement ¶
func (BlockUpgradeMiddleware) WriteAcknowledgement( ctx sdk.Context, chanCap *capabilitytypes.Capability, packet exported.PacketI, ack exported.Acknowledgement, ) error
WriteAcknowledgement implements the ICS4 Wrapper interface
type EmptyAcknowledgement ¶
type EmptyAcknowledgement struct {
Response []byte
}
EmptyAcknowledgement implements the exported.Acknowledgement interface and always returns an empty byte string as Response
func NewEmptyAcknowledgement ¶
func NewEmptyAcknowledgement() EmptyAcknowledgement
NewEmptyAcknowledgement returns a new instance of EmptyAcknowledgement
func (EmptyAcknowledgement) Acknowledgement ¶
func (EmptyAcknowledgement) Acknowledgement() []byte
Acknowledgement implements the Acknowledgement interface
func (EmptyAcknowledgement) Success ¶
func (EmptyAcknowledgement) Success() bool
Success implements the Acknowledgement interface
type IBCApp ¶
type IBCApp struct { PortID string ScopedKeeper capabilitykeeper.ScopedKeeper OnChanOpenInit func( ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string, ) (string, error) OnChanOpenTry func( ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string, ) (version string, err error) OnChanOpenAck func( ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string, ) error OnChanOpenConfirm func( ctx sdk.Context, portID, channelID string, ) error OnChanCloseInit func( ctx sdk.Context, portID, channelID string, ) error OnChanCloseConfirm func( ctx sdk.Context, portID, channelID string, ) error // OnRecvPacket must return an acknowledgement that implements the Acknowledgement interface. // In the case of an asynchronous acknowledgement, nil should be returned. // If the acknowledgement returned is successful, the state changes on callback are written, // otherwise the application state changes are discarded. In either case the packet is received // and the acknowledgement is written (in synchronous cases). OnRecvPacket func( ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, ) exported.Acknowledgement OnAcknowledgementPacket func( ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress, ) error OnTimeoutPacket func( ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, ) error OnChanUpgradeInit func( ctx sdk.Context, portID, channelID string, order channeltypes.Order, connectionHops []string, version string, ) (string, error) OnChanUpgradeTry func( ctx sdk.Context, portID, channelID string, order channeltypes.Order, connectionHops []string, counterpartyVersion string, ) (string, error) OnChanUpgradeAck func( ctx sdk.Context, portID, channelID, counterpartyVersion string, ) error OnChanUpgradeOpen func( ctx sdk.Context, portID, channelID string, order channeltypes.Order, connectionHops []string, version string, ) }
IBCApp contains IBC application module callbacks as defined in 05-port.
func NewIBCApp ¶
func NewIBCApp(portID string, scopedKeeper capabilitykeeper.ScopedKeeper) *IBCApp
NewIBCApp returns a IBCApp. An empty PortID indicates the mock app doesn't bind/claim ports.
type IBCModule ¶
type IBCModule struct { IBCApp *IBCApp // base application of an IBC middleware stack // contains filtered or unexported fields }
IBCModule implements the ICS26 callbacks for testing/mock.
func NewIBCModule ¶
NewIBCModule creates a new IBCModule given the underlying mock IBC application and scopedKeeper.
func (IBCModule) OnAcknowledgementPacket ¶
func (im IBCModule) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress) error
OnAcknowledgementPacket implements the IBCModule interface.
func (IBCModule) OnChanCloseConfirm ¶
OnChanCloseConfirm implements the IBCModule interface.
func (IBCModule) OnChanCloseInit ¶
OnChanCloseInit implements the IBCModule interface.
func (IBCModule) OnChanOpenAck ¶
func (im IBCModule) OnChanOpenAck(ctx sdk.Context, portID string, channelID string, counterpartyChannelID string, counterpartyVersion string) error
OnChanOpenAck implements the IBCModule interface.
func (IBCModule) OnChanOpenConfirm ¶
OnChanOpenConfirm implements the IBCModule interface.
func (IBCModule) OnChanOpenInit ¶
func (im IBCModule) OnChanOpenInit( ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, chanCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string, ) (string, error)
OnChanOpenInit implements the IBCModule interface.
func (IBCModule) OnChanOpenTry ¶
func (im IBCModule) OnChanOpenTry( ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, chanCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string, ) (version string, err error)
OnChanOpenTry implements the IBCModule interface.
func (IBCModule) OnChanUpgradeAck ¶
func (im IBCModule) OnChanUpgradeAck(ctx sdk.Context, portID, channelID, counterpartyVersion string) error
OnChanUpgradeAck implements the IBCModule interface
func (IBCModule) OnChanUpgradeInit ¶
func (im IBCModule) OnChanUpgradeInit(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, proposedVersion string) (string, error)
OnChanUpgradeInit implements the IBCModule interface
func (IBCModule) OnChanUpgradeOpen ¶
func (im IBCModule) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, proposedVersion string)
OnChanUpgradeOpen implements the IBCModule interface
func (IBCModule) OnChanUpgradeTry ¶
func (im IBCModule) OnChanUpgradeTry(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, counterpartyVersion string) (string, error)
OnChanUpgradeTry implements the IBCModule interface
func (IBCModule) OnRecvPacket ¶
func (im IBCModule) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) exported.Acknowledgement
OnRecvPacket implements the IBCModule interface.
func (IBCModule) OnTimeoutPacket ¶
func (im IBCModule) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress) error
OnTimeoutPacket implements the IBCModule interface.
func (IBCModule) UnmarshalPacketData ¶
UnmarshalPacketData returns the MockPacketData. This function implements the optional PacketDataUnmarshaler interface required for ADR 008 support.
type KeyPath ¶
type KeyPath struct{}
KeyPath defines a placeholder struct which implements the exported.Path interface
type PV ¶ added in v9.1.5
type PV struct {
PrivKey cryptotypes.PrivKey
}
MockPV implements PrivValidator without any safety or persistence. Only use it for testing.
func (PV) SignProposal ¶ added in v9.1.5
SignProposal implements PrivValidator interface
type PortKeeper ¶
type PortKeeper interface { BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability IsBound(ctx sdk.Context, portID string) bool }
Expected Interface PortKeeper defines the expected IBC port keeper