-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathExtendedKeyTests.swift
27 lines (23 loc) · 999 Bytes
/
ExtendedKeyTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import Foundation
import XCTest
@testable import BIP32
final class ExtendedKeyTests: XCTestCase {
private func sut(serializedKey: SerializedKeyable, accessControl: KeyAccessControl) -> ExtendedKey {
.init(serializedKey: serializedKey, accessControl: accessControl)
}
func testGivenSerializedKey_WithPrivateAccessControl_WhenInit_AndCountKeyBytes_ThenEqual32() throws {
let sut = try self.sut(serializedKey: serializedKey(), accessControl: .`private`)
XCTAssertEqual(sut.key.count, 32)
}
func testGivenSerializedKey_WithPublicAccessControl_WhenInit_AndCountKeyBytes_ThenEqual33() throws {
let sut = try self.sut(serializedKey: serializedKey(), accessControl: .`public`)
XCTAssertEqual(sut.key.count, 33)
}
}
// MARK: - Helpers
fileprivate extension ExtendedKeyTests {
func serializedKey() throws -> SerializedKey {
let data = Data(hex: SerializedKeyTestVector.hexEncodedKey)
return try .init(data: data)
}
}