-
Notifications
You must be signed in to change notification settings - Fork 418
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
Return IBC packet sequence number #1225
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,9 @@ message MsgIBCSend { | |
message MsgIBCCloseChannel { | ||
string channel = 2 [ (gogoproto.moretags) = "yaml:\"source_channel\"" ]; | ||
} | ||
|
||
// MsgIBCSendResponse | ||
message MsgIBCSendResponse { | ||
// sequence number of the transfer packet sent | ||
uint64 sequence = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -188,7 +188,19 @@ func (h IBCRawPacketHandler) DispatchMsg(ctx sdk.Context, _ sdk.AccAddress, cont | |||||
ConvertWasmIBCTimeoutHeightToCosmosHeight(msg.IBC.SendPacket.Timeout.Block), | ||||||
msg.IBC.SendPacket.Timeout.Timestamp, | ||||||
) | ||||||
return nil, nil, h.channelKeeper.SendPacket(ctx, channelCap, packet) | ||||||
|
||||||
if err := h.channelKeeper.SendPacket(ctx, channelCap, packet); err != nil { | ||||||
return nil, nil, sdkerrors.Wrap(err, "failed to send packet") | ||||||
} | ||||||
|
||||||
resp := &types.MsgIBCSendResponse{Sequence: sequence} | ||||||
val, err := resp.Marshal() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does work correct! |
||||||
if err != nil { | ||||||
return nil, nil, sdkerrors.Wrap(err, "failed to marshal sequence response") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
data = append(data, val) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to append. Just set the value here
Suggested change
or better return nil, val, nil |
||||||
return nil, data, nil | ||||||
} | ||||||
|
||||||
var _ Messenger = MessageHandlerFunc(nil) | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,14 +308,20 @@ func TestIBCRawPacketHandler(t *testing.T) { | |
capturedPacket = nil | ||
// when | ||
h := NewIBCRawPacketHandler(spec.chanKeeper, spec.capKeeper) | ||
data, evts, gotErr := h.DispatchMsg(ctx, RandomAccountAddress(t), ibcPort, wasmvmtypes.CosmosMsg{IBC: &wasmvmtypes.IBCMsg{SendPacket: &spec.srcMsg}}) | ||
evts, data, gotErr := h.DispatchMsg(ctx, RandomAccountAddress(t), ibcPort, wasmvmtypes.CosmosMsg{IBC: &wasmvmtypes.IBCMsg{SendPacket: &spec.srcMsg}}) | ||
// then | ||
require.True(t, spec.expErr.Is(gotErr), "exp %v but got %#+v", spec.expErr, gotErr) | ||
if spec.expErr != nil { | ||
return | ||
} | ||
assert.Nil(t, data) | ||
|
||
assert.Nil(t, evts) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really? The events are nil? How do we get the ibc packet events to the relayers here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, via context. |
||
require.NotNil(t, data) | ||
|
||
msg := &types.MsgIBCSendResponse{Sequence: 1} | ||
val, err := msg.Marshal() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same code as used in the handler. When you |
||
require.NoError(t, err) | ||
assert.Equal(t, data[0], val) | ||
assert.Equal(t, spec.expPacketSent, capturedPacket) | ||
}) | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.