Add one more assertion to fetcher test (#7733)

This commit is contained in:
Victor Farazdagi
2020-11-05 22:48:49 +03:00
committed by GitHub
parent f6cbfd5e27
commit 6e21b7a623

View File

@@ -2,6 +2,7 @@ package initialsync
import (
"context"
"fmt"
"sort"
"sync"
"testing"
@@ -25,6 +26,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/sirupsen/logrus"
logTest "github.com/sirupsen/logrus/hooks/test"
)
func TestBlocksFetcher_InitStartStop(t *testing.T) {
@@ -545,6 +547,7 @@ func TestBlocksFetcher_RequestBlocksRateLimitingLocks(t *testing.T) {
fetcher := newBlocksFetcher(ctx, &blocksFetcherConfig{p2p: p1})
fetcher.rateLimiter = leakybucket.NewCollector(float64(req.Count), int64(req.Count*burstFactor), false)
hook := logTest.NewGlobal()
wg := new(sync.WaitGroup)
wg.Add(1)
go func() {
@@ -581,6 +584,8 @@ func TestBlocksFetcher_RequestBlocksRateLimitingLocks(t *testing.T) {
case <-ch:
// p3 responded w/o waiting for rate limiter's lock (on which p2 spins).
}
// Make sure that p2 has been rate limited.
require.LogsContain(t, hook, fmt.Sprintf("msg=\"Slowing down for rate limit\" peer=%s", p2.PeerID()))
}
func TestBlocksFetcher_requestBlocksFromPeerReturningInvalidBlocks(t *testing.T) {