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-kbucket
Commits
b797ed11
Commit
b797ed11
authored
Aug 01, 2019
by
Aarsh Shah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added a test for the failure scenario
parent
ba93cb36
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
table.go
table.go
+1
-1
table_test.go
table_test.go
+6
-0
No files found.
table.go
View file @
b797ed11
...
...
@@ -79,7 +79,7 @@ func (rt *RoutingTable) GenRandPeerID(bucketID int) (peer.ID, error) {
}
// should give up after a fixed number of attempts so we don't take up too much time/cpu
for
i
:=
0
;
i
<
2
00
;
i
++
{
for
i
:=
0
;
i
<
10
00
;
i
++
{
peerID
,
err
:=
randPeerID
()
if
err
!=
nil
{
log
.
Debugf
(
"failed to generate random peerID in bucket %d, error is %+v"
,
bucketID
,
err
)
...
...
table_test.go
View file @
b797ed11
...
...
@@ -81,6 +81,12 @@ func TestGenRandPeerID(t *testing.T) {
}
}
// test error case
peerID
,
err
:=
rt
.
GenRandPeerID
(
-
1
)
if
err
!=
ErrGenRandPeerIDFailed
||
len
(
peerID
)
!=
0
{
t
.
Fatalf
(
"should have got err ErrGenRandPeerIDFailed for bucketID -1"
)
}
}
func
TestTableCallbacks
(
t
*
testing
.
T
)
{
...
...
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