Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
5f727445
Commit
5f727445
authored
Jan 29, 2020
by
Janos Guljas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add swarm.MustParseHexAddress and use it in tests
parent
21dbbe42
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
12 deletions
+22
-12
pingpong_test.go
pkg/api/pingpong_test.go
+3
-3
peer_test.go
pkg/debugapi/peer_test.go
+4
-4
handshake_test.go
pkg/p2p/libp2p/internal/handshake/handshake_test.go
+4
-4
pingpong_test.go
pkg/pingpong/pingpong_test.go
+1
-1
swarm.go
pkg/swarm/swarm.go
+10
-0
No files found.
pkg/api/pingpong_test.go
View file @
5f727445
...
...
@@ -21,9 +21,9 @@ import (
func
TestPingpong
(
t
*
testing
.
T
)
{
rtt
:=
time
.
Minute
peerID
,
_
:=
swarm
.
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c"
)
unknownPeerID
,
_
:=
swarm
.
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59e"
)
errorPeerID
,
_
:=
swarm
.
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59a"
)
peerID
:=
swarm
.
Must
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c"
)
unknownPeerID
:=
swarm
.
Must
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59e"
)
errorPeerID
:=
swarm
.
Must
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59a"
)
testErr
:=
errors
.
New
(
"test error"
)
pingpongService
:=
pingpongmock
.
New
(
func
(
ctx
context
.
Context
,
address
swarm
.
Address
,
msgs
...
string
)
(
time
.
Duration
,
error
)
{
...
...
pkg/debugapi/peer_test.go
View file @
5f727445
...
...
@@ -22,7 +22,7 @@ import (
func
TestConnect
(
t
*
testing
.
T
)
{
underlay
:=
"/ip4/127.0.0.1/tcp/7070/p2p/16Uiu2HAkx8ULY8cTXhdVAcMmLcH9AsTKz6uBQ7DPLKRjMLgBVYkS"
errorUnderlay
:=
"/ip4/127.0.0.1/tcp/7070/p2p/16Uiu2HAkw88cjH2orYrB6fDui4eUNdmgkwnDM8W681UbfsPgM9QY"
overlay
,
_
:=
swarm
.
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c"
)
overlay
:=
swarm
.
Must
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c"
)
testErr
:=
errors
.
New
(
"test error"
)
client
,
cleanup
:=
newTestServer
(
t
,
testServerOptions
{
...
...
@@ -57,9 +57,9 @@ func TestConnect(t *testing.T) {
}
func
TestDisconnect
(
t
*
testing
.
T
)
{
address
,
_
:=
swarm
.
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c"
)
unknownAdddress
,
_
:=
swarm
.
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59e"
)
errorAddress
,
_
:=
swarm
.
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59a"
)
address
:=
swarm
.
Must
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c"
)
unknownAdddress
:=
swarm
.
Must
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59e"
)
errorAddress
:=
swarm
.
Must
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59a"
)
testErr
:=
errors
.
New
(
"test error"
)
client
,
cleanup
:=
newTestServer
(
t
,
testServerOptions
{
...
...
pkg/p2p/libp2p/internal/handshake/handshake_test.go
View file @
5f727445
...
...
@@ -62,8 +62,8 @@ func (s *StreamMock) Close() error {
}
func
TestHandshake
(
t
*
testing
.
T
)
{
node1Addr
,
_
:=
swarm
.
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c"
)
node2Addr
,
_
:=
swarm
.
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59b"
)
node1Addr
:=
swarm
.
Must
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c"
)
node2Addr
:=
swarm
.
Must
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59b"
)
logger
:=
logging
.
New
(
ioutil
.
Discard
,
0
)
info
:=
Info
{
Address
:
node1Addr
,
...
...
@@ -179,8 +179,8 @@ func TestHandshake(t *testing.T) {
}
func
TestHandle
(
t
*
testing
.
T
)
{
node1Addr
,
_
:=
swarm
.
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c"
)
node2Addr
,
_
:=
swarm
.
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59b"
)
node1Addr
:=
swarm
.
Must
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c"
)
node2Addr
:=
swarm
.
Must
ParseHexAddress
(
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59b"
)
nodeInfo
:=
Info
{
Address
:
node1Addr
,
NetworkID
:
0
,
...
...
pkg/pingpong/pingpong_test.go
View file @
5f727445
...
...
@@ -52,7 +52,7 @@ func TestPing(t *testing.T) {
// ping
peerID
:=
"ca1e9f3938cc1425c6061b96ad9eb93e134dfe8734ad490164ef20af9d1cf59c"
peerIDAddress
,
_
:=
swarm
.
ParseHexAddress
(
peerID
)
peerIDAddress
:=
swarm
.
Must
ParseHexAddress
(
peerID
)
greetings
:=
[]
string
{
"hey"
,
"there"
,
"fella"
}
rtt
,
err
:=
client
.
Ping
(
context
.
Background
(),
peerIDAddress
,
greetings
...
)
if
err
!=
nil
{
...
...
pkg/swarm/swarm.go
View file @
5f727445
...
...
@@ -30,6 +30,16 @@ func ParseHexAddress(s string) (a Address, err error) {
return
NewAddress
(
b
),
nil
}
// MustParseHexAddress returns an Address from a hex-encoded string
// representation, and panics if there is a parse error.
func
MustParseHexAddress
(
s
string
)
Address
{
a
,
err
:=
ParseHexAddress
(
s
)
if
err
!=
nil
{
panic
(
err
)
}
return
a
}
// String returns a hex-encoded representation of the Address.
func
(
a
Address
)
String
()
string
{
return
hex
.
EncodeToString
(
a
.
b
)
...
...
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