mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
bf59530d93
* prepares peer scorer collection * decouples scoring service into separate object * updates references * renames package * removes redundant test init * gazelle * gofmt * updates comment * fix build * adds block provider scorer * score rounding factor constant (per Nishant's suggestion) * updates penalty applying * updates score block provider tests * updates scorer tests * expand test suite * get rid of penalties + counters for requested/returned blocks * removes start score * fixes provider test * fixes scorer manager tests * updates comments * moves roundScore test function * maxscore tests * improves test coverage * Update beacon-chain/p2p/peers/score_block_providers.go Co-authored-by: Nishant Das <nishdas93@gmail.com> * renames var to make it less ambigous - per Nishant's suggestion Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: Nishant Das <nishdas93@gmail.com>
37 lines
864 B
Go
37 lines
864 B
Go
package peers_test
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"math"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/flags"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
|
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
logrus.SetOutput(ioutil.Discard)
|
|
|
|
resetCfg := featureconfig.InitWithReset(&featureconfig.Flags{})
|
|
defer resetCfg()
|
|
|
|
resetFlags := flags.Get()
|
|
flags.Init(&flags.GlobalFlags{
|
|
BlockBatchLimit: 64,
|
|
BlockBatchLimitBurstFactor: 10,
|
|
})
|
|
defer func() {
|
|
flags.Init(resetFlags)
|
|
}()
|
|
os.Exit(m.Run())
|
|
}
|
|
|
|
// roundScore returns score rounded in accordance with the score manager's rounding factor.
|
|
func roundScore(score float64) float64 {
|
|
return math.Round(score*peers.ScoreRoundingFactor) / peers.ScoreRoundingFactor
|
|
}
|