Commit 35ef587b authored by Andreas Bigger's avatar Andreas Bigger

peer params testing :test_tube:

parent da2644c9
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"sort" "sort"
"testing" "testing"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )
...@@ -22,6 +23,11 @@ func TestPeerParams(t *testing.T) { ...@@ -22,6 +23,11 @@ func TestPeerParams(t *testing.T) {
suite.Run(t, new(PeerParamsTestSuite)) suite.Run(t, new(PeerParamsTestSuite))
} }
// TestPeerScoreConstants validates the peer score constants.
func (testSuite *PeerParamsTestSuite) TestPeerScoreConstants() {
testSuite.Equal(0.01, DecayToZero)
}
// TestAvailablePeerScoreParams validates the available peer score parameters. // TestAvailablePeerScoreParams validates the available peer score parameters.
func (testSuite *PeerParamsTestSuite) TestAvailablePeerScoreParams() { func (testSuite *PeerParamsTestSuite) TestAvailablePeerScoreParams() {
available := AvailablePeerScoreParams() available := AvailablePeerScoreParams()
...@@ -29,3 +35,19 @@ func (testSuite *PeerParamsTestSuite) TestAvailablePeerScoreParams() { ...@@ -29,3 +35,19 @@ func (testSuite *PeerParamsTestSuite) TestAvailablePeerScoreParams() {
expected := []string{"light", "none"} expected := []string{"light", "none"}
testSuite.Equal(expected, available) testSuite.Equal(expected, available)
} }
// TestNewPeerScoreThresholds validates the peer score thresholds.
//
// This is tested to ensure that the thresholds are not modified and missed in review.
func (testSuite *PeerParamsTestSuite) TestNewPeerScoreThresholds() {
thresholds := NewPeerScoreThresholds()
expected := pubsub.PeerScoreThresholds{
SkipAtomicValidation: false,
GossipThreshold: -10,
PublishThreshold: -40,
GraylistThreshold: -40,
AcceptPXThreshold: 20,
OpportunisticGraftThreshold: 0.05,
}
testSuite.Equal(expected, thresholds)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment