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: make #18472 test structure same as backports #18504

Merged
merged 2 commits into from
Nov 17, 2023
Merged

Conversation

julienrbrt
Copy link
Member

@julienrbrt julienrbrt commented Nov 17, 2023

Description

Small follow-up of #18472
When backporting this fix, the package name changes of tests was giving an import cycle in the backport PR.
As I had to modify some files in both backport, I make those changes as well here to keep consistency and reduce the diff we'll have during our audit.

ref: #18502
ref: #18503


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...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

Reviewers 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...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

  • Refactor

    • Renamed the test package for improved clarity and compliance with Go standards.
    • Updated variable initialization to align with the new package structure.
  • Tests

    • Added a new test case to enhance the testing suite and ensure functionality correctness.
  • Documentation

    • Updated the changelog to reflect recent changes and improvements.
    • Clarified configuration options in comments to assist with user customization.
  • Chores

    • Removed invalid configuration from migration templates to streamline user experience.

@julienrbrt julienrbrt requested a review from a team as a code owner November 17, 2023 21:39
Copy link
Contributor

coderabbitai bot commented Nov 17, 2023

Walkthrough

The changes involve minor updates and refactoring across several files in a codebase, likely related to a blockchain or financial software project. A test package is renamed, global variables are added for testing, and a new test case is introduced. Additionally, there's a documentation update in the changelog and a clarifying comment in a configuration-related file. These changes seem to be part of routine maintenance and improvement of the code and its documentation.

Changes

File(s) Change Summary
client/tx/aux_builder_test.go Renamed package to tx_test, added imports and global variables, and updated AuxTxBuilder initialization.
client/tx/tx_test.go Added a new test case TestPreprocessHook.
tools/confix/CHANGELOG.md Added a pull request link to changelog for removing invalid config.
simapp/simd/cmd/config.go (x2) Modified a comment for clarity on srvCfg.MinGasPrices usage.

Poem

As autumn leaves begin to twirl,
A rabbit hops through code, a swirl.
Refactoring with care and glee,
Crafting changes, making history. 🍂🐰✨


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 80e0c63 and f9a6a34.
Files selected for processing (3)
  • client/tx/aux_builder_test.go (4 hunks)
  • client/tx/tx_test.go (1 hunks)
  • tools/confix/CHANGELOG.md (1 hunks)
Files skipped from review due to trivial changes (1)
  • client/tx/tx_test.go
Additional comments: 5
tools/confix/CHANGELOG.md (1)
  • 34-34: The changelog update correctly references the pull request and provides a brief description of the change. It follows the established format and is placed under the "Unreleased" section, which is appropriate for changes that have not yet been included in a released version.
client/tx/aux_builder_test.go (4)
  • 1-11: The renaming of the package from tx to tx_test is a good practice to avoid import cycles and to indicate that the file contains tests for the tx package. This change also helps to ensure that the test code is only compiled when running tests and not included in the final build of the package.

  • 15-32: The introduction of new global variables (memo, timeoutHeight, rawSig, msg1, and chainID) is a common pattern in tests to define constants and variables that will be reused across different test cases. However, it's important to ensure that these variables are not mutated during test execution to prevent side effects that could affect other tests. If mutation is necessary, consider using a setup function to provide a fresh set of variables for each test case.

  • 40-46: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [34-217]

The test cases are well-structured and cover a variety of scenarios, including error cases and successful paths. The use of table-driven tests is a good practice for clarity and maintainability. However, it's important to reset the AuxTxBuilder before each test case to avoid state leakage between tests. This is correctly done on line 217 with b = tx.NewAuxTxBuilder(), ensuring that each test case starts with a fresh builder.

  • 214-220: The loop correctly creates a new scope for each test case, preventing parallel test execution issues. However, if tests are to be run in parallel, you would need to add t.Parallel() inside the t.Run function. Since this is not present, it's assumed that parallel execution is not intended or necessary for these tests.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f9a6a34 and f0eee82.
Files selected for processing (1)
  • simapp/simd/cmd/config.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • simapp/simd/cmd/config.go

Copy link
Collaborator

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Nice catch and thank you @julienrbrt, LGTM!

@julienrbrt julienrbrt added this pull request to the merge queue Nov 17, 2023
Merged via the queue into main with commit 4b8be25 Nov 17, 2023
52 of 60 checks passed
@julienrbrt julienrbrt deleted the julien/chores branch November 17, 2023 23:58
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.

2 participants