-
Notifications
You must be signed in to change notification settings - Fork 15
tests: add ibc test cases #63
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
Conversation
more test cases will be added.
OnTimeoutPacket, OnAcknowledgementPacket
4266a7b
to
2c2ff33
Compare
and also update comments and variable name
089b850
to
626aa09
Compare
4f04bdf
to
ffd131a
Compare
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.
Overall, this looks good to me
- How about adding a test case to reach coverage this part as well?
- We also need to add test cases for the ICS20-related precompile, but since the removal of authz dependency is currently in progress, it seems more efficient to handle it after that change is completed.
make sure whether it is registered as dynamic precompiled contract or not
61c91c8
to
c098171
Compare
Thank you for your feedback. The part you mentioned is already covered by existing test cases. Case1: Source native denom through IBC to ERC20 precompiled contract // Case 1. token pair is not registered and is a single hop IBC Coin
// by checking the prefix we ensure that only coins not native from this chain are evaluated.
// IsNativeFromSourceChain will check if the coin is native from the source chain.
// If the coin denom starts with `factory/` then it is a token factory coin, and we should not convert it
// NOTE: Check https://docs.osmosis.zone/osmosis-core/modules/tokenfactory/ for more information
case !found && strings.HasPrefix(coin.Denom, "ibc/") && ibc.IsBaseDenomFromSourceChain(data.Denom):
tokenPair, err := k.RegisterERC20Extension(ctx, coin.Denom)
if err != nil {
return channeltypes.NewErrorAcknowledgement(err)
}
ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
types.EventTypeRegisterERC20Extension,
sdk.NewAttribute(types.AttributeCoinSourceChannel, packet.SourceChannel),
sdk.NewAttribute(types.AttributeKeyERC20Token, tokenPair.Erc20Address),
sdk.NewAttribute(types.AttributeKeyCosmosCoin, tokenPair.Denom),
),
},
)
return ack Case2: Receiving ERC20 native coin through IBC // Case 2. native ERC20 token
case found && pair.IsNativeERC20():
// Token pair is disabled -> return
if !pair.Enabled {
return ack
}
balance := k.bankKeeper.GetBalance(ctx, recipient, coin.Denom)
if err := k.ConvertCoinNativeERC20(ctx, pair, balance.Amount, common.BytesToAddress(recipient.Bytes()), recipient); err != nil {
return channeltypes.NewErrorAcknowledgement(err)
}
// For now the only case we are interested in adding telemetry is a successful conversion.
telemetry.IncrCounterWithLabels(
[]string{types.ModuleName, "ibc", "on_recv", "total"},
1,
[]metrics.Label{
telemetry.NewLabel("denom", coin.Denom),
telemetry.NewLabel("source_channel", packet.SourceChannel),
telemetry.NewLabel("source_port", packet.SourcePort),
},
)
} This is tested in v1 |
Regarding your second point about adding test cases for the ICS20-related precompile:
What do you think about this approach? |
Ah, it seems like the coverage was mistakenly recognized as missing due to an issue with the measurement on my local environment. I confirmed that the breakpoint is hit and the coverage is reached in debug mode. 🙏
Yes, I agree that it would be better to handle the ICS20-related tests in a separate PR, as you suggested. I’ll finish the review and proceed with the approval within today. |
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.
It seems that the main ibc middleware cases are covered.
I’m currently working separately on test cases for the ICS20 precompile's transfer related to this issue.
Once it’s complete, I’ll open a PR and request a review.
Description
This PR adds test coverage to verify that both IBC v1 and IBC v2 flows are working as expected in
ExampleChain
.Coverage
Closes: #46
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...
main
branchReviewers 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...
Unreleased
section inCHANGELOG.md