From 850c5b2b58f30d90ee4f11c2103d439de56f8da6 Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Wed, 14 Feb 2024 09:57:29 +0100 Subject: [PATCH] Remove ALL keychain random bytes refs, update CI, try running tarpaulin without nightly. --- .github/workflows/test.yml | 8 ++++---- tests/uniffi/bindings/test_bag_of_bytes.swift | 8 ++++---- tests/uniffi/bindings/test_hex32_bytes.swift | 20 +++++++++++-------- .../test_radix_connect_password.swift | 20 +++++++++++-------- tests/uniffi/bindings/test_wallet.swift | 20 +++++++++++-------- 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebf697a8f..e04debf96 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -91,13 +91,13 @@ jobs: - uses: radixdlt/public-iac-resuable-artifacts/fetch-secrets@main with: role_name: ${{ secrets.AWS_ROLE_NAME_SECRET }} - app_name: 'sargon' - step_name: 'codecoverage' - secret_prefix: 'CODECOV' + app_name: "sargon" + step_name: "codecoverage" + secret_prefix: "CODECOV" secret_name: ${{ secrets.AWS_SECRET_NAME_CODECOV }} parse_json: true - name: Generate code coverage - run: cargo +nightly tarpaulin + run: cargo tarpaulin - name: Upload to codecov.io uses: RDXWorks-actions/codecov-action@main with: diff --git a/tests/uniffi/bindings/test_bag_of_bytes.swift b/tests/uniffi/bindings/test_bag_of_bytes.swift index 57da5418e..422814557 100644 --- a/tests/uniffi/bindings/test_bag_of_bytes.swift +++ b/tests/uniffi/bindings/test_bag_of_bytes.swift @@ -62,7 +62,7 @@ extension Data { } } -func randomByteArray(byteCount count: Int) throws -> [UInt8] { +func randomByteArray(byteCount count: Int) -> [UInt8] { #if canImport(Darwin) || os(Linux) || os(Android) || os(Windows) var rng = SystemRandomNumberGenerator() return (0.. [UInt8] { } extension Data { - public static func random(byteCount: Int) throws -> Self { - Data(randomBytesArray(byteCount: byteCount)) + public static func random(byteCount: Int) -> Self { + Data(randomByteArray(byteCount: byteCount)) } } @@ -160,7 +160,7 @@ func test() throws { let s = Set( (0.. [UInt8] { + #if canImport(Darwin) || os(Linux) || os(Android) || os(Windows) + var rng = SystemRandomNumberGenerator() + return (0.. Self { - var bytes = [UInt8](repeating: 0, count: byteCount) - let status = SecRandomCopyBytes(kSecRandomDefault, byteCount, &bytes) - if status == errSecSuccess { - return Self(bytes) - } - struct UnableToGenerateBytes: Swift.Error {} - throw UnableToGenerateBytes() + public static func random(byteCount: Int) -> Self { + Data(randomByteArray(byteCount: byteCount)) } } + extension Hex32Bytes { init(data: Data) throws { self = try newHex32BytesFrom(bytes: data) diff --git a/tests/uniffi/bindings/test_radix_connect_password.swift b/tests/uniffi/bindings/test_radix_connect_password.swift index 403b27189..73133162f 100644 --- a/tests/uniffi/bindings/test_radix_connect_password.swift +++ b/tests/uniffi/bindings/test_radix_connect_password.swift @@ -1,17 +1,21 @@ import Sargon import Foundation +func randomByteArray(byteCount count: Int) -> [UInt8] { + #if canImport(Darwin) || os(Linux) || os(Android) || os(Windows) + var rng = SystemRandomNumberGenerator() + return (0.. Self { - var bytes = [UInt8](repeating: 0, count: byteCount) - let status = SecRandomCopyBytes(kSecRandomDefault, byteCount, &bytes) - if status == errSecSuccess { - return Self(bytes) - } - struct UnableToGenerateBytes: Swift.Error {} - throw UnableToGenerateBytes() + public static func random(byteCount: Int) -> Self { + Data(randomByteArray(byteCount: byteCount)) } } + extension RadixConnectPassword { init(bytes: Hex32Bytes) { self = newRadixConnectPassword(bytes: bytes) diff --git a/tests/uniffi/bindings/test_wallet.swift b/tests/uniffi/bindings/test_wallet.swift index d89baac00..617e52f4d 100644 --- a/tests/uniffi/bindings/test_wallet.swift +++ b/tests/uniffi/bindings/test_wallet.swift @@ -139,18 +139,22 @@ extension AppearanceID { static let placeholder: Self = newAppearanceIdPlaceholder() static let placeholderOther: Self = newAppearanceIdPlaceholderOther() } +func randomByteArray(byteCount count: Int) -> [UInt8] { + #if canImport(Darwin) || os(Linux) || os(Android) || os(Windows) + var rng = SystemRandomNumberGenerator() + return (0.. Self { - var bytes = [UInt8](repeating: 0, count: byteCount) - let status = SecRandomCopyBytes(kSecRandomDefault, byteCount, &bytes) - if status == errSecSuccess { - return Self(bytes) - } - struct UnableToGenerateBytes: Swift.Error {} - throw UnableToGenerateBytes() + public static func random(byteCount: Int) -> Self { + Data(randomByteArray(byteCount: byteCount)) } } + extension Wallet { public static let defaultIphoneName: String = "iPhone"