Skip to content

test: fix sim tests#3983

Merged
kingpinXD merged 4 commits intodevelopfrom
fix-sim
Jun 17, 2025
Merged

test: fix sim tests#3983
kingpinXD merged 4 commits intodevelopfrom
fix-sim

Conversation

@kingpinXD
Copy link
Member

@kingpinXD kingpinXD commented Jun 16, 2025

Description

Closes : #3982

Provides a work around for : #3979

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • Bug Fixes

    • Improved consistency and clarity in error handling and logging during app state export and zero-height genesis preparation.
    • Standardized address conversion methods for validator and delegator addresses to enhance reliability.
    • Updated test logic to skip comparison of a specific key prefix during state import/export, preventing false-positive test failures.
  • Chores

    • Refined internal comments and reordered checks for better maintainability and readability.

@kingpinXD kingpinXD requested a review from a team as a code owner June 16, 2025 22:27
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 16, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

The changes refine the app state export and zero-height genesis preparation logic by standardizing context initialization, address handling, and error management. Additionally, simulation tests are updated to skip a specific key prefix during state comparison, acknowledging a known issue with cross-chain counter indices.

Changes

File(s) Change Summary
app/export.go Refined context creation, standardized address conversion using codec methods, improved error handling, reordered checks, updated hooks, and adjusted handling of store keys and iterator errors in state export and zero-height genesis logic.
simulation/simulation_test.go Added crosschaintypes.CounterIndexKey to the skip list during store comparison in import/export tests, with clarifying comments.

Sequence Diagram(s)

sequenceDiagram
    participant Exporter as ExportAppStateAndValidators
    participant Context as Context
    participant Keeper as Various Keepers
    participant Logger as Logger

    Exporter->>Context: NewContextLegacy(true, Header{Height: LastBlockHeight()})
    Exporter->>Keeper: Retrieve validators, delegations, rewards, etc.
    loop For each validator/delegation
        Exporter->>Keeper: Convert addresses using ValidatorAddressCodec
        Exporter->>Keeper: Withdraw commissions/rewards (ignore errors)
        Exporter->>Keeper: Donate outstanding rewards to community pool (log errors)
        Exporter->>Keeper: Set validator signing info (panic on error)
    end
    Exporter->>Logger: Log errors or fatal on critical errors
    Exporter->>Context: Return exported app state and validators
Loading
sequenceDiagram
    participant Test as TestAppImportExport
    participant Store as StoreComparer

    Test->>Store: Compare original and imported app states
    Store->>Store: Skip keys: ...CounterIndexKey for crosschaintypes.StoreKey
    Store->>Test: Report differences (excluding skipped keys)
Loading

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

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

🧹 Nitpick comments (1)
simulation/simulation_test.go (1)

417-422: Skipping the counter-index key hides real divergence – add a follow-up guard.

Adding crosschaintypes.CounterIndexKey to the skip list unblocks the test, but it also means any future regression on that key will silently pass.
Consider wrapping the skip behind a helper that fails once #3979 is closed, or add a TODO with an assert that re-enables the comparison when the refactor lands.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f26ceaa and 9472c71.

📒 Files selected for processing (2)
  • app/export.go (10 hunks)
  • simulation/simulation_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.go`: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

  • simulation/simulation_test.go
  • app/export.go
🧬 Code Graph Analysis (1)
simulation/simulation_test.go (2)
x/crosschain/types/keys.go (2)
  • KeyPrefix (37-39)
  • CounterIndexKey (50-50)
x/observer/types/keys.go (1)
  • KeyPrefix (39-41)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: build-zetanode
  • GitHub Check: build-and-test
  • GitHub Check: lint
  • GitHub Check: gosec
  • GitHub Check: build
  • GitHub Check: analyze (go)
🔇 Additional comments (1)
app/export.go (1)

184-186: ```shell
#!/bin/bash

Display unbonding delegation snippet and redelegation snippet for comparison

echo "=== Unbonding Delegation Entries ==="
rg -C3 "ubd.Entries" -n app/export.go || true

echo ""
echo "=== Redelegation Entries ==="
rg -C3 "red.Entries" -n app/export.go || true


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@codecov
Copy link

codecov bot commented Jun 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.74%. Comparing base (f26ceaa) to head (4274058).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3983   +/-   ##
========================================
  Coverage    64.74%   64.74%           
========================================
  Files          474      474           
  Lines        34809    34809           
========================================
  Hits         22536    22536           
  Misses       11223    11223           
  Partials      1050     1050           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kingpinXD kingpinXD requested a review from a team as a code owner June 16, 2025 22:45
@github-actions github-actions bot added the ci Changes to CI pipeline or github actions label Jun 16, 2025
@kingpinXD kingpinXD enabled auto-merge June 17, 2025 15:26
@kingpinXD kingpinXD added this pull request to the merge queue Jun 17, 2025
Merged via the queue into develop with commit 1c26283 Jun 17, 2025
47 checks passed
@kingpinXD kingpinXD deleted the fix-sim branch June 17, 2025 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Changes to CI pipeline or github actions SIM_TESTS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zetacore : Simulation tests throws an error `calculated final stake for delegator greater than current stake.

4 participants