Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
3d0720e3
Commit
3d0720e3
authored
Apr 9, 2019
by
Tigran Avakyan
Browse files
Options
Downloads
Patches
Plain Diff
Made changes to pass in group as JSON
parent
77f8112b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bindings/client.go
+9
-1
9 additions, 1 deletion
bindings/client.go
bindings/client_test.go
+16
-3
16 additions, 3 deletions
bindings/client_test.go
cmd/root.go
+2
-9
2 additions, 9 deletions
cmd/root.go
with
27 additions
and
13 deletions
bindings/client.go
+
9
−
1
View file @
3d0720e3
...
@@ -14,6 +14,7 @@ import (
...
@@ -14,6 +14,7 @@ import (
"gitlab.com/elixxir/client/user"
"gitlab.com/elixxir/client/user"
"gitlab.com/elixxir/crypto/certs"
"gitlab.com/elixxir/crypto/certs"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/crypto/large"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/elixxir/primitives/id"
"gitlab.com/elixxir/primitives/id"
"gitlab.com/elixxir/primitives/switchboard"
"gitlab.com/elixxir/primitives/switchboard"
...
@@ -146,12 +147,19 @@ func InitClient(storage Storage, loc string) error {
...
@@ -146,12 +147,19 @@ func InitClient(storage Storage, loc string) error {
// “Jono”
// “Jono”
// OIF3OJ5I
// OIF3OJ5I
func
Register
(
registrationCode
string
,
gwAddr
string
,
numNodes
int
,
func
Register
(
registrationCode
string
,
gwAddr
string
,
numNodes
int
,
mint
bool
,
grp
*
cyclic
.
Group
)
([]
byte
,
error
)
{
mint
bool
,
grp
JSON
string
)
([]
byte
,
error
)
{
if
numNodes
<
1
{
if
numNodes
<
1
{
return
id
.
ZeroID
[
:
],
errors
.
New
(
"invalid number of nodes"
)
return
id
.
ZeroID
[
:
],
errors
.
New
(
"invalid number of nodes"
)
}
}
// Unmarshal group JSON
grp
:=
cyclic
.
NewGroup
(
large
.
NewMaxInt
(),
large
.
NewMaxInt
(),
large
.
NewMaxInt
())
err
:=
grp
.
UnmarshalJSON
([]
byte
(
grpJSON
))
if
err
!=
nil
{
return
id
.
ZeroID
[
:
],
err
}
UID
,
err
:=
api
.
Register
(
registrationCode
,
gwAddr
,
uint
(
numNodes
),
mint
,
grp
)
UID
,
err
:=
api
.
Register
(
registrationCode
,
gwAddr
,
uint
(
numNodes
),
mint
,
grp
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
bindings/client_test.go
+
16
−
3
View file @
3d0720e3
...
@@ -147,8 +147,12 @@ func TestRegister(t *testing.T) {
...
@@ -147,8 +147,12 @@ func TestRegister(t *testing.T) {
g
:=
large
.
NewInt
(
2
)
g
:=
large
.
NewInt
(
2
)
q
:=
large
.
NewInt
(
3
)
q
:=
large
.
NewInt
(
3
)
grp
:=
cyclic
.
NewGroup
(
p
,
g
,
q
)
grp
:=
cyclic
.
NewGroup
(
p
,
g
,
q
)
grpJSON
,
err
:=
grp
.
MarshalJSON
()
if
err
!=
nil
{
t
.
Errorf
(
"Failed to marshal group JSON: %s"
,
err
)
}
regRes
,
err
:=
Register
(
registrationCode
,
gwAddress
,
1
,
false
,
grp
)
regRes
,
err
:=
Register
(
registrationCode
,
gwAddress
,
1
,
false
,
string
(
grpJSON
)
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Registration failed: %s"
,
err
.
Error
())
t
.
Errorf
(
"Registration failed: %s"
,
err
.
Error
())
}
}
...
@@ -170,8 +174,12 @@ func TestRegisterBadNumNodes(t *testing.T) {
...
@@ -170,8 +174,12 @@ func TestRegisterBadNumNodes(t *testing.T) {
g
:=
large
.
NewInt
(
int64
(
2
))
g
:=
large
.
NewInt
(
int64
(
2
))
q
:=
large
.
NewInt
(
int64
(
3
))
q
:=
large
.
NewInt
(
int64
(
3
))
grp
:=
cyclic
.
NewGroup
(
p
,
g
,
q
)
grp
:=
cyclic
.
NewGroup
(
p
,
g
,
q
)
grpJSON
,
err
:=
grp
.
MarshalJSON
()
if
err
!=
nil
{
t
.
Errorf
(
"Failed to marshal group JSON: %s"
,
err
)
}
_
,
err
=
Register
(
registrationCode
,
gwAddress
,
0
,
false
,
grp
)
_
,
err
=
Register
(
registrationCode
,
gwAddress
,
0
,
false
,
string
(
grpJSON
)
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Errorf
(
"Registration worked with bad numnodes! %s"
,
err
.
Error
())
t
.
Errorf
(
"Registration worked with bad numnodes! %s"
,
err
.
Error
())
}
}
...
@@ -202,8 +210,12 @@ func TestLoginLogout(t *testing.T) {
...
@@ -202,8 +210,12 @@ func TestLoginLogout(t *testing.T) {
g
:=
large
.
NewInt
(
2
)
g
:=
large
.
NewInt
(
2
)
q
:=
large
.
NewInt
(
3
)
q
:=
large
.
NewInt
(
3
)
grp
:=
cyclic
.
NewGroup
(
p
,
g
,
q
)
grp
:=
cyclic
.
NewGroup
(
p
,
g
,
q
)
grpJSON
,
err
:=
grp
.
MarshalJSON
()
if
err
!=
nil
{
t
.
Errorf
(
"Failed to marshal group JSON: %s"
,
err
)
}
regRes
,
err
:=
Register
(
registrationCode
,
gwAddress
,
1
,
false
,
grp
)
regRes
,
err
:=
Register
(
registrationCode
,
gwAddress
,
1
,
false
,
string
(
grpJSON
)
)
loginRes
,
err2
:=
Login
(
regRes
,
gwAddress
,
""
)
loginRes
,
err2
:=
Login
(
regRes
,
gwAddress
,
""
)
if
err2
!=
nil
{
if
err2
!=
nil
{
t
.
Errorf
(
"Login failed: %s"
,
err
.
Error
())
t
.
Errorf
(
"Login failed: %s"
,
err
.
Error
())
...
@@ -216,6 +228,7 @@ func TestLoginLogout(t *testing.T) {
...
@@ -216,6 +228,7 @@ func TestLoginLogout(t *testing.T) {
if
err3
!=
nil
{
if
err3
!=
nil
{
t
.
Errorf
(
"Logoutfailed: %s"
,
err
.
Error
())
t
.
Errorf
(
"Logoutfailed: %s"
,
err
.
Error
())
}
}
globals
.
LocalStorage
=
nil
globals
.
LocalStorage
=
nil
}
}
...
...
This diff is collapsed.
Click to expand it.
cmd/root.go
+
2
−
9
View file @
3d0720e3
...
@@ -22,7 +22,6 @@ import (
...
@@ -22,7 +22,6 @@ import (
"gitlab.com/elixxir/client/parse"
"gitlab.com/elixxir/client/parse"
"gitlab.com/elixxir/client/user"
"gitlab.com/elixxir/client/user"
"gitlab.com/elixxir/comms/connect"
"gitlab.com/elixxir/comms/connect"
"gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/elixxir/primitives/format"
"gitlab.com/elixxir/primitives/id"
"gitlab.com/elixxir/primitives/id"
"gitlab.com/elixxir/primitives/switchboard"
"gitlab.com/elixxir/primitives/switchboard"
...
@@ -122,16 +121,10 @@ func sessionInitialization() {
...
@@ -122,16 +121,10 @@ func sessionInitialization() {
// FIXME Use a different encoding for the user ID command line argument,
// FIXME Use a different encoding for the user ID command line argument,
// to allow testing with IDs that are long enough to exercise more than
// to allow testing with IDs that are long enough to exercise more than
// 64 bits
// 64 bits
grp
:=
cyclic
.
Group
{}
grpJSON
:=
viper
.
GetString
(
"group"
)
grpBuff
:=
[]
byte
(
viper
.
GetString
(
"group"
))
err
:=
grp
.
UnmarshalJSON
(
grpBuff
)
if
err
!=
nil
{
fmt
.
Printf
(
"Could Not Decode group from JSON: %s
\n
"
,
err
.
Error
())
return
}
regCode
:=
new
(
id
.
User
)
.
SetUints
(
&
[
4
]
uint64
{
0
,
0
,
0
,
userId
})
.
RegistrationCode
()
regCode
:=
new
(
id
.
User
)
.
SetUints
(
&
[
4
]
uint64
{
0
,
0
,
0
,
userId
})
.
RegistrationCode
()
_
,
err
=
bindings
.
Register
(
regCode
,
gwAddr
,
int
(
numNodes
),
mint
,
&
grp
)
_
,
err
=
bindings
.
Register
(
regCode
,
gwAddr
,
int
(
numNodes
),
mint
,
grp
JSON
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"Could Not Register User: %s
\n
"
,
err
.
Error
())
fmt
.
Printf
(
"Could Not Register User: %s
\n
"
,
err
.
Error
())
return
return
...
...
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