-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Reusability of Mock module for middleware integration tests (#432)
* proof of concept for mock middleware * add mock base app implementation and add documentation * add changelog * update wording * Update CHANGELOG.md * rename BaseApp to IBCApp * fix testing readme * Update testing/README.md Co-authored-by: Aditya <adityasripal@gmail.com>
- Loading branch information
1 parent
a19d1ec
commit 6e56b04
Showing
5 changed files
with
169 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package mock | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" | ||
|
||
channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types" | ||
"github.com/cosmos/ibc-go/v2/modules/core/exported" | ||
) | ||
|
||
type MockIBCApp struct { | ||
OnChanOpenInit func( | ||
ctx sdk.Context, | ||
order channeltypes.Order, | ||
connectionHops []string, | ||
portID string, | ||
channelID string, | ||
channelCap *capabilitytypes.Capability, | ||
counterparty channeltypes.Counterparty, | ||
version string, | ||
) error | ||
|
||
OnChanOpenTry func( | ||
ctx sdk.Context, | ||
order channeltypes.Order, | ||
connectionHops []string, | ||
portID, | ||
channelID string, | ||
channelCap *capabilitytypes.Capability, | ||
counterparty channeltypes.Counterparty, | ||
version, | ||
counterpartyVersion string, | ||
) error | ||
|
||
OnChanOpenAck func( | ||
ctx sdk.Context, | ||
portID, | ||
channelID 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 | ||
|
||
// NegotiateAppVersion performs application version negotiation given the provided channel ordering, connectionID, portID, counterparty and proposed version. | ||
// An error is returned if version negotiation cannot be performed. For example, an application module implementing this interface | ||
// may decide to return an error in the event of the proposed version being incompatible with it's own | ||
NegotiateAppVersion func( | ||
ctx sdk.Context, | ||
order channeltypes.Order, | ||
connectionID string, | ||
portID string, | ||
counterparty channeltypes.Counterparty, | ||
proposedVersion string, | ||
) (version string, err error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters