Replace a Few IntFlags with Uint64Flags (#9959)

* use uints instead of ints

* fix method

* fix

* fix

* builds

* deepsource

* deep source
This commit is contained in:
Raul Jordan
2021-12-01 18:34:53 -05:00
committed by GitHub
parent ab60b1c7b2
commit 790bf03123
25 changed files with 57 additions and 58 deletions

View File

@@ -372,7 +372,7 @@ func TestBlocksFetcher_RoundRobin(t *testing.T) {
}
func TestBlocksFetcher_scheduleRequest(t *testing.T) {
blockBatchLimit := uint64(flags.Get().BlockBatchLimit)
blockBatchLimit := flags.Get().BlockBatchLimit
t.Run("context cancellation", func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
fetcher := newBlocksFetcher(ctx, &blocksFetcherConfig{})
@@ -426,7 +426,7 @@ func TestBlocksFetcher_handleRequest(t *testing.T) {
})
cancel()
response := fetcher.handleRequest(ctx, 1, uint64(blockBatchLimit))
response := fetcher.handleRequest(ctx, 1, blockBatchLimit)
assert.ErrorContains(t, "context canceled", response.err)
})
@@ -441,7 +441,7 @@ func TestBlocksFetcher_handleRequest(t *testing.T) {
requestCtx, reqCancel := context.WithTimeout(context.Background(), 2*time.Second)
defer reqCancel()
go func() {
response := fetcher.handleRequest(requestCtx, 1 /* start */, uint64(blockBatchLimit) /* count */)
response := fetcher.handleRequest(requestCtx, 1 /* start */, blockBatchLimit /* count */)
select {
case <-ctx.Done():
case fetcher.fetchResponses <- response:
@@ -459,7 +459,7 @@ func TestBlocksFetcher_handleRequest(t *testing.T) {
blocks = resp.blocks
}
}
if uint64(len(blocks)) != uint64(blockBatchLimit) {
if uint64(len(blocks)) != blockBatchLimit {
t.Errorf("incorrect number of blocks returned, expected: %v, got: %v", blockBatchLimit, len(blocks))
}
@@ -510,11 +510,11 @@ func TestBlocksFetcher_requestBeaconBlocksByRange(t *testing.T) {
req := &p2ppb.BeaconBlocksByRangeRequest{
StartSlot: 1,
Step: 1,
Count: uint64(blockBatchLimit),
Count: blockBatchLimit,
}
blocks, err := fetcher.requestBlocks(ctx, req, peerIDs[0])
assert.NoError(t, err)
assert.Equal(t, uint64(blockBatchLimit), uint64(len(blocks)), "Incorrect number of blocks returned")
assert.Equal(t, blockBatchLimit, uint64(len(blocks)), "Incorrect number of blocks returned")
// Test context cancellation.
ctx, cancel = context.WithCancel(context.Background())