Skip to content

Conversation

Snezhkko
Copy link

@Snezhkko Snezhkko commented Aug 25, 2025

Fix logical inconsistency in TestSlashingMsgs where validator signing info
was being queried for the wrong address.

The test creates a validator using addr1 and valKey, but then attempts
to get signing info for valAddr (which is derived from valKey but not
the same as the created validator's address). This creates a mismatch
between the validator being tested and the address being queried.

Changed GetValidatorSigningInfo call from sdk.ConsAddress(valAddr) to
sdk.ConsAddress(valKey.PubKey().Address()) to ensure the signing info
is queried for the correct validator that was actually created in the test.

Summary by CodeRabbit

  • Tests
    • Updated slashing-related tests to use the validator’s consensus address when validating signing info, improving accuracy and preventing false positives/negatives.
    • Enhances test reliability in CI and better safeguards against regressions.
    • No user-facing changes; runtime behavior and public APIs remain unchanged.

Copy link
Contributor

coderabbitai bot commented Aug 25, 2025

📝 Walkthrough

Walkthrough

Updated x/slashing/app_test.go: TestSlashingMsgs now queries validator signing info using the consensus address derived from the validator’s public key instead of the account address. No other logic or public APIs changed.

Changes

Cohort / File(s) Summary
Slashing tests
x/slashing/app_test.go
In TestSlashingMsgs, replaced GetValidatorSigningInfo query key from account address to consensus address (valKey.PubKey().Address()).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

CodeRabbit Configuration 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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: 0

🧹 Nitpick comments (4)
x/slashing/app_test.go (4)

110-110: Fix misleading comment: it’s “not jailed,” not “unknown validator.”

The validator exists; the expected error is ErrValidatorNotJailed, so the comment should reflect that.

Apply this diff:

- // unjail should fail with unknown validator
+ // unjail should fail because the validator is not jailed

106-106: Optional: Use a consistent context constructor.

You’ve used both baseApp.NewContext(true) and app.NewContext(true) in this test. They’re equivalent here; consider standardizing on one for readability.

- ctxCheck = app.NewContext(true)
+ ctxCheck = baseApp.NewContext(true)

78-78: Redundant require.NoError(t, err) check.

This re-checks the same err from Line 71 without any new assignment. Safe to remove.

- require.NoError(t, err)

33-35: Drop the unused valAddr declaration in x/slashing/app_test.go
We ran

rg -nP '\bvalAddr\b' -C2 --type=go x/slashing/app_test.go

and confirmed the only occurrence is the assignment on line 34; removing it leaves no references and silences linter warnings.

Apply this diff:

 var (
   priv1 = secp256k1.GenPrivKey()
   addr1 = sdk.AccAddress(priv1.PubKey().Address())

-  valKey  = ed25519.GenPrivKey()
-  valAddr = sdk.AccAddress(valKey.PubKey().Address())
+  valKey = ed25519.GenPrivKey()
 )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 79fcc30 and af2057b.

📒 Files selected for processing (1)
  • x/slashing/app_test.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Summary
🔇 Additional comments (1)
x/slashing/app_test.go (1)

107-108: Correctly targeting the validator’s consensus address for signing info.

Switching to sdk.ConsAddress(valKey.PubKey().Address()) ensures the query matches the validator created with valKey in MsgCreateValidator. This aligns the slashing lookup with the actual consensus key under test. LGTM.

@Snezhkko
Copy link
Author

Snezhkko commented Sep 3, 2025

lint fixeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants