-
Notifications
You must be signed in to change notification settings - Fork 58
feat(swift-sdk): expose watermark-freeze sync fault flag (syncFaultDetected) #4320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
45 changes: 45 additions & 0 deletions
45
packages/swift-sdk/SwiftTests/SwiftDashSDKTests/SyncFaultDetectedTests.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // SyncFaultDetectedTests.swift | ||
| // SwiftDashSDKTests | ||
| // | ||
| // Unit tests for the `PlatformWalletManager.syncFaultDetected()` FFI bridge. | ||
|
|
||
| import XCTest | ||
| @testable import SwiftDashSDK | ||
|
|
||
| /// Coverage for the Swift side of the watermark-freeze fault latch | ||
| /// (dashpay/platform#4069), exported over the C ABI by PR #4314 as | ||
| /// `platform_wallet_manager_sync_fault_detected`. | ||
| /// | ||
| /// `syncFaultDetected()` is a pure bridge: guard the handle, call the export, | ||
| /// return the out-param. The latch's actual semantics — the persisted | ||
| /// `syncedHeight` being deliberately held behind the chain tip after the | ||
| /// wallet-event adapter drops record-bearing events or a persistence `store()` | ||
| /// is rejected, and the flag latching `true` for the process lifetime — live in | ||
| /// Rust and are covered by the shared tests in | ||
| /// `packages/rs-platform-wallet/src/changeset/core_bridge.rs`. What is Swift's | ||
| /// to get right is the unconfigured-handle guard, which must throw rather than | ||
| /// hand `NULL_HANDLE` across the FFI boundary. | ||
| /// | ||
| /// `PlatformWalletManager` is main-actor isolated, so the suite runs on the | ||
| /// main actor. | ||
| @MainActor | ||
| final class SyncFaultDetectedTests: XCTestCase { | ||
|
|
||
| /// A bare `PlatformWalletManager()` has never been configured: `handle` is | ||
| /// `NULL_HANDLE` and `isConfigured` is false, so the wrapper must throw | ||
| /// `PlatformWalletError.invalidHandle` instead of calling the export with | ||
| /// a null handle. | ||
| func testSyncFaultDetectedRequiresConfiguredManager() { | ||
| let manager = PlatformWalletManager() | ||
| XCTAssertFalse(manager.isConfigured, "a bare manager is unconfigured") | ||
|
|
||
| XCTAssertThrowsError(try manager.syncFaultDetected()) { error in | ||
| XCTAssertTrue(error is PlatformWalletError) | ||
| if case PlatformWalletError.invalidHandle = error { | ||
| // Expected error | ||
| } else { | ||
| XCTFail("Expected invalidHandle error, got \(error)") | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.