Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
comms
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
xx network
comms
Commits
55f38103
Commit
55f38103
authored
Aug 26, 2022
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Add basic unit tests for webconn
parent
cb2eb413
No related branches found
No related tags found
3 merge requests
!39
Merge release into master
,
!34
Update to use modified client, add params for relevant options, enable use of tls with web conn
,
!32
Project/channels
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
connect/webConn_test.go
+123
-0
123 additions, 0 deletions
connect/webConn_test.go
with
123 additions
and
0 deletions
connect/webConn_test.go
0 → 100644
+
123
−
0
View file @
55f38103
package
connect
import
(
"gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/primitives/id"
"testing"
)
func
TestWebConn_Close
(
t
*
testing
.
T
)
{
rng
:=
csprng
.
NewSystemRNG
()
hostId
,
err
:=
id
.
NewRandomID
(
rng
,
id
.
User
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
hostParams
:=
GetDefaultHostParams
()
hostParams
.
ConnectionType
=
Web
h
,
err
:=
NewHost
(
hostId
,
"0.0.0.0"
,
nil
,
hostParams
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
wc
:=
webConn
{
h
:
h
,
connection
:
nil
,
}
err
=
wc
.
Connect
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
wc
.
Close
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
TestWebConn_Connect
(
t
*
testing
.
T
)
{
rng
:=
csprng
.
NewSystemRNG
()
hostId
,
err
:=
id
.
NewRandomID
(
rng
,
id
.
User
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
hostParams
:=
GetDefaultHostParams
()
hostParams
.
ConnectionType
=
Web
h
,
err
:=
NewHost
(
hostId
,
"0.0.0.0"
,
nil
,
hostParams
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
wc
:=
webConn
{
h
:
h
,
connection
:
nil
,
}
err
=
wc
.
Connect
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
TestWebConn_GetGrpcConn
(
t
*
testing
.
T
)
{
defer
func
()
{
if
r
:=
recover
();
r
==
nil
{
t
.
Error
(
"Did not receive expected fatal error"
)
}
}()
rng
:=
csprng
.
NewSystemRNG
()
hostId
,
err
:=
id
.
NewRandomID
(
rng
,
id
.
User
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
hostParams
:=
GetDefaultHostParams
()
hostParams
.
ConnectionType
=
Web
h
,
err
:=
NewHost
(
hostId
,
"0.0.0.0"
,
nil
,
hostParams
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
wc
:=
webConn
{
h
:
h
,
connection
:
nil
,
}
err
=
wc
.
Connect
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
conn
:=
wc
.
GetGrpcConn
()
if
conn
!=
nil
{
t
.
Fatal
(
"Expected panic, received conn instead"
)
}
}
func
TestWebConn_GetWebConn
(
t
*
testing
.
T
)
{
rng
:=
csprng
.
NewSystemRNG
()
hostId
,
err
:=
id
.
NewRandomID
(
rng
,
id
.
User
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
hostParams
:=
GetDefaultHostParams
()
hostParams
.
ConnectionType
=
Web
h
,
err
:=
NewHost
(
hostId
,
"0.0.0.0"
,
nil
,
hostParams
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
wc
:=
webConn
{
h
:
h
,
connection
:
nil
,
}
err
=
wc
.
Connect
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
conn
:=
wc
.
GetWebConn
()
if
conn
==
nil
{
t
.
Fatal
(
"Expected grpcConn, received nil instead"
)
}
}
func
TestWebConn_IsWeb
(
t
*
testing
.
T
)
{
wc
:=
webConn
{}
if
!
wc
.
IsWeb
()
{
t
.
Fatal
(
"WebConn is not web"
)
}
}
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