mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
4de0b9fe69
* refactors redundant part of varname * introduces score_block_providers * Merge branch 'master' into init-sync-peer-scoring-slow-peers * gazelle * adds comment * Merge branch 'master' into init-sync-peer-scoring-slow-peers * removes redundant checks * add block provider decay test * Merge branch 'master' into init-sync-peer-scoring-slow-peers * adds case * penalize inactive peers * adds scorebadresponses test * inroduces no-activity penalty * gazelle * gofmt * Merge branch 'master' into init-sync-peer-scoring-slow-peers * expanded tests * implement SortBlockProviders * change -> update * updates block fetcher peer filter * fixes test * allows to keep track of peer id * updates scoring coefficients * fixes test * block fetcher update * Merge branch 'master' into init-sync-peer-scoring-slow-peers * disables empty batch penalty * Merge branch 'master' into init-sync-peer-scoring-slow-peers * Merge branch 'master' into init-sync-peer-scoring-slow-peers * removes outdated code * update filterPeers * gazelle * updates var * revert changes to var name * updates blocks_fetcher * minor fix to import name * Merge branch 'master' into init-sync-peer-scoring-slow-peers * add max processed blocks cap * impoves scoring of stale peers * Merge branch 'master' into init-sync-peer-scoring-slow-peers * fixes test * adds weight sorting to scored peers * return pid when fetching batches * updates round robin * gazelle * Merge branch 'master' into init-sync-peer-scoring-slow-peers * updates block provider decay count * go tidy * cherry pick * fixes test * go tidy * Merge branch 'peer-scorer-weighted-sorter' into init-sync-peer-scoring-slow-peers * Merge branch 'master' into init-sync-peer-scoring-slow-peers * Merge branch 'master' into init-sync-peer-scoring-slow-peers * refactors blocks fetcher: repackage methods * Merge branch 'refactor-blocks-fetcher' into init-sync-peer-scoring-slow-peers * minor fixes * Merge branch 'master' into init-sync-peer-scoring-slow-peers * Merge branch 'master' into init-sync-peer-scoring-slow-peers * allow scores in range (0;1) in weighted filter * filterScoredPeers improve test suite * puts feature behind the flag * Merge branch 'master' into init-sync-peer-scoring-slow-peers * Merge refs/heads/master into init-sync-peer-scoring-slow-peers * fixes tests * Merge branch 'init-sync-peer-scoring-slow-peers' of github.com:prysmaticlabs/prysm into init-sync-peer-scoring-slow-peers * Merge refs/heads/master into init-sync-peer-scoring-slow-peers * Merge branch 'master' into init-sync-peer-scoring-slow-peers * Merge refs/heads/master into init-sync-peer-scoring-slow-peers * Update beacon-chain/sync/initial-sync/blocks_fetcher_test.go Co-authored-by: Shay Zluf <thezluf@gmail.com> * Nishant's suggestion on peer limit variable * better explanation of non-blocking peer scoring * Shay's sugession on peer naming * Merge refs/heads/master into init-sync-peer-scoring-slow-peers * Merge refs/heads/master into init-sync-peer-scoring-slow-peers * Update beacon-chain/sync/initial-sync/blocks_fetcher.go Co-authored-by: Nishant Das <nishdas93@gmail.com> * Merge refs/heads/master into init-sync-peer-scoring-slow-peers * gofmt * Merge refs/heads/master into init-sync-peer-scoring-slow-peers * Merge refs/heads/master into init-sync-peer-scoring-slow-peers * Merge refs/heads/master into init-sync-peer-scoring-slow-peers
39 lines
892 B
Go
39 lines
892 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{
|
|
EnablePeerScorer: true,
|
|
})
|
|
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
|
|
}
|