Skip to content

fix: poll token index after createToken; add integration test retries#1070

Merged
tuliomir merged 3 commits intomasterfrom
fix/service-adapter-poll-token-after-create
Apr 23, 2026
Merged

fix: poll token index after createToken; add integration test retries#1070
tuliomir merged 3 commits intomasterfrom
fix/service-adapter-poll-token-after-create

Conversation

@tuliomir
Copy link
Copy Markdown
Contributor

@tuliomir tuliomir commented Apr 17, 2026

Summary

  • Fix: poll token index after createToken in the service adapter, ensuring the new token is indexed before returning.
  • CI: add jest.retryTimes(2) to integration test setup, retrying flaky test cases up to 2 extra times before failing.

Why the retry on all tests, and not on specific ones?

The flakiness is not on a single test, but on the test infrastructure itself. PRs like #1033 , #1056 , #1058 , #1063 , #1069 and HathorNetwork/rfcs#103 are attempting to fix the underlying issues, but this PR would remove the immediate pain with the constant blocking we're having with the Wallet Lib CI.

Will we lose the failure data?

No, we're not. The failures are still catalogued in the CI output, which was greatly improved by #1049 . We can ask AI agents to look into the CI logs regularly to find more flaky tests, but without the great cost this is imposing on the speed of development on the Wallet Lib.

Acceptance Criteria

  • createToken via service adapter correctly polls the token index before resolving.
  • Flaky integration tests get up to 2 retry attempts, with errors logged on each retry.

Summary by CodeRabbit

  • Tests
    • Enhanced token-creation test to verify an additional post-transaction polling step.
    • Integration test setup now automatically retries failing tests up to two times and logs errors before each retry.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 17, 2026

Warning

Rate limit exceeded

@tuliomir has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 58 minutes and 31 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 58 minutes and 31 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 84438ec1-7181-49bb-abbd-f9e5156c9468

📥 Commits

Reviewing files that changed from the base of the PR and between 94345a5 and f199dec.

📒 Files selected for processing (1)
  • setupTests-integration.js
📝 Walkthrough

Walkthrough

Extended integration test setup and ServiceWalletTestAdapter.createToken() to add an extra post-transaction polling step; added Jest retry configuration for integration tests.

Changes

Cohort / File(s) Summary
Test Adapter Enhancement
__tests__/integration/adapters/service.adapter.ts
createToken() now calls and awaits pollForTokenDetails(sw, response.hash) after pollForTx(sw, response.hash) succeeds; retains existing hash validation and return shape.
Integration Test Setup
setupTests-integration.js
Added jest.retryTimes(2, { logErrorsBeforeRetry: true }) to retry failing integration tests up to two times with error logging before retries.

Sequence Diagram(s)

(omitted — changes are small and do not introduce a multi-component new control flow requiring visualization)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • pedroferreira1
  • raul-oliveira

Poem

🐰 I hopped through tests at break of day,
Polled a hash to guide my way.
Two retries set to catch the mist,
Token details fetched — a joyful twist.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main changes: polling token details after createToken and adding integration test retries.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/service-adapter-poll-token-after-create

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.99%. Comparing base (b43eed5) to head (f199dec).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1070       +/-   ##
===========================================
+ Coverage   66.33%   87.99%   +21.65%     
===========================================
  Files         114      114               
  Lines        8918     8918               
  Branches     2022     2022               
===========================================
+ Hits         5916     7847     +1931     
+ Misses       2975     1044     -1931     
  Partials       27       27               

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The wallet-service has separate indexes for tx visibility and
token/balance data. After createToken, pollForTx only confirms the
tx is visible, but getBalance may still return empty. Adding the
existing pollForTokenDetails call ensures the token index has
caught up before returning.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tuliomir tuliomir force-pushed the fix/service-adapter-poll-token-after-create branch from d155328 to 7687556 Compare April 17, 2026 17:42
@tuliomir tuliomir self-assigned this Apr 17, 2026
@tuliomir tuliomir added bug Something isn't working tests labels Apr 17, 2026
@tuliomir tuliomir moved this from Todo to In Progress (WIP) in Hathor Network Apr 17, 2026
@tuliomir tuliomir changed the title fix: poll token index after createToken in service adapter fix: poll token index after createToken; add integration test retries Apr 20, 2026
Copy link
Copy Markdown

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

🧹 Nitpick comments (1)
setupTests-integration.js (1)

26-27: Reconsider unconditional global retries for stateful integration tests.

Global jest.retryTimes(2) will retry every failed test up to three total attempts, which can mask genuinely flaky operations (wallet starts, token creation, transactions) rather than forcing fixes at their source. The adapter already includes deterministic polling logic for token details (pollForTokenDetails with 20 retries, 2s delays), making test-level retries redundant and potentially hiding intermittent issues in wallet-service indexing or synchronization.

Consider making retries opt-in via environment variable or limiting them to specific flaky test suites, so the polling-based fixes remain the primary signal for addressing race conditions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@setupTests-integration.js` around lines 26 - 27, The global
jest.retryTimes(2) unconditionally retries all tests and can mask real
integration race conditions; change it so retries are opt-in or scoped: replace
the unconditional call to jest.retryTimes in setupTests-integration.js with a
conditional that reads an environment variable (e.g.,
process.env.INTEGRATION_TEST_RETRIES) or remove it here and apply
jest.retryTimes only in specific flaky suites; keep existing deterministic logic
like pollForTokenDetails intact and ensure wallet/transaction integration tests
rely on that polling rather than global retries.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@setupTests-integration.js`:
- Around line 26-27: The global jest.retryTimes(2) unconditionally retries all
tests and can mask real integration race conditions; change it so retries are
opt-in or scoped: replace the unconditional call to jest.retryTimes in
setupTests-integration.js with a conditional that reads an environment variable
(e.g., process.env.INTEGRATION_TEST_RETRIES) or remove it here and apply
jest.retryTimes only in specific flaky suites; keep existing deterministic logic
like pollForTokenDetails intact and ensure wallet/transaction integration tests
rely on that polling rather than global retries.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d827f679-c30d-44f6-b048-b76427afb149

📥 Commits

Reviewing files that changed from the base of the PR and between 7687556 and 94345a5.

📒 Files selected for processing (1)
  • setupTests-integration.js

@tuliomir tuliomir moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Apr 22, 2026
jest.retryTimes(2) retries each failed test case up to
2 extra times before marking it as failed, with error
logging on each retry attempt.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tuliomir tuliomir force-pushed the fix/service-adapter-poll-token-after-create branch from 94345a5 to 3fffceb Compare April 22, 2026 23:25
@tuliomir tuliomir requested a review from raul-oliveira April 23, 2026 14:45
@tuliomir tuliomir enabled auto-merge (squash) April 23, 2026 15:34
Copy link
Copy Markdown
Contributor

@raul-oliveira raul-oliveira left a comment

Choose a reason for hiding this comment

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

Please create an issue for us to revert this retry param when your pullrequests get merged.

@tuliomir tuliomir merged commit 2e5486c into master Apr 23, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress (Done) to Waiting to be deployed in Hathor Network Apr 23, 2026
@pedroferreira1 pedroferreira1 deleted the fix/service-adapter-poll-token-after-create branch April 23, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working tests

Projects

Status: Waiting to be deployed

Development

Successfully merging this pull request may close these issues.

3 participants