Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-conn-security-multistream
Commits
b40b2555
Commit
b40b2555
authored
Jan 18, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests
parent
1bc19799
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
ssms_test.go
ssms_test.go
+55
-0
No files found.
ssms_test.go
0 → 100644
View file @
b40b2555
package
ssms
import
(
"context"
"net"
"sync"
"testing"
ss
"github.com/libp2p/go-stream-security"
sst
"github.com/libp2p/go-stream-security/test"
)
func
TestCommonProto
(
t
*
testing
.
T
)
{
var
at
,
bt
SSMuxer
atInsecure
:=
ss
.
InsecureTransport
(
"peerA"
)
btInsecure
:=
ss
.
InsecureTransport
(
"peerB"
)
at
.
AddTransport
(
"/plaintext/1.0.0"
,
&
atInsecure
)
bt
.
AddTransport
(
"/plaintext/1.1.0"
,
&
btInsecure
)
bt
.
AddTransport
(
"/plaintext/1.0.0"
,
&
btInsecure
)
sst
.
SubtestRW
(
t
,
&
at
,
&
bt
,
"peerA"
,
"peerB"
)
}
func
TestNoCommonProto
(
t
*
testing
.
T
)
{
var
at
,
bt
SSMuxer
atInsecure
:=
ss
.
InsecureTransport
(
"peerA"
)
btInsecure
:=
ss
.
InsecureTransport
(
"peerB"
)
at
.
AddTransport
(
"/plaintext/1.0.0"
,
&
atInsecure
)
bt
.
AddTransport
(
"/plaintext/1.1.0"
,
&
btInsecure
)
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
a
,
b
:=
net
.
Pipe
()
var
wg
sync
.
WaitGroup
wg
.
Add
(
2
)
go
func
()
{
defer
wg
.
Done
()
defer
a
.
Close
()
_
,
err
:=
at
.
SecureInbound
(
ctx
,
a
)
if
err
==
nil
{
t
.
Fatal
(
"conection should have failed"
)
}
}()
go
func
()
{
defer
wg
.
Done
()
defer
b
.
Close
()
_
,
err
:=
bt
.
SecureOutbound
(
ctx
,
b
,
"peerA"
)
if
err
==
nil
{
t
.
Fatal
(
"connection should have failed"
)
}
}()
wg
.
Wait
()
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment