Fix: Issue #14 Type 'Bundle' has no member 'module'

Linting changes

Update Swift-Crypto to 2.0.4
This commit is contained in:
Francisco Gindre 2022-01-12 19:22:48 -03:00
parent 1bff2fd15e
commit 746d6a0057
4 changed files with 18 additions and 12 deletions

View File

@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/apple/swift-crypto.git",
"state": {
"branch": null,
"revision": "9c53b7a758bb849a7df1bd2314395f5f0c14306f",
"version": "2.0.3"
"revision": "a8911e0fadc25aef1071d582355bd1037a176060",
"version": "2.0.4"
}
}
]

View File

@ -6,13 +6,13 @@ import Foundation
public extension UInt8 {
func mnemonicBits() -> [String] {
let totalBitsCount = MemoryLayout<UInt8>.size * 8
var bitsArray = [String](repeating: "0", count: totalBitsCount)
for j in 0 ..< totalBitsCount {
let bitVal: UInt8 = 1 << UInt8(totalBitsCount - 1 - j)
let check = self & bitVal
if check != 0 {
bitsArray[j] = "1"
}

View File

@ -152,14 +152,14 @@ public enum Mnemonic {
guard strength % 32 == 0 else {
throw MnemonicError.invalidInput
}
let count = strength / 8
var bytes = [UInt8](repeating: 0, count: count)
guard SecRandomCopyBytes(kSecRandomDefault, count, &bytes) == errSecSuccess else {
throw MnemonicError.entropyCreationFailed
}
return try mnemonicString(from: bytes.hexString, language: language)
}

View File

@ -23,7 +23,7 @@ class MnemonicSwiftTests: XCTestCase {
XCTFail("Failed to parse input file.")
return
}
for testCase in testCases {
let expectedMnemonicString = testCase[mnenomicStringIndex]
let hexRepresentation = testCase[hexRepresentationIndex]
@ -40,7 +40,7 @@ class MnemonicSwiftTests: XCTestCase {
XCTFail("Failed to parse input file.")
return
}
for testCase in testCases {
let mnemonicString = testCase[mnenomicStringIndex]
let expectedDeterministicSeedString = testCase[deterministicSeedStringIndex]
@ -53,9 +53,15 @@ class MnemonicSwiftTests: XCTestCase {
}
static func dictionaryFromTestInputFile() -> [String: Any]? {
#if SWIFT_PACKAGE
guard let url = Bundle.module.url(forResource: "vectors", withExtension: "json") else {
return nil
}
#else
guard let url = Bundle(for: MnemonicSwiftTests.self).url(forResource: "vectors", withExtension: "json") else {
return nil
}
#endif
do {
let data = try Data(contentsOf: url)
@ -87,7 +93,7 @@ class MnemonicSwiftTests: XCTestCase {
XCTAssertNoThrow(try {
XCTAssertEqual(try Mnemonic.generateMnemonic(strength: 32).components(separatedBy: " ").count, 3)
}())
XCTAssertNoThrow(try {
XCTAssertEqual(try Mnemonic.generateMnemonic(strength: 64).components(separatedBy: " ").count, 6)
}())
@ -234,7 +240,7 @@ class MnemonicSwiftTests: XCTestCase {
XCTAssertNoThrow(try Mnemonic.deterministicSeedBytes(from: x))
XCTAssertThrowsError(try Mnemonic.deterministicSeedBytes(from: y))
XCTAssertEqual(
try Mnemonic.deterministicSeedBytes(from: x),
try Mnemonic.deterministicSeedBytes(from: " " + x)