Attempt to fix AssertionError "ms is denormalized" in QueryPurchasesUseCaseTest#3361
Merged
Conversation
mockk's JvmSignatureValueGenerator fails to construct kotlin.time.Duration via reflection when setting up any() matchers, because Kotlin 2.0's Duration constructor-impl validates the raw Long and throws for denormalized values. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📸 Snapshot Test588 unchanged
🛸 Powered by Emerge Tools |
AssertionError "ms is denormalized" in QueryPurchasesUseCaseTest
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3361 +/- ##
=======================================
Coverage 79.36% 79.36%
=======================================
Files 354 354
Lines 14259 14259
Branches 1951 1951
=======================================
Hits 11316 11316
Misses 2140 2140
Partials 803 803 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tonidero
approved these changes
Apr 20, 2026
tonidero
left a comment
Contributor
There was a problem hiding this comment.
Hmm interesting... I haven't seen this issue before, but I think these changes should indeed not hurt.
Member
Author
|
Yeah, it's weird. I've seen it more than once for sure and a rerun fixes it. I think it's probably mockk related or JVM related. Will merge and keep an eye out to see if I see it again |
matteinn
pushed a commit
to matteinn/purchases-android
that referenced
this pull request
Apr 28, 2026
**This is an automatic release.** ## RevenueCat SDK ### 🐞 Bugfixes * fix: move Google BillingClient connection off the main thread (RevenueCat#3369) via Toni Rico (@tonidero) * [EXTERNAL] fix(google): guard showInAppMessages against BillingClient runtime crashes (RevenueCat#3367) by @matteinn (RevenueCat#3368) via Monika Mateska (@MonikaMateska) ## RevenueCatUI SDK ### Paywallv2 #### 🐞 Bugfixes * Add Workflows network layer (RevenueCat#3300) via Cesar de la Vega (@vegaro) ### 🔄 Other Changes * Fix `revenuecat.useWorkflowsEndpoint` compiler flag (RevenueCat#3374) via Cesar de la Vega (@vegaro) * Create paywall from workflow response. Add `USE_WORKFLOWS_ENDPOINT` BuildConfig (RevenueCat#3350) via Cesar de la Vega (@vegaro) * Refactor: Remove unnecessary lint suppressions (RevenueCat#3373) via cursor[bot] (@cursor[bot]) * Bump fastlane-plugin-revenuecat_internal from `a1eed48` to `b822f01` (RevenueCat#3371) via dependabot[bot] (@dependabot[bot]) * Bump fastlane from 2.232.2 to 2.233.0 (RevenueCat#3370) via dependabot[bot] (@dependabot[bot]) * Attempt to fix `AssertionError` "ms is denormalized" in `QueryPurchasesUseCaseTest` (RevenueCat#3361) via Cesar de la Vega (@vegaro) * Update baseline profiles (RevenueCat#3296) via Jaewoong Eum (@skydoves) * fix: reduce precision for flaky HeaderDirectHeroImage snapshot (RevenueCat#3362) via Cesar de la Vega (@vegaro) * Fix test failures reported twice (RevenueCat#3360) via Cesar de la Vega (@vegaro) * refactor: extract `updateStateFromOffering` in `PaywallViewModel` (RevenueCat#3359) via Cesar de la Vega (@vegaro) * [Fix] Include parent tabs component_name in tab-control switch interaction events (RevenueCat#3358) via Monika Mateska (@MonikaMateska) * Refactor: Remove unnecessary lint suppressions (RevenueCat#3348) via cursor[bot] (@cursor[bot]) * fix: always upload CI test results even when tests fail (RevenueCat#3357) via Cesar de la Vega (@vegaro) * refactor: extract `RevenueCatDialogScaffold` (RevenueCat#3355) via Cesar de la Vega (@vegaro) * Fix Slack notifications for nightly integration tests (RevenueCat#3354) via Toni Rico (@tonidero) * UI events for paywall component interactions (RevenueCat#3287) via Monika Mateska (@MonikaMateska) * Bump fastlane-plugin-revenuecat_internal from `20911d1` to `a1eed48` (RevenueCat#3351) via dependabot[bot] (@dependabot[bot]) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Primarily a version bump and release automation updates (docs deploy/redirect and changelog); no functional library code changes beyond updating embedded version constants. > > **Overview** > Cuts the `10.2.1` release by updating version references across the repo (Gradle `VERSION_NAME`, internal `frameworkVersion`, sample/test app dependency pins, and `.version`). > > Updates the docs release pipeline and website redirect to publish and point at `10.2.1`, and refreshes `CHANGELOG.md`/`CHANGELOG.latest.md` with the 10.2.1 release notes. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a0a325b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This is an attempt to fix these failures https://app.circleci.com/pipelines/github/RevenueCat/purchases-android/21114/workflows/d18f7377-6a4e-4bab-b3bf-fb5104ae26ec/jobs/181586/tests#failed-test-0
Claude suggests it's an issue in mockk's
JvmSignatureValueGeneratorwhich fails to constructkotlin.time.Durationvia reflection when recordingany()matchers inevery { }blocks. Kotlin 2.0'sDuration.constructor-implvalidates the rawLongvalue and throwsAssertionError: X ms is denormalizedfor the arbitrary value mockk generates.Description
The attempted fix is to change the three
any()matchers forDurationparameters inBaseBillingUseCaseTest.mockDiagnosticsTracker()to typedany<Duration>(), to give mockk explicit type information.I have seen this crash happen at least 3 more times, and it seems random. The code changes are harmless and hopefully we don't see it again.
Note
Low Risk
Test-only change that only affects how MockK matches
Durationparameters; no production logic or runtime behavior is modified.Overview
Adjusts
BaseBillingUseCaseTest.mockDiagnosticsTracker()to use typed MockK matchers (any<Duration>()) forDiagnosticsTrackercalls that take akotlin.time.Duration, and adds the neededDurationimport.This aims to avoid intermittent test failures caused by MockK attempting to synthesize invalid
Durationvalues when recording untypedany()matchers.Reviewed by Cursor Bugbot for commit 9e03423. Bugbot is set up for automated code reviews on this repo. Configure here.