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
bfd7e518
Commit
bfd7e518
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add ChannelDef model
parent
d18e9465
No related branches found
No related tags found
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/ChannelDef.swift
+37
-0
37 additions, 0 deletions
Sources/ElixxirDAppsSDK/Models/ChannelDef.swift
Tests/ElixxirDAppsSDKTests/Models/ChannelDefTests.swift
+34
-0
34 additions, 0 deletions
Tests/ElixxirDAppsSDKTests/Models/ChannelDefTests.swift
with
71 additions
and
0 deletions
Sources/ElixxirDAppsSDK/Models/ChannelDef.swift
0 → 100644
+
37
−
0
View file @
bfd7e518
import
Foundation
public
struct
ChannelDef
:
Equatable
{
public
init
(
name
:
String
,
description
:
String
,
salt
:
Data
,
pubKey
:
Data
)
{
self
.
name
=
name
self
.
description
=
description
self
.
salt
=
salt
self
.
pubKey
=
pubKey
}
public
var
name
:
String
public
var
description
:
String
public
var
salt
:
Data
public
var
pubKey
:
Data
}
extension
ChannelDef
:
Codable
{
enum
CodingKeys
:
String
,
CodingKey
{
case
name
=
"Name"
case
description
=
"Description"
case
salt
=
"Salt"
case
pubKey
=
"PubKey"
}
public
static
func
decode
(
_
data
:
Data
)
throws
->
Self
{
try
JSONDecoder
()
.
decode
(
Self
.
self
,
from
:
data
)
}
public
func
encode
()
throws
->
Data
{
try
JSONEncoder
()
.
encode
(
self
)
}
}
This diff is collapsed.
Click to expand it.
Tests/ElixxirDAppsSDKTests/Models/ChannelDefTests.swift
0 → 100644
+
34
−
0
View file @
bfd7e518
import
CustomDump
import
XCTest
@testable
import
ElixxirDAppsSDK
final
class
ChannelDefTests
:
XCTestCase
{
func
testCoding
()
throws
{
let
name
=
"My broadcast channel"
let
description
=
"A broadcast channel for me to test things"
let
saltB64
=
"gpUqW7N22sffMXsvPLE7BA=="
let
pubKeyB64
=
"LS0tLS1CRUdJTiBSU0EgUFVCTElDIEtFWS0tLS0tCk1DZ0NJUUN2YkZVckJKRFpqT3Y0Y0MvUHZZdXNvQkFtUTFkb3Znb044aHRuUjA2T3F3SURBUUFCCi0tLS0tRU5EIFJTQSBQVUJMSUMgS0VZLS0tLS0="
let
jsonString
=
"""
{
"
Name
": "
\(
name
)
",
"
Description
": "
\(
description
)
",
"
Salt
": "
\(
saltB64
)
",
"
PubKey
": "
\(
pubKeyB64
)
"
}
"""
let
jsonData
=
jsonString
.
data
(
using
:
.
utf8
)
!
let
model
=
try
ChannelDef
.
decode
(
jsonData
)
XCTAssertNoDifference
(
model
,
ChannelDef
(
name
:
name
,
description
:
description
,
salt
:
Data
(
base64Encoded
:
saltB64
)
!
,
pubKey
:
Data
(
base64Encoded
:
pubKeyB64
)
!
))
let
encodedModel
=
try
model
.
encode
()
let
decodedModel
=
try
ChannelDef
.
decode
(
encodedModel
)
XCTAssertNoDifference
(
decodedModel
,
model
)
}
}
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