From 6298d56ae0f4c81cc72d9b9af57f9649b9fb6836 Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Tue, 9 Aug 2022 20:09:09 +0100 Subject: [PATCH] Update BackupReport model --- .../ElixxirDAppsSDK/Models/BackupReport.swift | 4 ++-- .../Models/BackupReportTests.swift | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Sources/ElixxirDAppsSDK/Models/BackupReport.swift b/Sources/ElixxirDAppsSDK/Models/BackupReport.swift index bea36500..5b405605 100644 --- a/Sources/ElixxirDAppsSDK/Models/BackupReport.swift +++ b/Sources/ElixxirDAppsSDK/Models/BackupReport.swift @@ -3,14 +3,14 @@ import Foundation public struct BackupReport: Equatable { public init( restoredContacts: [Data], - params: Data + params: String ) { self.restoredContacts = restoredContacts self.params = params } public var restoredContacts: [Data] - public var params: Data + public var params: String } extension BackupReport: Codable { diff --git a/Tests/ElixxirDAppsSDKTests/Models/BackupReportTests.swift b/Tests/ElixxirDAppsSDKTests/Models/BackupReportTests.swift index cd37b514..5fb99128 100644 --- a/Tests/ElixxirDAppsSDKTests/Models/BackupReportTests.swift +++ b/Tests/ElixxirDAppsSDKTests/Models/BackupReportTests.swift @@ -4,24 +4,27 @@ import XCTest final class BackupReportTests: XCTestCase { func testCoding() throws { - let restoredContacts: [Data] = [ - "id1".data(using: .utf8)!, - "id2".data(using: .utf8)!, - "id3".data(using: .utf8)!, - ] - let paramsB64 = "cGFyYW1z" + let restoredContact1B64 = "U4x/lrFkvxuXu59LtHLon1sUhPJSCcnZND6SugndnVID" + let restoredContact2B64 = "15tNdkKbYXoMn58NO6VbDMDWFEyIhTWEGsvgcJsHWAgD" + let params = "test1234" let jsonString = """ { - "RestoredContacts": [\(restoredContacts.map { "\"\($0.base64EncodedString())\"" }.joined(separator: ", "))], - "Params": "\(paramsB64)" + "RestoredContacts": [ + "\(restoredContact1B64)", + "\(restoredContact2B64)" + ], + "Params": "\(params)" } """ let jsonData = jsonString.data(using: .utf8)! let model = try BackupReport.decode(jsonData) XCTAssertNoDifference(model, BackupReport( - restoredContacts: restoredContacts, - params: Data(base64Encoded: paramsB64)! + restoredContacts: [ + Data(base64Encoded: restoredContact1B64)!, + Data(base64Encoded: restoredContact2B64)!, + ], + params: params )) let encodedModel = try model.encode() -- GitLab