diff --git a/plugin/evm/block_builder_test.go b/plugin/evm/block_builder_test.go deleted file mode 100644 index 04739ba2aa..0000000000 --- a/plugin/evm/block_builder_test.go +++ /dev/null @@ -1,73 +0,0 @@ -// (c) 2019-2021, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package evm - -import ( - "sync" - "testing" - "time" - - "github.com/ava-labs/subnet-evm/params" - "github.com/ava-labs/subnet-evm/utils" -) - -func attemptAwait(t *testing.T, wg *sync.WaitGroup, delay time.Duration) { - ticker := make(chan struct{}) - - // Wait for [wg] and then close [ticket] to indicate that - // the wait group has finished. - go func() { - wg.Wait() - close(ticker) - }() - - select { - case <-time.After(delay): - t.Fatal("Timed out waiting for wait group to complete") - case <-ticker: - // The wait group completed without issue - } -} - -func TestBlockBuilderShutsDown(t *testing.T) { - shutdownChan := make(chan struct{}) - wg := &sync.WaitGroup{} - config := *params.TestChainConfig - - config.SubnetEVMTimestamp = utils.TimeToNewUint64(time.Now().Add(time.Hour)) - - builder := &blockBuilder{ - ctx: utils.TestSnowContext(), - chainConfig: &config, - shutdownChan: shutdownChan, - shutdownWg: wg, - } - - builder.handleBlockBuilding() - // Close [shutdownChan] and ensure that the wait group finishes in a reasonable - // amount of time. - close(shutdownChan) - attemptAwait(t, wg, 5*time.Second) -} - -func TestBlockBuilderSkipsTimerInitialization(t *testing.T) { - shutdownChan := make(chan struct{}) - wg := &sync.WaitGroup{} - builder := &blockBuilder{ - ctx: utils.TestSnowContext(), - chainConfig: params.TestChainConfig, - shutdownChan: shutdownChan, - shutdownWg: wg, - } - - builder.handleBlockBuilding() - - if builder.buildBlockTimer == nil { - t.Fatal("expected block timer to be non-nil") - } - - // The wait group should finish immediately since no goroutine - // should be created when all prices should be set from the start - attemptAwait(t, wg, time.Millisecond) -} diff --git a/plugin/evm/gossipper_test.go b/plugin/evm/gossipper_test.go index 68bcbd8c1a..27b482b60b 100644 --- a/plugin/evm/gossipper_test.go +++ b/plugin/evm/gossipper_test.go @@ -424,3 +424,21 @@ func TestMempoolTxsPriorityRegossip(t *testing.T) { assert.Len(queued, 10, "unexpected length of queued txs") assert.ElementsMatch(txs, queued) } + +func attemptAwait(t *testing.T, wg *sync.WaitGroup, delay time.Duration) { + ticker := make(chan struct{}) + + // Wait for [wg] and then close [ticket] to indicate that + // the wait group has finished. + go func() { + wg.Wait() + close(ticker) + }() + + select { + case <-time.After(delay): + t.Fatal("Timed out waiting for wait group to complete") + case <-ticker: + // The wait group completed without issue + } +}