Repository navigation
test(wasm): cover stargate ibc transfer - #164
Conversation
WalkthroughThis PR adds support for testing IBC transfer contracts within the CosmWasm testing environment. It introduces a new ChangesIBC Transfer WASM Contract Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/wasmtesting/stargate-ibc-transfer/src/proto.rs (1)
76-99: ⚡ Quick winAdd a regression test for omitted default fields.
Lines 77-99 only validate the “memo+timeout present” path. Add a case with
timeout_timestamp = 0andmemo = None/empty to lock in omission semantics for fields 7 and 8.Suggested test addition
#[cfg(test)] mod tests { use super::{encode_msg_transfer, MsgTransfer}; @@ fn encodes_ibc_transfer_msg() { @@ } + + #[test] + fn omits_zero_timeout_and_empty_memo() { + let encoded = encode_msg_transfer(MsgTransfer { + source_port: "transfer", + source_channel: "channel-0", + denom: "uinit", + amount: "123", + sender: "init1sender", + receiver: "cosmos1receiver", + timeout_timestamp: 0, + memo: None, + }); + + assert_eq!( + encoded, + vec![ + 10, 8, 116, 114, 97, 110, 115, 102, 101, 114, 18, 9, 99, 104, 97, 110, 110, 101, + 108, 45, 48, 26, 12, 10, 5, 117, 105, 110, 105, 116, 18, 3, 49, 50, 51, 34, 11, + 105, 110, 105, 116, 49, 115, 101, 110, 100, 101, 114, 42, 15, 99, 111, 115, 109, + 111, 115, 49, 114, 101, 99, 101, 105, 118, 101, 114, + ] + ); + } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/wasmtesting/stargate-ibc-transfer/src/proto.rs` around lines 76 - 99, Add a regression test inside the encodes_ibc_transfer_msg test (or as a new #[test]) that covers the omitted-defaults path by calling encode_msg_transfer with a MsgTransfer where timeout_timestamp is 0 and memo is None (or empty) and assert the produced bytes match the expected encoding that omits fields 7 and 8; locate the encode_msg_transfer function and the MsgTransfer struct in this file to craft the input and generate the expected vector, ensuring the assertion pins omission semantics for those fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/wasmtesting/stargate-ibc-transfer/src/msg.rs`:
- Around line 14-16: Change ExecuteMsg::IbcTransfer's timeout_timestamp from u64
to cosmwasm_std::Uint64 in msg.rs so it serializes as a JSON string and
preserves 64-bit precision; then update the call site that builds the IBC
transfer proto (where proto::encode_msg_transfer is invoked in lib.rs) to
convert the Uint64 back to a raw u64 (e.g., timeout_timestamp.u64()) or
appropriate representation expected by encode_msg_transfer. Ensure imports for
Uint64 are added and types adjusted wherever ExecuteMsg::IbcTransfer is
constructed or pattern-matched.
---
Nitpick comments:
In `@app/wasmtesting/stargate-ibc-transfer/src/proto.rs`:
- Around line 76-99: Add a regression test inside the encodes_ibc_transfer_msg
test (or as a new #[test]) that covers the omitted-defaults path by calling
encode_msg_transfer with a MsgTransfer where timeout_timestamp is 0 and memo is
None (or empty) and assert the produced bytes match the expected encoding that
omits fields 7 and 8; locate the encode_msg_transfer function and the
MsgTransfer struct in this file to craft the input and generate the expected
vector, ensuring the assertion pins omission semantics for those fields.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7951b79a-6034-4682-9772-1e36e33d31c8
⛔ Files ignored due to path filters (2)
app/wasmtesting/stargate-ibc-transfer/Cargo.lockis excluded by!**/*.lockapp/wasmtesting/stargate-ibc-transfer/artifacts/stargate_ibc_transfer.wasmis excluded by!**/*.wasm
📒 Files selected for processing (9)
app/wasmtesting/common_test.goapp/wasmtesting/stargate-ibc-transfer/.cargo/config.tomlapp/wasmtesting/stargate-ibc-transfer/.gitignoreapp/wasmtesting/stargate-ibc-transfer/Cargo.tomlapp/wasmtesting/stargate-ibc-transfer/artifacts/checksums.txtapp/wasmtesting/stargate-ibc-transfer/src/lib.rsapp/wasmtesting/stargate-ibc-transfer/src/msg.rsapp/wasmtesting/stargate-ibc-transfer/src/proto.rsapp/wasmtesting/stargate_test.go
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #164 +/- ##
=======================================
Coverage 42.54% 42.54%
=======================================
Files 49 49
Lines 3154 3154
=======================================
Hits 1342 1342
Misses 1675 1675
Partials 137 137 🚀 New features to boost your workflow:
|
Description
Closes: N/A
Adds a minimal CosmWasm contract that dispatches
/ibc.applications.transfer.v1.MsgTransferthrough stargate, plus a wasmtesting regression test that stores, instantiates, and executes it. The test registers a captureMsgServerfor the transfer service so it can verify the decodedMsgTransferfields without requiring a live IBC channel.Critical files to review:
app/wasmtesting/stargate-ibc-transfer/src/lib.rsapp/wasmtesting/stargate-ibc-transfer/src/proto.rsapp/wasmtesting/stargate_test.goapp/wasmtesting/common_test.goValidation:
go test ./app/wasmtesting -run 'Test_Stargate(Query|IBCTransfer)' -count=1cargo testinapp/wasmtesting/stargate-ibc-transfercosmwasm/optimizer-arm64:0.17.0generatedartifacts/stargate_ibc_transfer.wasmBreaking changes: none.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!in the type prefix if API or client breaking change: N/A, no breaking changemainReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
Summary by CodeRabbit
New Features
Tests
Chores