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

refactor: move upgrade unit tests together #3302

Merged
merged 14 commits into from
Apr 18, 2024

Conversation

ninabarbakadze
Copy link
Member

@ninabarbakadze ninabarbakadze commented Apr 11, 2024

Overview

Moves all upgrade unit tests in one place

@ninabarbakadze ninabarbakadze changed the title chore: move ica upgrade test to test refactor: move ica upgrade test to test directory Apr 11, 2024
@ninabarbakadze ninabarbakadze marked this pull request as ready for review April 11, 2024 18:28
@ninabarbakadze ninabarbakadze requested a review from a team as a code owner April 11, 2024 18:28
@ninabarbakadze ninabarbakadze requested review from rootulp and cmwaters and removed request for a team April 11, 2024 18:28
Copy link
Contributor

coderabbitai bot commented Apr 11, 2024

Walkthrough

Walkthrough

The recent updates focus on enhancing test configurations for application upgrades by introducing a utility function for setting up test environments. New tests have been added to assess the behavior of the application during version upgrades, specifically targeting minimum fees, Interchain Accounts (ICA), and packet forwarding. The restructuring also involves cleaning up obsolete code and imports, streamlining the setup process across various test modules.

Changes

File Path Change Summary
app/test/upgrade_test.go Replaced old setup function with SetupTestAppWithUpgradeHeight and added tests for version upgrades, ICA, and packet forwarding.
test/ica/ica_upgrade_test.go Introduced a test to verify ICA module behavior during upgrades.
test/packetforward/packetforward_upgrade_test.go Streamlined test setup and removed unnecessary imports and code.
test/util/testapp_upgrade.go Introduced SetupTestApp function for initializing test applications.
x/minfee/upgrade_test.go Updated setup function to util.SetupTestApp and cleaned up imports.

Recent Review Details

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 17bf8a5 and d6f3cae.
Files selected for processing (1)
  • app/test/upgrade_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/test/upgrade_test.go

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:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

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

rootulp
rootulp previously approved these changes Apr 11, 2024
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -0,0 +1,56 @@
package util
Copy link
Collaborator

Choose a reason for hiding this comment

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

cmwaters
cmwaters previously approved these changes Apr 12, 2024
Copy link
Contributor

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

The other approach would be to say that these are all upgrade tests and just to bundle them up together rather than adding a new test for each new module

dbm "github.com/tendermint/tm-db"
)

func SetupTestApp(t *testing.T, upgradeHeight int64) (*app.App, keyring.Keyring) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
func SetupTestApp(t *testing.T, upgradeHeight int64) (*app.App, keyring.Keyring) {
func SetupTestAppWithUpgradeHeight(t *testing.T, upgradeHeight int64) (*app.App, keyring.Keyring) {

@ninabarbakadze ninabarbakadze dismissed stale reviews from cmwaters and rootulp via f1a8997 April 15, 2024 19:38
@celestia-bot celestia-bot requested review from a team, ramin and rootulp and removed request for a team April 15, 2024 19:38
@ninabarbakadze ninabarbakadze changed the title refactor: move ica upgrade test to test directory refactor: move upgrade unit tests together Apr 15, 2024
@celestia-bot celestia-bot requested a review from a team April 15, 2024 19:47
rootulp
rootulp previously approved these changes Apr 15, 2024
@ninabarbakadze ninabarbakadze requested a review from cmwaters April 16, 2024 07:51
Copy link
Contributor

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

You're still repeating yourself a lot here. This kind of pattern lends itself to table based testing.

testCases := []struct {
	module string
	preUpgradeAssertion func (t *testing.T, app *app.App)
	postUpgradeAssertion func(t *testing.T, app *app.App)
}{
	{
		module: "signal",
		preUpgradeAssertion: func(t *testing.T, app *app.App, ) {
			// add assertions about how this module doesn't yet exist
		},
		postUpgradeAssertion: func(t *testing.T, app *app.App) {
			// add assertions about how this module now exists
		},
	},
}

// start up the testnet

// do the pre upgrade assertions for all testCases

// upgrade the application and check it succeeded

// do all the post upgrade assertions for all testCases

Also don't forget that when a test errors that it tells the caller which module failed and at which stage

@celestia-bot celestia-bot requested review from a team and cmwaters and removed request for a team April 16, 2024 17:23
cmwaters
cmwaters previously approved these changes Apr 17, 2024
Copy link
Contributor

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

Looks good once you fix the conflicts

@ninabarbakadze ninabarbakadze requested a review from liamsi as a code owner April 17, 2024 15:27
@celestia-bot celestia-bot requested review from a team and rach-id and removed request for a team April 17, 2024 15:27
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: 2

Comment on lines 74 to 76
# Persist ABCI responses
sed -i'.bak' 's#discard_abci_responses = true#discard_abci_responses = false#g' "${CELESTIA_APP_HOME}"/config/config.toml

Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The verification process did not find any tests specifically addressing the handling of ABCI responses in the shell scripts. This supports the initial review comment's emphasis on the need for thorough testing and documentation of the changes made to persist ABCI responses. It is crucial to ensure that these changes are well-tested and documented, particularly regarding their impact on node performance and storage requirements.

Analysis chain

Persisting ABCI responses by setting discard_abci_responses to false is a significant change. Ensure that this behavior is thoroughly tested and documented, especially regarding its impact on node performance and storage requirements.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Check for tests related to ABCI response handling.
rg --type sh 'ABCI response'

Length of output: 78

Comment on lines 28 to 30
// FilterTxs applies the antehandler to all proposed transactions and removes
// transactions that return an error.
//
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The investigation into the FilterTxs function and its associated tests reveals that while the function is used in the test scenario within out_of_order_prepare.go, there is no explicit evidence of tests specifically designed to verify the new functionalities of handling errors and arranging transactions as described in the review comment. It is recommended to create targeted tests to ensure these functionalities work as intended and do not introduce any unintended side effects.

Analysis chain

The updates to the FilterTxs function to apply an antehandler to all proposed transactions, remove transactions that return an error, and arrange transactions improve the robustness of transaction handling. Ensure that these changes are thoroughly tested to confirm that they work as expected and do not introduce any unintended side effects.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Check for tests covering the new transaction handling in FilterTxs.
rg --type go 'FilterTxs' | grep 'test'

Length of output: 167



Script:

#!/bin/bash
# Search for detailed test cases specifically covering the new functionalities in FilterTxs.
rg --type go -C 10 'FilterTxs' test/

Length of output: 1689

@ninabarbakadze ninabarbakadze marked this pull request as draft April 17, 2024 17:00
@ninabarbakadze ninabarbakadze marked this pull request as ready for review April 18, 2024 09:55
@evan-forbes evan-forbes self-requested a review April 18, 2024 12:44
@ninabarbakadze ninabarbakadze merged commit 34915fc into celestiaorg:main Apr 18, 2024
32 of 33 checks passed
@ninabarbakadze ninabarbakadze deleted the nina/move-ica-tests branch April 18, 2024 12:50
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.

4 participants