diff --git a/tests/uniffi/bindings/test_bag_of_bytes.swift b/tests/uniffi/bindings/test_bag_of_bytes.swift index 204471867..57da5418e 100644 --- a/tests/uniffi/bindings/test_bag_of_bytes.swift +++ b/tests/uniffi/bindings/test_bag_of_bytes.swift @@ -62,15 +62,18 @@ extension Data { } } +func randomByteArray(byteCount count: Int) throws -> [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() + Data(randomBytesArray(byteCount: byteCount)) } }