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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
28f2b851
Commit
28f2b851
authored
3 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
finished fixing group chat tests
parent
f8df0ac7
No related branches found
No related tags found
3 merge requests
!510
Release
,
!207
WIP: Client Restructure
,
!203
Symmetric broadcast
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
groupChat/receiveRequest_test.go
+27
-56
27 additions, 56 deletions
groupChat/receiveRequest_test.go
groupChat/utils_test.go
+3
-3
3 additions, 3 deletions
groupChat/utils_test.go
with
30 additions
and
59 deletions
groupChat/receiveRequest_test.go
+
27
−
56
View file @
28f2b851
...
@@ -10,10 +10,10 @@ package groupChat
...
@@ -10,10 +10,10 @@ package groupChat
import
(
import
(
"github.com/cloudflare/circl/dh/sidh"
"github.com/cloudflare/circl/dh/sidh"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/proto"
"gitlab.com/elixxir/client/c
mix
"
"gitlab.com/elixxir/client/c
atalog
"
"gitlab.com/elixxir/client/e2e/ratchet/partner/session"
"gitlab.com/elixxir/client/e2e/ratchet/partner/session"
"gitlab.com/elixxir/client/e2e/receive"
gs
"gitlab.com/elixxir/client/groupChat/groupStore"
gs
"gitlab.com/elixxir/client/groupChat/groupStore"
"gitlab.com/elixxir/client/stoppable"
util
"gitlab.com/elixxir/client/storage/utility"
util
"gitlab.com/elixxir/client/storage/utility"
"math/rand"
"math/rand"
"reflect"
"reflect"
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
)
)
// Tests that the correct group is received from the request.
// Tests that the correct group is received from the request.
func
Test
Manager_receiveRequest
(
t
*
testing
.
T
)
{
func
Test
RequestListener_Hear
(
t
*
testing
.
T
)
{
prng
:=
rand
.
New
(
rand
.
NewSource
(
42
))
prng
:=
rand
.
New
(
rand
.
NewSource
(
42
))
requestChan
:=
make
(
chan
gs
.
Group
)
requestChan
:=
make
(
chan
gs
.
Group
)
requestFunc
:=
func
(
g
gs
.
Group
)
{
requestChan
<-
g
}
requestFunc
:=
func
(
g
gs
.
Group
)
{
requestChan
<-
g
}
...
@@ -44,11 +44,12 @@ func TestManager_receiveRequest(t *testing.T) {
...
@@ -44,11 +44,12 @@ func TestManager_receiveRequest(t *testing.T) {
t
.
Errorf
(
"Failed to marshal proto message: %+v"
,
err
)
t
.
Errorf
(
"Failed to marshal proto message: %+v"
,
err
)
}
}
msg
:=
cmix
.
TargetedCmix
Message
{
msg
:=
receive
.
Message
{
Sender
:
g
.
Members
[
0
]
.
ID
,
Sender
:
g
.
Members
[
0
]
.
ID
,
Payload
:
requestMarshaled
,
Payload
:
requestMarshaled
,
MessageType
:
message
.
GroupCreationRequest
,
MessageType
:
catalog
.
GroupCreationRequest
,
}
}
listener
:=
requestListener
{
m
:
m
}
myVariant
:=
sidh
.
KeyVariantSidhA
myVariant
:=
sidh
.
KeyVariantSidhA
mySIDHPrivKey
:=
util
.
NewSIDHPrivateKey
(
myVariant
)
mySIDHPrivKey
:=
util
.
NewSIDHPrivateKey
(
myVariant
)
...
@@ -71,10 +72,7 @@ func TestManager_receiveRequest(t *testing.T) {
...
@@ -71,10 +72,7 @@ func TestManager_receiveRequest(t *testing.T) {
session
.
GetDefaultParams
(),
session
.
GetDefaultParams
(),
)
)
rawMessages
:=
make
(
chan
message
.
Receive
)
go
listener
.
Hear
(
msg
)
quit
:=
stoppable
.
NewSingle
(
"groupReceiveRequestTestStoppable"
)
go
m
.
receiveRequest
(
rawMessages
,
quit
)
rawMessages
<-
msg
select
{
select
{
case
receivedGrp
:=
<-
requestChan
:
case
receivedGrp
:=
<-
requestChan
:
...
@@ -89,7 +87,7 @@ func TestManager_receiveRequest(t *testing.T) {
...
@@ -89,7 +87,7 @@ func TestManager_receiveRequest(t *testing.T) {
// Tests that the callback is not called when the group already exists in the
// Tests that the callback is not called when the group already exists in the
// manager.
// manager.
func
Test
Manager_receiveRequest
_GroupExists
(
t
*
testing
.
T
)
{
func
Test
RequestListener_Hear
_GroupExists
(
t
*
testing
.
T
)
{
prng
:=
rand
.
New
(
rand
.
NewSource
(
42
))
prng
:=
rand
.
New
(
rand
.
NewSource
(
42
))
requestChan
:=
make
(
chan
gs
.
Group
)
requestChan
:=
make
(
chan
gs
.
Group
)
requestFunc
:=
func
(
g
gs
.
Group
)
{
requestChan
<-
g
}
requestFunc
:=
func
(
g
gs
.
Group
)
{
requestChan
<-
g
}
...
@@ -106,15 +104,14 @@ func TestManager_receiveRequest_GroupExists(t *testing.T) {
...
@@ -106,15 +104,14 @@ func TestManager_receiveRequest_GroupExists(t *testing.T) {
t
.
Errorf
(
"Failed to marshal proto message: %+v"
,
err
)
t
.
Errorf
(
"Failed to marshal proto message: %+v"
,
err
)
}
}
msg
:=
message
.
Receive
{
listener
:=
requestListener
{
m
:
m
}
msg
:=
receive
.
Message
{
Payload
:
requestMarshaled
,
Payload
:
requestMarshaled
,
MessageType
:
message
.
GroupCreationRequest
,
MessageType
:
catalog
.
GroupCreationRequest
,
}
}
rawMessages
:=
make
(
chan
message
.
Receive
)
go
listener
.
Hear
(
msg
)
stop
:=
stoppable
.
NewSingle
(
"testStoppable"
)
go
m
.
receiveRequest
(
rawMessages
,
stop
)
rawMessages
<-
msg
select
{
select
{
case
<-
requestChan
:
case
<-
requestChan
:
...
@@ -124,47 +121,21 @@ func TestManager_receiveRequest_GroupExists(t *testing.T) {
...
@@ -124,47 +121,21 @@ func TestManager_receiveRequest_GroupExists(t *testing.T) {
}
}
}
}
// Tests that the quit channel quits the worker.
func
TestManager_receiveRequest_QuitChan
(
t
*
testing
.
T
)
{
prng
:=
rand
.
New
(
rand
.
NewSource
(
42
))
requestChan
:=
make
(
chan
gs
.
Group
)
requestFunc
:=
func
(
g
gs
.
Group
)
{
requestChan
<-
g
}
m
,
_
:=
newTestManagerWithStore
(
prng
,
10
,
0
,
requestFunc
,
nil
,
t
)
rawMessages
:=
make
(
chan
message
.
Receive
)
stop
:=
stoppable
.
NewSingle
(
"testStoppable"
)
done
:=
make
(
chan
struct
{})
go
func
()
{
m
.
receiveRequest
(
rawMessages
,
stop
)
done
<-
struct
{}{}
}()
if
err
:=
stop
.
Close
();
err
!=
nil
{
t
.
Errorf
(
"Failed to signal close to process: %+v"
,
err
)
}
select
{
case
<-
done
:
case
<-
time
.
NewTimer
(
5
*
time
.
Millisecond
)
.
C
:
t
.
Error
(
"receiveRequest() failed to close when the quit."
)
}
}
// Tests that the callback is not called when the send message is not of the
// Tests that the callback is not called when the send message is not of the
// correct type.
// correct type.
func
Test
Manager_receiveRequest_Sen
dMessageType
Error
(
t
*
testing
.
T
)
{
func
Test
RequestListener_Hear_Ba
dMessageType
(
t
*
testing
.
T
)
{
prng
:=
rand
.
New
(
rand
.
NewSource
(
42
))
prng
:=
rand
.
New
(
rand
.
NewSource
(
42
))
requestChan
:=
make
(
chan
gs
.
Group
)
requestChan
:=
make
(
chan
gs
.
Group
)
requestFunc
:=
func
(
g
gs
.
Group
)
{
requestChan
<-
g
}
requestFunc
:=
func
(
g
gs
.
Group
)
{
requestChan
<-
g
}
m
,
_
:=
newTestManagerWithStore
(
prng
,
10
,
0
,
requestFunc
,
nil
,
t
)
m
,
_
:=
newTestManagerWithStore
(
prng
,
10
,
0
,
requestFunc
,
nil
,
t
)
msg
:=
message
.
Receiv
e
{
msg
:=
receive
.
Messag
e
{
MessageType
:
message
.
NoType
,
MessageType
:
catalog
.
NoType
,
}
}
rawMessages
:=
make
(
chan
message
.
Receive
)
listener
:=
requestListener
{
m
:
m
}
stop
:=
stoppable
.
NewSingle
(
"singleStoppable"
)
go
m
.
receiveRequest
(
rawMessages
,
stop
)
go
listener
.
Hear
(
msg
)
rawMessages
<-
msg
select
{
select
{
case
receivedGrp
:=
<-
requestChan
:
case
receivedGrp
:=
<-
requestChan
:
...
@@ -212,9 +183,9 @@ func TestManager_readRequest(t *testing.T) {
...
@@ -212,9 +183,9 @@ func TestManager_readRequest(t *testing.T) {
t
.
Errorf
(
"Failed to marshal proto message: %+v"
,
err
)
t
.
Errorf
(
"Failed to marshal proto message: %+v"
,
err
)
}
}
msg
:=
message
.
Receiv
e
{
msg
:=
receive
.
Messag
e
{
Payload
:
requestMarshaled
,
Payload
:
requestMarshaled
,
MessageType
:
message
.
GroupCreationRequest
,
MessageType
:
catalog
.
GroupCreationRequest
,
}
}
newGrp
,
err
:=
m
.
readRequest
(
msg
)
newGrp
,
err
:=
m
.
readRequest
(
msg
)
...
@@ -232,8 +203,8 @@ func TestManager_readRequest(t *testing.T) {
...
@@ -232,8 +203,8 @@ func TestManager_readRequest(t *testing.T) {
func
TestManager_readRequest_MessageTypeError
(
t
*
testing
.
T
)
{
func
TestManager_readRequest_MessageTypeError
(
t
*
testing
.
T
)
{
m
,
_
:=
newTestManager
(
rand
.
New
(
rand
.
NewSource
(
42
)),
t
)
m
,
_
:=
newTestManager
(
rand
.
New
(
rand
.
NewSource
(
42
)),
t
)
expectedErr
:=
sendMessageTypeErr
expectedErr
:=
sendMessageTypeErr
msg
:=
message
.
Receiv
e
{
msg
:=
receive
.
Messag
e
{
MessageType
:
message
.
NoType
,
MessageType
:
catalog
.
NoType
,
}
}
_
,
err
:=
m
.
readRequest
(
msg
)
_
,
err
:=
m
.
readRequest
(
msg
)
...
@@ -255,9 +226,9 @@ func TestManager_readRequest_ProtoUnmarshalError(t *testing.T) {
...
@@ -255,9 +226,9 @@ func TestManager_readRequest_ProtoUnmarshalError(t *testing.T) {
t
.
Errorf
(
"Failed to marshal proto message: %+v"
,
err
)
t
.
Errorf
(
"Failed to marshal proto message: %+v"
,
err
)
}
}
msg
:=
message
.
Receiv
e
{
msg
:=
receive
.
Messag
e
{
Payload
:
requestMarshaled
,
Payload
:
requestMarshaled
,
MessageType
:
message
.
GroupCreationRequest
,
MessageType
:
catalog
.
GroupCreationRequest
,
}
}
_
,
err
=
m
.
readRequest
(
msg
)
_
,
err
=
m
.
readRequest
(
msg
)
...
@@ -271,9 +242,9 @@ func TestManager_readRequest_ProtoUnmarshalError(t *testing.T) {
...
@@ -271,9 +242,9 @@ func TestManager_readRequest_ProtoUnmarshalError(t *testing.T) {
func
TestManager_readRequest_DeserializeMembershipError
(
t
*
testing
.
T
)
{
func
TestManager_readRequest_DeserializeMembershipError
(
t
*
testing
.
T
)
{
m
,
_
:=
newTestManager
(
rand
.
New
(
rand
.
NewSource
(
42
)),
t
)
m
,
_
:=
newTestManager
(
rand
.
New
(
rand
.
NewSource
(
42
)),
t
)
expectedErr
:=
strings
.
SplitN
(
protoUnmarshalErr
,
"%"
,
2
)[
0
]
expectedErr
:=
strings
.
SplitN
(
protoUnmarshalErr
,
"%"
,
2
)[
0
]
msg
:=
message
.
Receiv
e
{
msg
:=
receive
.
Messag
e
{
Payload
:
[]
byte
(
"Invalid message."
),
Payload
:
[]
byte
(
"Invalid message."
),
MessageType
:
message
.
GroupCreationRequest
,
MessageType
:
catalog
.
GroupCreationRequest
,
}
}
_
,
err
:=
m
.
readRequest
(
msg
)
_
,
err
:=
m
.
readRequest
(
msg
)
...
...
This diff is collapsed.
Click to expand it.
groupChat/utils_test.go
+
3
−
3
View file @
28f2b851
...
@@ -14,9 +14,9 @@ import (
...
@@ -14,9 +14,9 @@ import (
"gitlab.com/elixxir/client/catalog"
"gitlab.com/elixxir/client/catalog"
"gitlab.com/elixxir/client/cmix"
"gitlab.com/elixxir/client/cmix"
"gitlab.com/elixxir/client/cmix/gateway"
"gitlab.com/elixxir/client/cmix/gateway"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/cmix/identity"
"gitlab.com/elixxir/client/cmix/identity"
"gitlab.com/elixxir/client/cmix/message"
"gitlab.com/elixxir/client/cmix/message"
"gitlab.com/elixxir/client/cmix/rounds"
clientE2E
"gitlab.com/elixxir/client/e2e"
clientE2E
"gitlab.com/elixxir/client/e2e"
"gitlab.com/elixxir/client/e2e/ratchet/partner"
"gitlab.com/elixxir/client/e2e/ratchet/partner"
"gitlab.com/elixxir/client/e2e/ratchet/partner/session"
"gitlab.com/elixxir/client/e2e/ratchet/partner/session"
...
@@ -242,11 +242,11 @@ type testE2eMessage struct {
...
@@ -242,11 +242,11 @@ type testE2eMessage struct {
Payload
[]
byte
Payload
[]
byte
}
}
func
(
tnm
*
testE2eManager
)
AddPartner
(
partnerID
*
id
.
ID
,
partnerPubKey
,
myPrivKey
*
cyclic
.
Int
,
partnerSIDHPubKey
*
sidh
.
PublicKey
,
mySIDHPrivKey
*
sidh
.
PrivateKey
,
sendParams
,
receiveParams
session
.
Params
)
(
*
partner
.
Manager
,
error
)
{
func
(
tnm
*
testE2eManager
)
AddPartner
(
partnerID
*
id
.
ID
,
partnerPubKey
,
myPrivKey
*
cyclic
.
Int
,
partnerSIDHPubKey
*
sidh
.
PublicKey
,
mySIDHPrivKey
*
sidh
.
PrivateKey
,
sendParams
,
receiveParams
session
.
Params
)
(
partner
.
Manager
,
error
)
{
panic
(
"implement me"
)
panic
(
"implement me"
)
}
}
func
(
tnm
*
testE2eManager
)
GetPartner
(
partnerID
*
id
.
ID
)
(
*
partner
.
Manager
,
error
)
{
func
(
tnm
*
testE2eManager
)
GetPartner
(
partnerID
*
id
.
ID
)
(
partner
.
Manager
,
error
)
{
panic
(
"implement me"
)
panic
(
"implement me"
)
}
}
...
...
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