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

test(vtransfer): more comprehensive multiapp tests #10849

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions golang/cosmos/types/address_hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ func TestExtractBaseAddressFromPacket(t *testing.T) {
}

require.Equal(t, ftPacketData, packetData)

roundTripBz, err := cdc.MarshalJSON(&packetData)
require.NoError(t, err)
require.Equal(t, packet.GetData(), roundTripBz)

roundTripPacket := packet
roundTripPacket.Data = roundTripBz
require.Equal(t, packet, roundTripPacket)
})
}
})
Expand Down
8 changes: 8 additions & 0 deletions golang/cosmos/x/swingset/testing/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ func GetActionQueueRecords(t *testing.T, ctx sdk.Context, swingsetKeeper keeper.
actionQueueName := keeper.StoragePathActionQueue
return vstoragetesting.GetQueueItems(ctx, vstorageKeeper, actionQueueName)
}

// ResetActionQueue resets the action queue.
// This is a testing utility function.
func ResetActionQueue(t *testing.T, ctx sdk.Context, swingsetKeeper keeper.Keeper) error {
vstorageKeeper := keeper.GetVstorageKeeper(t, swingsetKeeper)
actionQueueName := keeper.StoragePathActionQueue
return vstoragetesting.ResetQueue(ctx, vstorageKeeper, actionQueueName)
}
4 changes: 2 additions & 2 deletions golang/cosmos/x/vibc/types/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewReceiver(impl ReceiverImpl) Receiver {
}
}

type portMessage struct { // comes from swingset's IBC handler
type PortMessage struct { // comes from swingset's IBC handler
Type string `json:"type"` // IBC_METHOD
Method string `json:"method"`
Packet channeltypes.Packet `json:"packet"`
Expand Down Expand Up @@ -94,7 +94,7 @@ func (ir Receiver) Receive(cctx context.Context, jsonRequest string) (jsonReply
ctx := sdk.UnwrapSDKContext(cctx)
impl := ir.impl

msg := new(portMessage)
msg := new(PortMessage)
err = json.Unmarshal([]byte(jsonRequest), &msg)
if err != nil {
return "", err
Expand Down
6 changes: 6 additions & 0 deletions golang/cosmos/x/vstorage/testing/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ func GetQueueItems(ctx sdk.Context, vstorageKeeper keeper.Keeper, queuePath stri
}
return values, nil
}

func ResetQueue(ctx sdk.Context, vstorageKeeper keeper.Keeper, queuePath string) error {
unlimitedCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
vstorageKeeper.RemoveEntriesWithPrefix(unlimitedCtx, queuePath)
return nil
}
6 changes: 5 additions & 1 deletion golang/cosmos/x/vtransfer/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ func (im IBCMiddleware) WriteAcknowledgement(
packet exported.PacketI,
ack exported.Acknowledgement,
) error {
return im.vtransferKeeper.InterceptWriteAcknowledgement(ctx, chanCap, packet, ack)
syncAck := im.vtransferKeeper.InterceptWriteAcknowledgement(ctx, chanCap, packet, ack)
if syncAck != nil {
return im.vtransferKeeper.WriteAcknowledgement(ctx, chanCap, packet, syncAck)
}
return nil
}

///////////////////////////////////
Expand Down
Loading
Loading