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-pubsub
Commits
0832791d
Commit
0832791d
authored
May 01, 2020
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extend behaviour penalty test to ensure coverage
parent
63239829
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
score_test.go
score_test.go
+22
-2
No files found.
score_test.go
View file @
0832791d
...
...
@@ -749,14 +749,34 @@ func TestScoreBehaviourPenalty(t *testing.T) {
}
peerA
:=
peer
.
ID
(
"A"
)
ps
:=
newPeerScore
(
params
)
ps
.
AddPeer
(
peerA
,
"myproto"
)
var
ps
*
peerScore
// first check AddPenalty on a nil peerScore
ps
.
AddPenalty
(
peerA
,
1
)
aScore
:=
ps
.
Score
(
peerA
)
if
aScore
!=
0
{
t
.
Errorf
(
"expected peer score to be 0, got %f"
,
aScore
)
}
// instantiate the peerScore
ps
=
newPeerScore
(
params
)
// next AddPenalty on a non-existent peer
ps
.
AddPenalty
(
peerA
,
1
)
aScore
=
ps
.
Score
(
peerA
)
if
aScore
!=
0
{
t
.
Errorf
(
"expected peer score to be 0, got %f"
,
aScore
)
}
// add the peer and test penalties
ps
.
AddPeer
(
peerA
,
"myproto"
)
aScore
=
ps
.
Score
(
peerA
)
if
aScore
!=
0
{
t
.
Errorf
(
"expected peer score to be 0, got %f"
,
aScore
)
}
ps
.
AddPenalty
(
peerA
,
1
)
aScore
=
ps
.
Score
(
peerA
)
if
aScore
!=
-
1
{
...
...
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