From 432b1e996139d4e53d6787ed12f15753add0bb10 Mon Sep 17 00:00:00 2001 From: PastaClaw Date: Sat, 21 Feb 2026 15:27:54 -0600 Subject: [PATCH 1/2] test(swift-sdk): remove scaffold tests and fix tautological assertions - Remove scaffold test files: CrashDebugTests, DebugTests, MinimalAsyncTest - Remove testSimpleAsync from StateTransitionTests (scaffold) - Remove testTransactionBuilderAddOutput and testTransactionBuilderChangeAddress (properties not accessible through public API, tests were tautological) - Replace XCTAssertTrue(true) with proper assertions throughout - Fix SDKMethodTests to XCTFail on unexpected success - Fix SDKTests version check: use semver regex instead of hardcoded '2.0.0' - Add missing swift_dash_string_free calls in SDKTests --- .../CrashDebugTests.swift | 121 ----------------- .../SwiftExampleAppTests/DebugTests.swift | 122 ------------------ .../MinimalAsyncTest.swift | 36 ------ .../SwiftExampleAppTests/SDKMethodTests.swift | 8 +- .../StateTransitionTests.swift | 8 -- .../WalletTests/TransactionTests.swift | 13 -- .../SwiftDashSDKTests/DataContractTests.swift | 3 - .../SwiftDashSDKTests/IdentityTests.swift | 6 +- .../MemoryManagementTests.swift | 18 --- .../Tests/SwiftDashSDKTests/SDKTests.swift | 17 ++- 10 files changed, 15 insertions(+), 337 deletions(-) delete mode 100644 packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/CrashDebugTests.swift delete mode 100644 packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/DebugTests.swift delete mode 100644 packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/MinimalAsyncTest.swift diff --git a/packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/CrashDebugTests.swift b/packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/CrashDebugTests.swift deleted file mode 100644 index 7961dacbf73..00000000000 --- a/packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/CrashDebugTests.swift +++ /dev/null @@ -1,121 +0,0 @@ -import DashSDKFFI -import SwiftDashSDK -import XCTest - -@testable import SwiftExampleApp - -final class CrashDebugTests: XCTestCase { - - func testCatchCrash() async throws { - print("=== Starting crash debug test ===") - - // Install exception handler (without capturing context) - let handler = NSGetUncaughtExceptionHandler() - NSSetUncaughtExceptionHandler { exception in - print("!!! Caught exception: \(exception)") - print("!!! Reason: \(exception.reason ?? "unknown")") - print("!!! User info: \(exception.userInfo ?? [:])") - print("!!! Call stack: \(exception.callStackSymbols)") - } - - defer { - NSSetUncaughtExceptionHandler(handler) - } - - // Try the problematic code - do { - print("Initializing SDK...") - SDK.initialize() - - print("Creating SDK instance...") - let sdk = try SDK(network: DashSDKNetwork(rawValue: 1)) - - print("SDK created, checking methods...") - - // Try to call the method with minimal setup - _ = "test" // fromId - let toId = "test2" - let amount: UInt64 = 1 - let key = Data(repeating: 0, count: 32) - - print("Creating identity and signer...") - - // Create a dummy identity - let identity = DPPIdentity( - id: Data(repeating: 0, count: 32), - publicKeys: [:], - balance: 0, - revision: 0 - ) - - // Create signer from private key - let signerResult = key.withUnsafeBytes { keyBytes in - dash_sdk_signer_create_from_private_key( - keyBytes.bindMemory(to: UInt8.self).baseAddress!, - UInt(key.count) - ) - } - - guard signerResult.error == nil, - let signer = signerResult.data - else { - print("Failed to create signer") - return - } - - defer { - dash_sdk_signer_destroy(signer.assumingMemoryBound(to: SignerHandle.self)) - } - - print("Calling transferCredits...") - _ = try await sdk.transferCredits( - from: identity, - toIdentityId: toId, - amount: amount, - signer: OpaquePointer(signer) - ) - - print("Method call completed") - } catch { - print("Caught error: \(error)") - print("Error type: \(type(of: error))") - print("Error localized: \(error.localizedDescription)") - - let nsError = error as NSError - print("NSError domain: \(nsError.domain)") - print("NSError code: \(nsError.code)") - print("NSError userInfo: \(nsError.userInfo)") - } - - print("=== Crash debug test completed ===") - } - - func testMethodExistence() { - print("=== Testing method existence ===") - - // Check if the SDK has the method we're trying to call - let sdkClass: AnyClass? = NSClassFromString("SwiftDashSDK.SDK") - print("SDK class: \(String(describing: sdkClass))") - - if let cls = sdkClass { - // List all methods - var methodCount: UInt32 = 0 - let methods = class_copyMethodList(cls, &methodCount) - - print("Found \(methodCount) methods in SDK class:") - if let methods = methods { - for i in 0.. Date: Mon, 23 Feb 2026 20:56:13 -0600 Subject: [PATCH 2/2] docs(swift-sdk): clarify SwiftDashSDKMock.c usage in tests --- .../SwiftTests/Sources/SwiftDashSDKMock/SwiftDashSDKMock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/swift-sdk/SwiftTests/Sources/SwiftDashSDKMock/SwiftDashSDKMock.c b/packages/swift-sdk/SwiftTests/Sources/SwiftDashSDKMock/SwiftDashSDKMock.c index 7594688a537..aac1efa5efc 100644 --- a/packages/swift-sdk/SwiftTests/Sources/SwiftDashSDKMock/SwiftDashSDKMock.c +++ b/packages/swift-sdk/SwiftTests/Sources/SwiftDashSDKMock/SwiftDashSDKMock.c @@ -1,5 +1,5 @@ -// Mock implementation of Swift Dash SDK for testing -// This provides mock implementations of all the C functions +// Test-only C mock implementation of SwiftDashSDK FFI, linked by SwiftTests/Package.swift target `SwiftDashSDKMock`. +// Used by SwiftTests unit tests to exercise Swift wrapper behavior without depending on a real Rust backend. #include "SwiftDashSDK.h" #include