github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/ibc-go/testing/mock/ibc_app.go (about)

     1  package mock
     2  
     3  import (
     4  	sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types"
     5  	capabilitykeeper "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/capability/keeper"
     6  	capabilitytypes "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/capability/types"
     7  	channeltypes "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/04-channel/types"
     8  	"github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/exported"
     9  )
    10  
    11  // MockIBCApp contains IBC application module callbacks as defined in 05-port.
    12  type MockIBCApp struct {
    13  	PortID       string
    14  	ScopedKeeper capabilitykeeper.ScopedKeeper
    15  
    16  	OnChanOpenInit func(
    17  		ctx sdk.Context,
    18  		order channeltypes.Order,
    19  		connectionHops []string,
    20  		portID string,
    21  		channelID string,
    22  		channelCap *capabilitytypes.Capability,
    23  		counterparty channeltypes.Counterparty,
    24  		version string,
    25  	) (string, error)
    26  
    27  	OnChanOpenTry func(
    28  		ctx sdk.Context,
    29  		order channeltypes.Order,
    30  		connectionHops []string,
    31  		portID,
    32  		channelID string,
    33  		channelCap *capabilitytypes.Capability,
    34  		counterparty channeltypes.Counterparty,
    35  		counterpartyVersion string,
    36  	) (version string, err error)
    37  
    38  	OnChanOpenAck func(
    39  		ctx sdk.Context,
    40  		portID,
    41  		channelID string,
    42  		counterpartyChannelID string,
    43  		counterpartyVersion string,
    44  	) error
    45  
    46  	OnChanOpenConfirm func(
    47  		ctx sdk.Context,
    48  		portID,
    49  		channelID string,
    50  	) error
    51  
    52  	OnChanCloseInit func(
    53  		ctx sdk.Context,
    54  		portID,
    55  		channelID string,
    56  	) error
    57  
    58  	OnChanCloseConfirm func(
    59  		ctx sdk.Context,
    60  		portID,
    61  		channelID string,
    62  	) error
    63  
    64  	// OnRecvPacket must return an acknowledgement that implements the Acknowledgement interface.
    65  	// In the case of an asynchronous acknowledgement, nil should be returned.
    66  	// If the acknowledgement returned is successful, the state changes on callback are written,
    67  	// otherwise the application state changes are discarded. In either case the packet is received
    68  	// and the acknowledgement is written (in synchronous cases).
    69  	OnRecvPacket func(
    70  		ctx sdk.Context,
    71  		packet channeltypes.Packet,
    72  		relayer sdk.AccAddress,
    73  	) exported.Acknowledgement
    74  
    75  	OnAcknowledgementPacket func(
    76  		ctx sdk.Context,
    77  		packet channeltypes.Packet,
    78  		acknowledgement []byte,
    79  		relayer sdk.AccAddress,
    80  	) error
    81  
    82  	OnTimeoutPacket func(
    83  		ctx sdk.Context,
    84  		packet channeltypes.Packet,
    85  		relayer sdk.AccAddress,
    86  	) error
    87  }
    88  
    89  // NewMockIBCApp returns a MockIBCApp. An empty PortID indicates the mock app doesn't bind/claim ports.
    90  func NewMockIBCApp(portID string, scopedKeeper capabilitykeeper.ScopedKeeper) *MockIBCApp {
    91  	return &MockIBCApp{
    92  		PortID:       portID,
    93  		ScopedKeeper: scopedKeeper,
    94  	}
    95  }