Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaSripal committed Nov 12, 2024
2 parents 7a67e72 + d416dc3 commit 602b07a
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 75 deletions.
6 changes: 5 additions & 1 deletion docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ const config = {
// Exclude template markdown files from the docs
exclude: ["**/*.template.md"],
// Select the latest version
lastVersion: "v8.5.x",
lastVersion: "v9.0.x",
// Assign banners to specific versions
versions: {
current: {
path: "main",
banner: "unreleased",
},
"v9.0.x": {
path: "v9",
banner: "none",
},
"v8.5.x": {
path: "v8",
banner: "none",
Expand Down
32 changes: 30 additions & 2 deletions modules/core/04-channel/types/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,43 @@ import (

"github.com/stretchr/testify/require"

clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
)

func TestCommitPacket(t *testing.T) {
packet := types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp)
commitment := types.CommitPacket(packet)
require.NotNil(t, commitment)

testCases := []struct {
name string
packet types.Packet
}{
{
name: "diff data",
packet: types.NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp),
},
{
name: "diff timeout revision number",
packet: types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, clienttypes.NewHeight(timeoutHeight.RevisionNumber+1, timeoutHeight.RevisionHeight), timeoutTimestamp),
},
{
name: "diff timeout revision height",
packet: types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, clienttypes.NewHeight(timeoutHeight.RevisionNumber, timeoutHeight.RevisionHeight+1), timeoutTimestamp),
},
{
name: "diff timeout timestamp",
packet: types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, uint64(1)),
},
}

for _, tc := range testCases {
testCommitment := types.CommitPacket(tc.packet)
require.NotNil(t, testCommitment)

require.NotEqual(t, commitment, testCommitment)
}
}

func TestPacketValidateBasic(t *testing.T) {
Expand All @@ -33,8 +63,6 @@ func TestPacketValidateBasic(t *testing.T) {
}

for i, tc := range testCases {
tc := tc

err := tc.packet.ValidateBasic()
if tc.expPass {
require.NoError(t, err, "Msg %d failed: %s", i, tc.errMsg)
Expand Down
23 changes: 12 additions & 11 deletions modules/core/04-channel/v2/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,47 @@ import (

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

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

// EmitSendPacketEvents emits events for the SendPacket handler.
func EmitSendPacketEvents(ctx context.Context, packet channeltypesv2.Packet) {
func EmitSendPacketEvents(ctx context.Context, packet types.Packet) {
// TODO: https://github.com/cosmos/ibc-go/issues/7386
}

// EmitRecvPacketEvents emits events for the RecvPacket handler.
func EmitRecvPacketEvents(ctx context.Context, packet channeltypesv2.Packet) {
func EmitRecvPacketEvents(ctx context.Context, packet types.Packet) {
// TODO: https://github.com/cosmos/ibc-go/issues/7386
}

// EmitAcknowledgePacketEvents emits events for the AcknowledgePacket handler.
func EmitAcknowledgePacketEvents(ctx context.Context, packet channeltypesv2.Packet) {
func EmitAcknowledgePacketEvents(ctx context.Context, packet types.Packet) {
// TODO: https://github.com/cosmos/ibc-go/issues/7386
}

// EmitTimeoutPacketEvents emits events for the TimeoutPacket handler.
func EmitTimeoutPacketEvents(ctx context.Context, packet channeltypesv2.Packet) {
func EmitTimeoutPacketEvents(ctx context.Context, packet types.Packet) {
// TODO: https://github.com/cosmos/ibc-go/issues/7386
}

// EmitWriteAcknowledgementEvents emits events for WriteAcknowledgement.
func EmitWriteAcknowledgementEvents(ctx context.Context, packet channeltypesv2.Packet, ack channeltypesv2.Acknowledgement) {
func EmitWriteAcknowledgementEvents(ctx context.Context, packet types.Packet, ack types.Acknowledgement) {
// TODO: https://github.com/cosmos/ibc-go/issues/7386
}

// EmitCreateChannelEvent emits a channel create event.
func (*Keeper) EmitCreateChannelEvent(ctx context.Context, channelID string) {
// emitCreateChannelEvent emits a channel create event.
func (*Keeper) emitCreateChannelEvent(ctx context.Context, channelID, clientID string) {
sdkCtx := sdk.UnwrapSDKContext(ctx)

sdkCtx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
channeltypesv2.EventTypeCreateChannel,
sdk.NewAttribute(channeltypesv2.AttributeKeyChannelID, channelID),
types.EventTypeCreateChannel,
sdk.NewAttribute(types.AttributeKeyChannelID, channelID),
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, channeltypesv2.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})
}
12 changes: 6 additions & 6 deletions modules/core/04-channel/v2/keeper/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ package keeper
import (
"context"

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

func (k *Keeper) SendPacketTest(
ctx context.Context,
sourceChannel string,
timeoutTimestamp uint64,
payloads []channeltypesv2.Payload,
payloads []types.Payload,
) (uint64, string, error) {
return k.sendPacket(
ctx,
Expand All @@ -27,7 +27,7 @@ func (k *Keeper) SendPacketTest(

func (k *Keeper) RecvPacketTest(
ctx context.Context,
packet channeltypesv2.Packet,
packet types.Packet,
proof []byte,
proofHeight exported.Height,
) error {
Expand All @@ -41,8 +41,8 @@ func (k *Keeper) RecvPacketTest(

func (k *Keeper) AcknowledgePacketTest(
ctx context.Context,
packet channeltypesv2.Packet,
acknowledgement channeltypesv2.Acknowledgement,
packet types.Packet,
acknowledgement types.Acknowledgement,
proof []byte,
proofHeight exported.Height,
) error {
Expand All @@ -57,7 +57,7 @@ func (k *Keeper) AcknowledgePacketTest(

func (k *Keeper) TimeoutPacketTest(
ctx context.Context,
packet channeltypesv2.Packet,
packet types.Packet,
proof []byte,
proofHeight exported.Height,
) error {
Expand Down
2 changes: 1 addition & 1 deletion modules/core/04-channel/v2/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (k *Keeper) CreateChannel(goCtx context.Context, msg *types.MsgCreateChanne
k.SetCreator(ctx, channelID, msg.Signer)
k.SetNextSequenceSend(ctx, channelID, 1)

k.EmitCreateChannelEvent(goCtx, channelID)
k.emitCreateChannelEvent(goCtx, channelID, msg.ClientId)

return &types.MsgCreateChannelResponse{ChannelId: channelID}, nil
}
Expand Down
Loading

0 comments on commit 602b07a

Please sign in to comment.