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

Fix ibcratelimit tests. #1977

Merged
merged 9 commits into from
May 17, 2024
Merged

Fix ibcratelimit tests. #1977

merged 9 commits into from
May 17, 2024

Conversation

Taztingo
Copy link
Contributor

@Taztingo Taztingo commented May 16, 2024

Description

Fixes the tests for the ibcratelimit module.

Related: #1760


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

Summary by CodeRabbit

  • New Features

    • Added rate limit middleware for IBC transactions.
  • Bug Fixes

    • Fixed unit tests for ibcratelimit.
    • Corrected chain ID handling in test contexts.
  • Improvements

    • Updated dependency versions for better performance and security.
    • Enhanced deserialization and serialization in rate-limiter contracts.
  • Testing Enhancements

    • Improved test functions to use JSON for data handling.
    • Added new test cases for middleware functionality.

Copy link
Contributor

coderabbitai bot commented May 16, 2024

Walkthrough

The recent changes in the provenance repository focus on enhancing the ibcratelimit functionality, updating dependencies, and refining unit tests. Key modifications include updating serialization methods, adjusting test logic for IBC transactions, and incorporating middleware enhancements. This overhaul ensures better compatibility, performance, and reliability of the IBC rate-limiting features.

Changes

File/Path Change Summary
CHANGELOG.md
.app/app.go
Fixed unit tests for ibcratelimit. Added ibctm module, RateLimitMiddleware field, and updated New function.
internal/antewrapper/msg_fees_decorator.go Updated isTestContext to include testchain prefix for IBC tests.
testutil/contracts/rate-limiter/Cargo.toml Updated dependency versions for various packages.
testutil/contracts/rate-limiter/artifacts/checksums.txt Updated checksums for wasm files.
testutil/contracts/rate-limiter/artifacts/checksums_intermediate.txt Updated checksum for rate_limiter.wasm.
testutil/contracts/rate-limiter/src/contract_tests.rs
testutil/contracts/rate-limiter/src/execute.rs
testutil/contracts/rate-limiter/src/helpers.rs
testutil/contracts/rate-limiter/src/management.rs
testutil/contracts/rate-limiter/src/query.rs
Serialization method updates from binary to JSON and vice versa.
testutil/ibc/testchain.go Updated IBC testing functions and logic.
x/ibchooks/ibc_middleware_test.go Modified functions and return values.
x/ibchooks/keeper/params.go Added import statements for sdk and types.
x/ibcratelimit/module/ibc_middleware.go Added import for transfertypes and additional logic.
x/ibcratelimit/module/ibc_middleware_test.go Added imports, updated function signatures, added tests, and made adjustments.

In the realm of code, where changes thrive,
A rabbit hops, keeping dreams alive.
With ibcratelimit set to soar,
Dependencies updated, tests galore!
Serialization shifts, from binary to JSON,
Our blockchain hums, a brighter dawn.
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Taztingo Taztingo marked this pull request as ready for review May 16, 2024 17:58
@Taztingo Taztingo requested a review from a team as a code owner May 16, 2024 17:58
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Out of diff range and nitpick comments (1)
CHANGELOG.md (1)

Line range hint 102-116: Fix unordered list style.

