Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Commits
88ab1875
Commit
88ab1875
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add SingleUseSendReport model
parent
a4046b1b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!102
Release 1.0.0
,
!18
Update Bindings
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Sources/ElixxirDAppsSDK/Models/SingleUseSendReport.swift
+51
-0
51 additions, 0 deletions
Sources/ElixxirDAppsSDK/Models/SingleUseSendReport.swift
Tests/ElixxirDAppsSDKTests/Models/SingleUseSendReportTests.swift
+35
-0
35 additions, 0 deletions
...lixxirDAppsSDKTests/Models/SingleUseSendReportTests.swift
with
86 additions
and
0 deletions
Sources/ElixxirDAppsSDK/Models/SingleUseSendReport.swift
0 → 100644
+
51
−
0
View file @
88ab1875
import
Foundation
public
struct
SingleUseSendReport
:
Equatable
{
public
init
(
rounds
:
[
Int
],
ephId
:
EphId
)
{
self
.
rounds
=
rounds
self
.
ephId
=
ephId
}
public
var
rounds
:
[
Int
]
public
var
ephId
:
EphId
}
extension
SingleUseSendReport
{
public
struct
EphId
:
Equatable
{
public
init
(
ephId
:
[
Int
],
source
:
Data
)
{
self
.
ephId
=
ephId
self
.
source
=
source
}
public
var
ephId
:
[
Int
]
public
var
source
:
Data
}
}
extension
SingleUseSendReport
:
Codable
{
enum
CodingKeys
:
String
,
CodingKey
{
case
rounds
=
"Rounds"
case
ephId
=
"EphID"
}
public
static
func
decode
(
_
data
:
Data
)
throws
->
Self
{
try
JSONDecoder
()
.
decode
(
Self
.
self
,
from
:
data
)
}
public
func
encode
()
throws
->
Data
{
try
JSONEncoder
()
.
encode
(
self
)
}
}
extension
SingleUseSendReport
.
EphId
:
Codable
{
enum
CodingKeys
:
String
,
CodingKey
{
case
ephId
=
"EphId"
case
source
=
"Source"
}
}
This diff is collapsed.
Click to expand it.
Tests/ElixxirDAppsSDKTests/Models/SingleUseSendReportTests.swift
0 → 100644
+
35
−
0
View file @
88ab1875
import
CustomDump
import
XCTest
@testable
import
ElixxirDAppsSDK
final
class
SingleUseSendReportTests
:
XCTestCase
{
func
testCoding
()
throws
{
let
rounds
:
[
Int
]
=
[
1
,
5
,
9
]
let
ephId
:
[
Int
]
=
[
0
,
0
,
0
,
0
,
0
,
0
,
3
,
89
]
let
ephIdSourceB64
=
"emV6aW1hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD"
let
jsonString
=
"""
{
"
Rounds
": [
\(
rounds
.
map
{
"
\(
$0
)
"
}
.
joined
(
separator
:
", "
)
)
],
"
EphID
": {
"
EphId
": [
\(
ephId
.
map
{
"
\(
$0
)
"
}
.
joined
(
separator
:
", "
)
)
],
"
Source
": "
\(
ephIdSourceB64
)
"
}
}
"""
let
jsonData
=
jsonString
.
data
(
using
:
.
utf8
)
!
let
report
=
try
SingleUseSendReport
.
decode
(
jsonData
)
XCTAssertNoDifference
(
report
,
SingleUseSendReport
(
rounds
:
rounds
,
ephId
:
.
init
(
ephId
:
ephId
,
source
:
Data
(
base64Encoded
:
ephIdSourceB64
)
!
)
))
let
encodedReport
=
try
report
.
encode
()
let
decodedReport
=
try
SingleUseSendReport
.
decode
(
encodedReport
)
XCTAssertNoDifference
(
decodedReport
,
report
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment