p2p-swift / Tests / IrdP2PCryptoTests / Vectors.swift
100 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import Foundation
import Testing
@testable import IrdP2PCrypto

/// Loads a golden-vector file from the test bundle.
func vector(_ name: String) throws -> JSONValue {
    let url = try #require(Bundle.module.url(forResource: name, withExtension: "json", subdirectory: "Vectors"))
    return try JSONValue.parse(try Data(contentsOf: url))
}

extension JSONValue {
    var str: String { stringValue! }
    var int: Int { intValue! }
    var arr: [JSONValue] { arrayValue! }
    var obj: JSONObject { objectValue! }
    var bytes: Data { Data(arr.map { UInt8($0.int) }) }
}

func peer(_ s: String) throws -> PeerId { try PeerId(s) }
func secret(_ s: String) throws -> RoomSecret { try RoomSecret(base64URL: s) }

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/p2p-swift.git