Skip to content

test: stabilize contact and Paykit unit tests - #1375

Merged
ovitrif merged 1 commit into
masterfrom
codex/ios-stabilize-unit-tests
Nov 19, 2026
Merged

ovitrif merged 1 commit into
masterfrom
codex/ios-stabilize-unit-tests

Conversation

@piotr-iohk

Copy link
Copy Markdown
Collaborator

This PR stabilizes two iOS unit tests that failed intermittently on PR #1370.

Description

  • Hosts the contact preview in the active simulator scene and waits until SwiftUI has handled the stubbed endpoint error before checking that Alice and Save remain visible and Pay stays hidden. The original test timed out waiting for the stub to start. CI attempt 1
  • Waits for the Paykit intake, optional ordered barrier, and payment mutation to join the real lock queue before releasing the active operation. The original test observed active → intake → payment where it expected active → payment → intake. CI attempt 2

Design

N/A. Test stabilization only.

Preview

N/A.

QA Notes

Setup

Run the Bitkit scheme on the iPhone 17 simulator with the exclusions in .github/workflows/unit-tests.yml. The affected tests use stubbed SDK and endpoint calls.

Journeys

N/A. The change adds no user-visible behavior.

Manual Tests

N/A.

Automated Checks

  • updated AddContactViewTests.swift — checks the rendered contact preview after the view handles an endpoint error and preserves coverage for the pending lookup and view removal.
  • updated PaykitSdkOperationLockTests.swift — verifies the expected ordering once all operations have joined the queue, including an ordered barrier and ordered proof.
  • ran ten iterations of the three contact-preview tests and the payment-mutation ordering test.

Evidence

  • On c7e6b46, Xcode 26.0.1 and iPhone 17 / iOS 26.0 ran the BitkitTests unit selection with the workflow's integration-test exclusions. XCTest reported 4,133 passed, 5 skipped, and 0 failures.
  • The focused repetitions recorded 40 passed and 0 failures. SwiftFormat 0.64.6 and git diff --check passed.
  • The local Xcode compiler needed an equivalent temporary split of an existing SparkExitSweepTests.swift expression. The file was restored after testing.

Gaps

Hosted validation on the workflow's Xcode 26.6 / iOS 26.5 environment is provided by this PR's CI.

Models used

  • Planning/scoping: gpt-6.2-sol (reasoning: high)
  • Implementation: gpt-6.2-sol (reasoning: high)
  • Review: gpt-6.2-sol (reasoning: high)

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Stabilizes contact-preview and Paykit queue-ordering tests without changing normal app behavior.

  • Contact preview tests wait for the endpoint result before checking the screen.
  • Paykit order tests release work only after callers join the lock queue.

No actionable issues found. iOS tests were not run in this Linux environment.

Reviews (1) · Last reviewed commit: "test: stabilize contact and Paykit unit ..." · Reviewed by Greptile

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

No findings. Replaces fixed sleeps in two flaky unit tests with completion signals: a test-only completion callback on AddContactView's endpoint lookup, and waits on PaykitSdkOperationLock.waiterCountForTesting through an injected lock in PaykitSdkService. Reviewed c7e6b46, full tier, static.

What I checked, and 4 candidates I ruled out

Build skipped: iOS does not build on Linux, so this review is reasoned from the code and CI; the unit-test job was still pending when it was written.

Read in full: AddContactViewTests.swift, the withLock/acquire*/release paths of PaykitSdkOperationLock, PaykitSdkService.init and withSdk, the AddContactView endpoint task.

Call sites traced: PaykitSdkService( (the shared instance and every test construction use the default lock, so production behaviour is unchanged); AddContactView( (MainNavView.swift:608 and the preview pass no callback).

Ruled out

  • Waiter count reached by something other than the queued operation: receivePrivateMessagesFromLinkedPeers(priority:), the payment mutations and contactRecords all reach operationLock.withLock(priority:) through withSdk, and only those tasks run against the fresh lock, so counts 1/2/3 map one-to-one onto intake, barrier and payment joining the queue, which is the ordering the assertion depends on.
  • Callback firing before the failure state renders: hasPayableEndpoint is set before the callback, and renderedLabels draws with afterScreenUpdates: true, so the snapshot sees the post-lookup state.
  • Callback never firing on the failure path: try? maps the thrown error to false, so the throwing stub still reaches the callback; it is skipped only when the task is cancelled or the profile changed, which should fail the test.
  • Scene-hosted window leaking key status: same pattern as ProfileDestinationViewTests and PaykitPaymentRequestServiceTests, with the previous key window restored in teardown.

Merge confidence: 4/5, no findings, but the unit-test job had not finished when I reviewed and I could not run the suite here.

Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the run metadata available to this reviewer does not report it)

@piotr-iohk

Copy link
Copy Markdown
Collaborator Author

CI is green on c7e6b46. The hosted unit run passed both repaired tests. Please review and leave the PR open after approval.

@piotr-iohk
piotr-iohk requested review from a team, ben-kaufman and ovitrif and removed request for a team November 19, 2026 16:11

@ovi-reviewer ovi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: ✅ Approve

Findings: None.

QA for c7e6b46:

Run the unit workflow selection ✅ The unchanged head built and both test targets passed with no failures.

Built with Xcode 27.0 and ran on an iPhone 17 Pro simulator with iOS 27.0, using the integration-test exclusions in unit-tests.yml. The XCTest result bundle confirms the unit and UI test results, including the contact-preview tests and payment-ordering test. Existing optional Spark regtest, USDT recovery, wake gateway, Trezor emulator and Arbitrum fork tests skipped because their opt-in prerequisites were absent.

suite-2x.small.mp4

Automated suite at 2× speed; outcomes checked in XCTest results.

Repeat contact preview and payment queue ordering ✅ The focused methods passed all ten iterations without failures or skips.

Relaunched the test host between iterations. The retained XCTest assertions checked the rendered preview while lookup is pending, after success and after failure; cancellation when leaving the preview; and payment priority with and without an ordered barrier, including ordered proof submission.

focused-2x.2x.mp4

Focused repetitions at 2× speed; rendering and queue order checked by the test assertions.

No manual journeys were listed or run: this change adds no user-visible behavior. The optional fixture skips do not cover the changed paths. SwiftFormat 0.64.6 on the changed files and git diff --check passed. The hosted unit run also passed at this head.

Full review of 602cd0e..c7e6b46, covering all four changed files, callers, endpoint cancellation, lock ordering and test isolation. The earlier static review also found no issues.

Android twin: none linked or found; the changes concern SwiftUI test hosting and the iOS SDK-operation queue tests.


Reviewed by gpt-6.1-sol-high

@ovitrif ovitrif left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

utAck

@ovitrif

ovitrif commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

@piotr-iohk Merged, as it was approved and green.

@ovitrif
ovitrif merged commit e65c447 into master Nov 19, 2026
22 checks passed
@ovitrif
ovitrif deleted the codex/ios-stabilize-unit-tests branch November 19, 2026 17:14
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.

3 participants