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-p2p-kad-dht
Commits
f20eef94
Commit
f20eef94
authored
Sep 22, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(routing:dht) add ctx args
parent
5858c8cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
dht_test.go
dht_test.go
+19
-18
No files found.
dht_test.go
View file @
f20eef94
...
...
@@ -109,13 +109,14 @@ func TestPing(t *testing.T) {
defer
dhtA
.
network
.
Close
()
defer
dhtB
.
network
.
Close
()
_
,
err
=
dhtA
.
Connect
(
peerB
)
_
,
err
=
dhtA
.
Connect
(
context
.
Background
(),
peerB
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
//Test that we can ping the node
err
=
dhtA
.
Ping
(
peerB
,
time
.
Second
*
2
)
ctx
,
_
:=
context
.
WithTimeout
(
context
.
Background
(),
2
*
time
.
Millisecond
)
err
=
dhtA
.
Ping
(
ctx
,
peerB
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -145,7 +146,7 @@ func TestValueGetSet(t *testing.T) {
defer
dhtA
.
network
.
Close
()
defer
dhtB
.
network
.
Close
()
_
,
err
=
dhtA
.
Connect
(
peerB
)
_
,
err
=
dhtA
.
Connect
(
context
.
Background
(),
peerB
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -178,17 +179,17 @@ func TestProvides(t *testing.T) {
}
}()
_
,
err
:=
dhts
[
0
]
.
Connect
(
peers
[
1
])
_
,
err
:=
dhts
[
0
]
.
Connect
(
context
.
Background
(),
peers
[
1
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
_
,
err
=
dhts
[
1
]
.
Connect
(
peers
[
2
])
_
,
err
=
dhts
[
1
]
.
Connect
(
context
.
Background
(),
peers
[
2
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
_
,
err
=
dhts
[
1
]
.
Connect
(
peers
[
3
])
_
,
err
=
dhts
[
1
]
.
Connect
(
context
.
Background
(),
peers
[
3
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -203,7 +204,7 @@ func TestProvides(t *testing.T) {
t
.
Fatal
(
err
)
}
err
=
dhts
[
3
]
.
Provide
(
u
.
Key
(
"hello"
))
err
=
dhts
[
3
]
.
Provide
(
context
.
Background
(),
u
.
Key
(
"hello"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -234,17 +235,17 @@ func TestProvidesAsync(t *testing.T) {
}
}()
_
,
err
:=
dhts
[
0
]
.
Connect
(
peers
[
1
])
_
,
err
:=
dhts
[
0
]
.
Connect
(
context
.
Background
(),
peers
[
1
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
_
,
err
=
dhts
[
1
]
.
Connect
(
peers
[
2
])
_
,
err
=
dhts
[
1
]
.
Connect
(
context
.
Background
(),
peers
[
2
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
_
,
err
=
dhts
[
1
]
.
Connect
(
peers
[
3
])
_
,
err
=
dhts
[
1
]
.
Connect
(
context
.
Background
(),
peers
[
3
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -259,7 +260,7 @@ func TestProvidesAsync(t *testing.T) {
t
.
Fatal
(
err
)
}
err
=
dhts
[
3
]
.
Provide
(
u
.
Key
(
"hello"
))
err
=
dhts
[
3
]
.
Provide
(
context
.
Background
(),
u
.
Key
(
"hello"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -290,17 +291,17 @@ func TestLayeredGet(t *testing.T) {
}
}()
_
,
err
:=
dhts
[
0
]
.
Connect
(
peers
[
1
])
_
,
err
:=
dhts
[
0
]
.
Connect
(
context
.
Background
(),
peers
[
1
])
if
err
!=
nil
{
t
.
Fatalf
(
"Failed to connect: %s"
,
err
)
}
_
,
err
=
dhts
[
1
]
.
Connect
(
peers
[
2
])
_
,
err
=
dhts
[
1
]
.
Connect
(
context
.
Background
(),
peers
[
2
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
_
,
err
=
dhts
[
1
]
.
Connect
(
peers
[
3
])
_
,
err
=
dhts
[
1
]
.
Connect
(
context
.
Background
(),
peers
[
3
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -310,7 +311,7 @@ func TestLayeredGet(t *testing.T) {
t
.
Fatal
(
err
)
}
err
=
dhts
[
3
]
.
Provide
(
u
.
Key
(
"hello"
))
err
=
dhts
[
3
]
.
Provide
(
context
.
Background
(),
u
.
Key
(
"hello"
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -342,17 +343,17 @@ func TestFindPeer(t *testing.T) {
}
}()
_
,
err
:=
dhts
[
0
]
.
Connect
(
peers
[
1
])
_
,
err
:=
dhts
[
0
]
.
Connect
(
context
.
Background
(),
peers
[
1
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
_
,
err
=
dhts
[
1
]
.
Connect
(
peers
[
2
])
_
,
err
=
dhts
[
1
]
.
Connect
(
context
.
Background
(),
peers
[
2
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
_
,
err
=
dhts
[
1
]
.
Connect
(
peers
[
3
])
_
,
err
=
dhts
[
1
]
.
Connect
(
context
.
Background
(),
peers
[
3
])
if
err
!=
nil
{
t
.
Fatal
(
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