github.com/ethersphere/bee/v2@v2.2.0/pkg/feeds/epochs/lookup_test.go (about)

     1  // Copyright 2021 The Swarm Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package epochs_test
     6  
     7  import (
     8  	"testing"
     9  
    10  	"github.com/ethersphere/bee/v2/pkg/crypto"
    11  	"github.com/ethersphere/bee/v2/pkg/feeds"
    12  	"github.com/ethersphere/bee/v2/pkg/feeds/epochs"
    13  	feedstesting "github.com/ethersphere/bee/v2/pkg/feeds/testing"
    14  	storage "github.com/ethersphere/bee/v2/pkg/storage"
    15  )
    16  
    17  func TestFinder_FLAKY(t *testing.T) {
    18  	t.Parallel()
    19  
    20  	testf := func(t *testing.T, finderf func(storage.Getter, *feeds.Feed) feeds.Lookup, updaterf func(putter storage.Putter, signer crypto.Signer, topic []byte) (feeds.Updater, error)) {
    21  		t.Helper()
    22  
    23  		t.Run("basic", func(t *testing.T) {
    24  			feedstesting.TestFinderBasic(t, finderf, updaterf)
    25  		})
    26  		i := int64(0)
    27  		nextf := func() (bool, int64) {
    28  			defer func() { i++ }()
    29  			return i < 50, i
    30  		}
    31  		t.Run("fixed", func(t *testing.T) {
    32  			feedstesting.TestFinderFixIntervals(t, nextf, finderf, updaterf)
    33  		})
    34  		t.Run("random", func(t *testing.T) {
    35  			feedstesting.TestFinderRandomIntervals(t, finderf, updaterf)
    36  		})
    37  	}
    38  	t.Run("sync", func(t *testing.T) {
    39  		t.Parallel()
    40  		testf(t, epochs.NewFinder, epochs.NewUpdater)
    41  	})
    42  	t.Run("async", func(t *testing.T) {
    43  		t.Parallel()
    44  		testf(t, epochs.NewAsyncFinder, epochs.NewUpdater)
    45  	})
    46  }