- - Bump `github.com/cosmos/ibc-go/v8` from 8.0.0 to 8.2.1 ([#1910](https://github.com/provenance-io/provenance/pull/1910), [#1956](https://github.com/provenance-io/provenance/pull/1956))
- - Bump `google.golang.org/grpc` from 1.62.1 to 1.64.0 ([#1903](https://github.com/provenance-io/provenance/pull/1903), [#1918](https://github.com/provenance-io/provenance/pull/1918), [#1972](https://github.com/provenance-io/provenance/pull/1972))
- - Bump `bufbuild/buf-breaking-action` from 1.1.3 to 1.1.4 ([#1894](https://github.com/provenance-io/provenance/pull/1894))
- - Bump `bufbuild/buf-lint-action` from 1.1.0 to 1.1.1 ([#1895](https://github.com/provenance-io/provenance/pull/1895))
- - Bump `bufbuild/buf-setup-action` from 1.30.0 to 1.31.0 ([#1904](https://github.com/provenance-io/provenance/pull/1904), [#1949](https://github.com/provenance-io/provenance/pull/1949))
- - Bump `github.com/cometbft/cometbft` from 0.38.5 to 0.38.7 ([#1912](https://github.com/provenance-io/provenance/pull/1912), [#1959](https://github.com/provenance-io/provenance/pull/1959))
- - Bump `cosmossdk.io/x/upgrade` from 0.1.0 to 0.1.1 ([#1913](https://github.com/provenance-io/provenance/pull/1913))
- - Bump `github.com/hashicorp/go-metrics` from 0.5.2 to 0.5.3 ([#1914](https://github.com/provenance-io/provenance/pull/1914))
- - Bump `peter-evans/create-pull-request` from 6.0.2 to 6.0.5 ([#1929](https://github.com/provenance-io/provenance/pull/1929), [#1940](https://github.com/provenance-io/provenance/pull/1940), [#1955](https://github.com/provenance-io/provenance/pull/1955))
- - Bump `cosmossdk.io/x/tx` from 0.13.1 to 0.13.3 ([#1928](https://github.com/provenance-io/provenance/pull/1928), [#1944](https://github.com/provenance-io/provenance/pull/1944))
- - Bump `cosmwasm-std` from 1.4.1 to 1.4.4 ([#1950](https://github.com/provenance-io/provenance/pull/1950))
- - Bump `golangci/golangci-lint-action` from 4 to 6 ([#1951](https://github.com/provenance-io/provenance/pull/1951), [#1965](https://github.com/provenance-io/provenance/pull/1965))
- - Bump `google.golang.org/protobuf` from 1.33.0 to 1.34.1 ([#1960](https://github.com/provenance-io/provenance/pull/1960), [#1966](https://github.com/provenance-io/provenance/pull/1966))
- - Bump `github.com/hashicorp/go-getter` from 1.7.3 to 1.7.4 ([#1958](https://github.com/provenance-io/provenance/pull/1958))
- - Bump `golang.org/x/text` from 0.14.0 to 0.15.0 ([#1964](https://github.com/provenance-io/provenance/pull/1964))
+ * Bump `github.com/cosmos/ibc-go/v8` from 8.0.0 to 8.2.1 ([#1910](https://github.com/provenance-io/provenance/pull/1910), [#1956](https://github.com/provenance-io/provenance/pull/1956))
+ * Bump `google.golang.org/grpc` from 1.62.1 to 1.64.0 ([#1903](https://github.com/provenance-io/provenance/pull/1903), [#1918](https://github.com/provenance-io/provenance/pull/1918), [#1972](https://github.com/provenance-io/provenance/pull/1972))
+ * Bump `bufbuild/buf-breaking-action` from 1.1.3 to 1.1.4 ([#1894](https://github.com/provenance-io/provenance/pull/1894))
+ * Bump `bufbuild/buf-lint-action` from 1.1.0 to 1.1.1 ([#1895](https://github.com/provenance-io/provenance/pull/1895))
+ * Bump `bufbuild/buf-setup-action` from 1.30.0 to 1.31.0 ([#1904](https://github.com/provenance-io/provenance/pull/1904), [#1949](https://github.com/provenance-io/provenance/pull/1949))
+ * Bump `github.com/cometbft/cometbft` from 0.38.5 to 0.38.7 ([#1912](https://github.com/provenance-io/provenance/pull/1912), [#1959](https://github.com/provenance-io/provenance/pull/1959))
+ * Bump `cosmossdk.io/x/upgrade` from 0.1.0 to 0.1.1 ([#1913](https://github.com/provenance-io/provenance/pull/1913))
+ * Bump `github.com/hashicorp/go-metrics` from 0.5.2 to 0.5.3 ([#1914](https://github.com/provenance-io/provenance/pull/1914))
+ * Bump `peter-evans/create-pull-request` from 6.0.2 to 6.0.5 ([#1929](https://github.com/provenance-io/provenance/pull/1929), [#1940](https://github.com/provenance-io/provenance/pull/1940), [#1955](https://github.com/provenance-io/provenance/pull/1955))
+ * Bump `cosmossdk.io/x/tx` from 0.13.1 to 0.13.3 ([#1928](https://github.com/provenance-io/provenance/pull/1928), [#1944](https://github.com/provenance-io/provenance/pull/1944))
+ * Bump `cosmwasm-std` from 1.4.1 to 1.4.4 ([#1950](https://github.com/provenance-io/provenance/pull/1950))
+ * Bump `golangci/golangci-lint-action` from 4 to 6 ([#1951](https://github.com/provenance-io/provenance/pull/1951), [#1965](https://github.com/provenance-io/provenance/pull/1965))
+ * Bump `google.golang.org/protobuf` from 1.33.0 to 1.34.1 ([#1960](https://github.com/provenance-io/provenance/pull/1960), [#1966](https://github.com/provenance-io/provenance/pull/1966))
+ * Bump `github.com/hashicorp/go-getter` from 1.7.3 to 1.7.4 ([#1958](https://github.com/provenance-io/provenance/pull/1958))
+ * Bump `golang.org/x/text` from 0.14.0 to 0.15.0 ([#1964](https://github.com/provenance-io/provenance/pull/1964))
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 93002e8 and b251d80.
Files ignored due to path filters (3)
  • testutil/contracts/rate-limiter/Cargo.lock is excluded by !**/*.lock
  • testutil/contracts/rate-limiter/artifacts/rate_limiter-aarch64.wasm is excluded by !**/*.wasm
  • testutil/contracts/rate-limiter/artifacts/rate_limiter.wasm is excluded by !**/*.wasm
Files selected for processing (16)
  • CHANGELOG.md (1 hunks)
  • app/app.go (5 hunks)
  • internal/antewrapper/msg_fees_decorator.go (2 hunks)
  • testutil/contracts/rate-limiter/Cargo.toml (1 hunks)
  • testutil/contracts/rate-limiter/artifacts/checksums.txt (1 hunks)
  • testutil/contracts/rate-limiter/artifacts/checksums_intermediate.txt (1 hunks)
  • testutil/contracts/rate-limiter/src/contract_tests.rs (5 hunks)
  • testutil/contracts/rate-limiter/src/execute.rs (4 hunks)
  • testutil/contracts/rate-limiter/src/helpers.rs (3 hunks)
  • testutil/contracts/rate-limiter/src/management.rs (4 hunks)
  • testutil/contracts/rate-limiter/src/query.rs (2 hunks)
  • testutil/ibc/testchain.go (3 hunks)
  • x/ibchooks/ibc_middleware_test.go (1 hunks)
  • x/ibchooks/keeper/params.go (1 hunks)
  • x/ibcratelimit/module/ibc_middleware.go (2 hunks)
  • x/ibcratelimit/module/ibc_middleware_test.go (10 hunks)
Files not reviewed due to errors (4)
  • testutil/contracts/rate-limiter/src/management.rs (no review received)
  • testutil/contracts/rate-limiter/src/execute.rs (no review received)
  • x/ibcratelimit/module/ibc_middleware.go (no review received)
  • x/ibchooks/ibc_middleware_test.go (no review received)
Files skipped from review due to trivial changes (3)
  • testutil/contracts/rate-limiter/Cargo.toml
  • testutil/contracts/rate-limiter/artifacts/checksums.txt
  • testutil/contracts/rate-limiter/artifacts/checksums_intermediate.txt
Additional comments not posted (19)
testutil/contracts/rate-limiter/src/query.rs (1)

1-1: LGTM! The change to use to_json_binary aligns with the PR's objective to switch serialization methods.

Also applies to: 11-11

x/ibchooks/keeper/params.go (1)

5-5: LGTM! The added imports are necessary for the functions to work correctly.

testutil/contracts/rate-limiter/src/helpers.rs (1)

5-5: LGTM! The change to use to_json_binary aligns with the PR's objective to switch serialization methods.

Also applies to: 21-21, 31-31

internal/antewrapper/msg_fees_decorator.go (1)

4-5: LGTM! The update to isTestContext to recognize chain IDs starting with "testchain" is necessary for the tests.

Also applies to: 82-84

testutil/ibc/testchain.go (3)

Line range hint 86-127: Ensure proper error handling and assertions.

The changes to SendMsgsNoCheck look good, but please verify that all calls to this function have been updated to match the new signature and that error handling is consistent.

Verification successful

All calls to SendMsgsNoCheck have been updated to match the new signature

The search results confirm that all instances of SendMsgsNoCheck in the codebase have been updated to use the new signature with the suite parameter. The error handling and assertions around these calls also appear to be consistent with the new function definition.

  • x/ibcratelimit/module/ibc_middleware_test.go
  • x/ibchooks/ibc_middleware_test.go
  • testutil/ibc/testchain.go

These files correctly use the new signature and handle the returned abci.ExecTxResult appropriately.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all function calls to `SendMsgsNoCheck` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go $'SendMsgsNoCheck'

Length of output: 753



Script:

#!/bin/bash
# Description: Verify the context of each call to `SendMsgsNoCheck` to ensure they match the new signature.

# Extract and review lines around each call to `SendMsgsNoCheck`
rg --type go --context 5 $'SendMsgsNoCheck'

Length of output: 4406


129-154: LGTM! The commitBlock function is a good addition for handling block commitments in tests.


160-190: LGTM! The changes to SignAndDeliver enhance the granularity of test results.

testutil/contracts/rate-limiter/src/contract_tests.rs (3)

6-6: Import change aligns with deserialization updates.


244-244: Deserialization method updated to from_json.


314-314: Deserialization method updated to from_json.

x/ibcratelimit/module/ibc_middleware_test.go (6)

17-17: Import statement for abci looks good.


24-24: Import statement for transfertypes looks good.


130-146: Function FullSendBToA changes look good. Ensure all function calls handle the new return type correctly.


151-177: Function FullSendAToB changes look good. Ensure all function calls handle the new return type correctly.


201-207: Function AssertSend changes look good. Ensure all function calls handle the new return type correctly.


221-241: New test function TestNonICS20 looks good.

app/app.go (3)

127-127: Import statement for IBC Tendermint light client module looks good.


296-296: Addition of RateLimitMiddleware field in the App struct looks good.


547-548: Integration of RateLimitMiddleware and addition of ibctm.AppModule{} in the New function looks good.

@Taztingo Taztingo enabled auto-merge (squash) May 16, 2024 18:22
@SpicyLemon
Copy link
Contributor

Can you update .github/workflows/test.yml so that the github action runs these tests again?

@Taztingo Taztingo requested a review from SpicyLemon May 16, 2024 22:11
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between b251d80 and e3b41bf.
Files ignored due to path filters (1)
  • testutil/contracts/rate-limiter/artifacts/rate_limiter.wasm is excluded by !**/*.wasm
Files selected for processing (1)
  • x/ibcratelimit/module/ibc_middleware_test.go (11 hunks)
Additional comments not posted (28)
x/ibcratelimit/module/ibc_middleware_test.go (28)

62-84: LGTM! The setup for the test environment is well-structured.


Line range hint 88-98: LGTM! The message construction for transferring tokens from chain A to chain B is correct.


Line range hint 109-119: LGTM! The message construction for transferring tokens from chain B to chain A is correct.


130-146: LGTM! The process for sending a message from chain B to chain A is handled correctly.


151-177: LGTM! The process for sending a message from chain A to chain B is handled correctly.


185-194: LGTM! The assertion for the receive operation from chain B to chain A is correct.


201-207: LGTM! The assertion for the send operation from chain A to chain B is correct.


213-215: LGTM! The quota message construction is correct.


222-241: LGTM! The test for rate limit reversion on send failure is correct.


244-247: LGTM! The test for sending IBC messages without middleware configuration is correct.


251-254: LGTM! The test for receiving IBC messages without middleware configuration is correct.


Line range hint 258-277: LGTM! The escrow setup is correct.


Line range hint 282-332: LGTM! The full send test with rate limiting is correct.


337-339: LGTM! The test for rate limiting on sends with native tokens is correct.


343-347: LGTM! The test for rate limiting on sends with non-native tokens is correct.


351-372: LGTM! The test for rate limit reset is correct.


Line range hint 376-419: LGTM! The full receive test with rate limiting is correct.


422-426: LGTM! The test for rate limiting on receives with native tokens is correct.


429-433: LGTM! The test for rate limiting on receives with non-native tokens is correct.


437-447: LGTM! The test for sending IBC messages without quotas is correct.


451-520: LGTM! The test for rate limit reversion on send failure is correct.


523-533: LGTM! The test for unsetting the rate limiting contract is correct.


538-543: LGTM! The event finding logic is correct.


Line range hint 547-555: LGTM! The attribute extraction logic is correct.


Line range hint 558-569: LGTM! The init message creation logic is correct.


Line range hint 573-593: LGTM! The channel value calculation logic is correct.


Line range hint 597-604: LGTM! The transfer path creation logic is correct.


Line range hint 607-613: LGTM! The logic to skip tests on WSL is correct.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between e3b41bf and 306d9c0.
Files selected for processing (1)
  • .github/workflows/test.yml (1 hunks)
Files skipped from review due to trivial changes (1)
  • .github/workflows/test.yml

@Taztingo Taztingo requested a review from SpicyLemon May 17, 2024 15:10
@Taztingo Taztingo merged commit 2adf2c5 into main May 17, 2024
25 of 36 checks passed
@Taztingo Taztingo deleted the taztingo/v50-fix-ratelimit-tests branch May 17, 2024 18:37
@Taztingo Taztingo self-assigned this May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants