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) }