Skip to content

Improve Error Handling in GenerateAccountsWithKeyrings Function#2746

Open
nagarajdivine wants to merge 1 commit into
mainfrom
improvements/keyring-helper
Open

Improve Error Handling in GenerateAccountsWithKeyrings Function#2746
nagarajdivine wants to merge 1 commit into
mainfrom
improvements/keyring-helper

Conversation

@nagarajdivine

@nagarajdivine nagarajdivine commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Description


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 relevant changelog entries under .changelog/unreleased (see Adding Changes).
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

Summary by CodeRabbit

  • Improvements

    • Enhanced error handling in account keyring generation functionality.
  • Tests

    • Updated test infrastructure for keyring setup across multiple modules.

@nagarajdivine nagarajdivine requested a review from a team as a code owner June 2, 2026 15:54
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Four integration test suites and a changelog were updated to refactor keyring initialization. Previously, a single GenerateTestKeyring call created both the keyring and test account entries. Now, NewTestKeyring creates the keyring, then GenerateTestAccountsInKeyring populates it separately, enabling improved error handling at each step.

Changes

Keyring Helper Refactoring

Layer / File(s) Summary
Split keyring and account generation across test suites
.changelog/unreleased/improvements/1970-keyring-helper.md, x/ibcratelimit/client/cli/cli_test.go, x/marker/client/cli/cli_test.go, x/metadata/client/cli/cli_test.go, x/trigger/client/cli/cli_test.go
Each test suite's GenerateAccountsWithKeyrings method now creates the keyring explicitly via testutil.NewTestKeyring, then generates test accounts via testutil.GenerateTestAccountsInKeyring, replacing the prior combined call. The changelog documents this improved error-handling approach.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Four test suites dance in line,
Splitting keyrings, oh so fine!
Two steps now where one before,
Error handling at each door—
Better tests for forevermore! 🔑✨

🚥 Pre-merge checks | ✅ 1 | ❌ 4

❌ Failed checks (4 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title refers to improving error handling in GenerateAccountsWithKeyrings, but the actual changes refactor the function by splitting a single call into two separate calls without implementing error handling tests. Either update the PR title to reflect the actual refactoring changes (e.g., 'Refactor GenerateAccountsWithKeyrings to use separate keyring creation and account generation calls'), or implement error handling tests as described in the linked issue #1970.
Linked Issues check ⚠️ Warning The PR does not fulfill the primary requirement from issue #1970: implementing tests that simulate keyring creation or mnemonic generation failures to verify error handling. Add tests that explicitly simulate failure scenarios (keyring creation failures, mnemonic generation failures) in GenerateAccountsWithKeyrings and verify proper error handling.
Out of Scope Changes check ⚠️ Warning The refactoring of GenerateAccountsWithKeyrings across multiple test files (ibcratelimit, marker, metadata, trigger) appears to be structural cleanup rather than the error handling improvements described in issue #1970. Clarify whether the two-step keyring creation refactoring is preparatory work for error handling tests, or implement the error handling tests as the primary objective of this PR.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improvements/keyring-helper

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@x/ibcratelimit/client/cli/cli_test.go`:
- Around line 109-111: The helper GenerateAccountsWithKeyrings currently calls
testutil.NewTestKeyring and testutil.GenerateTestAccountsInKeyring which call
require.NoError internally and thus abort tests instead of returning errors;
change GenerateAccountsWithKeyrings to use error-returning variants (or accept
injectable factory functions) so keyring creation and account generation return
errors to the caller (e.g., make GenerateAccountsWithKeyrings return error and
propagate errors from testutil.NewTestKeyring and
testutil.GenerateTestAccountsInKeyring), allowing the test suite to choose
require.NoError or assert on failure paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d854266a-e524-4a7e-9b61-0e3ede2c0ddf

📥 Commits

Reviewing files that changed from the base of the PR and between 63ceab7 and 761e18e.

📒 Files selected for processing (5)
  • .changelog/unreleased/improvements/1970-keyring-helper.md
  • x/ibcratelimit/client/cli/cli_test.go
  • x/marker/client/cli/cli_test.go
  • x/metadata/client/cli/cli_test.go
  • x/trigger/client/cli/cli_test.go

Comment thread x/ibcratelimit/client/cli/cli_test.go
Comment on lines -110 to +111
s.keyringEntries, s.keyring = testutil.GenerateTestKeyring(s.T(), number, s.cfg.Codec)
s.keyring = testutil.NewTestKeyring(s.T(), s.cfg.Codec)
s.keyringEntries = testutil.GenerateTestAccountsInKeyring(s.T(), s.keyring, number)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tldr; I think we can just close the issue as done without doing a PR.

I think the one-liner is better than the split out version.

The ticket was originally about adding some unit tests to the testutil.GenerateTestKeyring func and its related functions, but that's a pain and I don't think it buys us anything. The secondary goal of the issue was to find all the places that do keyring stuff without using testutil.GenerateTestKeyring. I did a quick look through the CLI stuff and all I found was the quarantine module, but since we're getting rid of that, there isn't really anything to do there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can close this PR 👍 , since there's already a PR for removing the quarantine module.

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.

Improve Error Handling in GenerateAccountsWithKeyrings Function

2 participants