Commit 361b5342 authored by Sebastian Stammler's avatar Sebastian Stammler Committed by GitHub

op-service/sources: Fix receipts fetcher concurrency test (#12554)

It got effectively disabled in #12533 and while investigating a fix,
I realized that its original assertion was too strict. The new assertion
adds as a factor the number of batch calls that each individual fetcher
would make if no batch calls were shared.
parent d3be0de2
...@@ -97,7 +97,8 @@ func TestBasicRPCReceiptsFetcher_Reuse(t *testing.T) { ...@@ -97,7 +97,8 @@ func TestBasicRPCReceiptsFetcher_Reuse(t *testing.T) {
func TestBasicRPCReceiptsFetcher_Concurrency(t *testing.T) { func TestBasicRPCReceiptsFetcher_Concurrency(t *testing.T) {
require := require.New(t) require := require.New(t)
const numFetchers = 32 const numFetchers = 32
batchSize, txCount := 4, uint64(18) // 4.5 * 4 const batchSize, txCount = 4, 16
const numBatchCalls = txCount / batchSize
block, receipts := randomRpcBlockAndReceipts(rand.New(rand.NewSource(123)), txCount) block, receipts := randomRpcBlockAndReceipts(rand.New(rand.NewSource(123)), txCount)
recMap := make(map[common.Hash]*types.Receipt, len(receipts)) recMap := make(map[common.Hash]*types.Receipt, len(receipts))
for _, rec := range receipts { for _, rec := range receipts {
...@@ -128,6 +129,7 @@ func TestBasicRPCReceiptsFetcher_Concurrency(t *testing.T) { ...@@ -128,6 +129,7 @@ func TestBasicRPCReceiptsFetcher_Concurrency(t *testing.T) {
mrpc.AssertExpectations(t) mrpc.AssertExpectations(t)
finalNumCalls := int(numCalls.Load()) finalNumCalls := int(numCalls.Load())
require.NotZero(finalNumCalls, "BatchCallContext should have been called.") require.NotZero(finalNumCalls, "BatchCallContext should have been called.")
require.Less(finalNumCalls, numFetchers*numBatchCalls, "Some IterativeBatchCalls should have been shared.")
} }
func runConcurrentFetchingTest(t *testing.T, rp ReceiptsProvider, numFetchers int, receipts types.Receipts, block *RPCBlock) { func runConcurrentFetchingTest(t *testing.T, rp ReceiptsProvider, numFetchers int, receipts types.Receipts, block *RPCBlock) {
......
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