Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
6e72e884
Unverified
Commit
6e72e884
authored
Aug 21, 2018
by
Raghav Gulati
Browse files
Add test for duplicate tpts in muxer
parent
3c19cb12
Changes
1
Hide whitespace changes
Inline
Side-by-side
config/muxer_test.go
View file @
6e72e884
package
config
import
(
"context"
"testing"
host
"github.com/libp2p/go-libp2p-host"
peer
"github.com/libp2p/go-libp2p-peer"
swarmt
"github.com/libp2p/go-libp2p-swarm/testing"
bhost
"github.com/libp2p/go-libp2p/p2p/host/basic"
mux
"github.com/libp2p/go-stream-muxer"
yamux
"github.com/whyrusleeping/go-smux-yamux"
)
...
...
@@ -52,3 +56,46 @@ func TestMuxerBadTypes(t *testing.T) {
}
}
}
func
TestCatchDuplicateTransportsMuxer
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
h
:=
bhost
.
New
(
swarmt
.
GenSwarm
(
t
,
ctx
))
yamuxMuxer
,
err
:=
MuxerConstructor
(
yamux
.
DefaultTransport
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
var
tests
=
map
[
string
]
struct
{
h
host
.
Host
transports
[]
MsMuxC
expectedError
string
}{
"no duplicate transports"
:
{
h
:
h
,
transports
:
[]
MsMuxC
{
MsMuxC
{
yamuxMuxer
,
"yamux"
}},
expectedError
:
""
,
},
"duplicate transports"
:
{
h
:
h
,
transports
:
[]
MsMuxC
{
MsMuxC
{
yamuxMuxer
,
"yamux"
},
MsMuxC
{
yamuxMuxer
,
"yamux"
},
},
expectedError
:
"duplicate muxer transport: yamux"
,
},
}
for
testName
,
test
:=
range
tests
{
t
.
Run
(
testName
,
func
(
t
*
testing
.
T
)
{
_
,
err
=
makeMuxer
(
test
.
h
,
test
.
transports
)
if
err
!=
nil
{
if
err
.
Error
()
!=
test
.
expectedError
{
t
.
Errorf
(
"
\n
expected: [%v]
\n
actual: [%v]
\n
"
,
test
.
expectedError
,
err
,
)
}
}
})
}
}
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