Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mock ibc module v2 #7398

Merged
merged 5 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions testing/mock/v2/ibc_app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package mock

import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"

channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types"
)

type IBCApp struct {
OnSendPacket func(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error
}
41 changes: 38 additions & 3 deletions testing/mock/v2/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,43 @@ import (

var _ api.IBCModule = (*IBCModule)(nil)

type IBCModule struct{}
// IBCModule is a mock implementation of the IBCModule interface.
// which delegates calls to the underlying IBCApp.
type IBCModule struct {
IBCApp *IBCApp
}

// NewIBCModule creates a new IBCModule with an underlying mock IBC application.
func NewIBCModule() IBCModule {
return IBCModule{
IBCApp: &IBCApp{},
}
}

func (IBCModule) OnSendPacket(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error {
panic("implement me")
func (im IBCModule) OnSendPacket(ctx context.Context, sourceID string, destinationID string, sequence uint64, data channeltypesv2.PacketData, signer sdk.AccAddress) error {
if im.IBCApp.OnSendPacket != nil {
return im.IBCApp.OnSendPacket(ctx, sourceID, destinationID, sequence, data, signer)
}
return nil
}

// func (im IBCModule) OnRecvPacket() error {
// if im.IBCApp.OnRecvPacket != nil {
// return im.IBCApp.OnRecvPacket(...)
// }
// return nil
// }
//
// func (im IBCModule) OnAcknowledgementPacket() error {
// if im.IBCApp.OnAcknowledgementPacket != nil {
// return im.IBCApp.OnAcknowledgementPacket(...)
// }
// return nil
// }
//
// func (im IBCModule) OnTimeoutPacket() error {
// if im.IBCApp.OnTimeoutPacket != nil {
// return im.IBCApp.OnTimeoutPacket(...)
// }
// return nil
// }
Loading