From cb6ba277b1b5c832256c8975c026d978b6a95933 Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Thu, 8 Sep 2022 22:48:42 +0200 Subject: [PATCH] Update BroadcastReport model --- Sources/XXClient/Models/BroadcastReport.swift | 14 +++++++++----- .../Models/BroadcastReportTests.swift | 13 ++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Sources/XXClient/Models/BroadcastReport.swift b/Sources/XXClient/Models/BroadcastReport.swift index 3114a12b..98df8909 100644 --- a/Sources/XXClient/Models/BroadcastReport.swift +++ b/Sources/XXClient/Models/BroadcastReport.swift @@ -2,21 +2,25 @@ import Foundation public struct BroadcastReport: Equatable { public init( - roundId: Int, - ephId: [Int] + rounds: [Int], + ephId: [Int], + roundURL: String ) { - self.roundId = roundId + self.rounds = rounds self.ephId = ephId + self.roundURL = roundURL } - public var roundId: Int + public var rounds: [Int] public var ephId: [Int] + public var roundURL: String } extension BroadcastReport: Codable { enum CodingKeys: String, CodingKey { - case roundId = "RoundID" + case rounds = "Rounds" case ephId = "EphID" + case roundURL = "RoundURL" } public static func decode(_ data: Data) throws -> Self { diff --git a/Tests/XXClientTests/Models/BroadcastReportTests.swift b/Tests/XXClientTests/Models/BroadcastReportTests.swift index 846657bb..3439b1dc 100644 --- a/Tests/XXClientTests/Models/BroadcastReportTests.swift +++ b/Tests/XXClientTests/Models/BroadcastReportTests.swift @@ -4,20 +4,23 @@ import XCTest final class BroadcastReportTests: XCTestCase { func testCoding() throws { - let roundId: Int = 42 + let rounds: [Int] = [25, 26, 29] let ephId: [Int] = [0, 0, 0, 0, 0, 0, 24, 61] + let roundURL = "https://dashboard.xx.network/rounds/25?xxmessenger=true" let jsonString = """ { - "RoundID": \(roundId), - "EphID": [\(ephId.map { "\($0)" }.joined(separator: ", "))] + "Rounds": [\(rounds.map { "\($0)" }.joined(separator: ", "))], + "EphID": [\(ephId.map { "\($0)" }.joined(separator: ", "))], + "RoundURL": "\(roundURL)" } """ let jsonData = jsonString.data(using: .utf8)! let model = try BroadcastReport.decode(jsonData) XCTAssertNoDifference(model, BroadcastReport( - roundId: roundId, - ephId: ephId + rounds: rounds, + ephId: ephId, + roundURL: roundURL )) let encodedModel = try model.encode() -- GitLab