From 76c25e3a773d596911385f115de0d1f7c8e71dcf Mon Sep 17 00:00:00 2001 From: tycho garen Date: Fri, 11 Mar 2022 09:40:20 -0500 Subject: [PATCH] clean up --- internal/consensus/common_test.go | 2 +- internal/consensus/reactor_test.go | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/internal/consensus/common_test.go b/internal/consensus/common_test.go index 6517ee639..12eaa0406 100644 --- a/internal/consensus/common_test.go +++ b/internal/consensus/common_test.go @@ -908,7 +908,7 @@ func randConsensusNetWithPeers( css[i] = newStateWithConfig(ctx, t, logger.With("validator", i, "module", "consensus"), thisConfig, state, privVal, app) css[i].SetTimeoutTicker(tickerFunc()) - require.NoError(t, css[i].Start(ctx)) + css[i].updateStateFromStore(ctx) } return css, genDoc, peer0Config, func() { for _, dir := range configRootDirs { diff --git a/internal/consensus/reactor_test.go b/internal/consensus/reactor_test.go index 773b20bde..970cc06df 100644 --- a/internal/consensus/reactor_test.go +++ b/internal/consensus/reactor_test.go @@ -276,15 +276,22 @@ func waitForAndValidateBlockWithTx( var wg sync.WaitGroup for i := 0; i < n; i++ { wg.Add(1) - go func(j int) { - defer wg.Done() - fn(j) - }(i) + go func(j int) { defer wg.Done(); fn(j) }(i) } + sig := make(chan struct{}) + go func() { defer close(sig); wg.Wait() }() - wg.Wait() - if err := ctx.Err(); errors.Is(err, context.DeadlineExceeded) { - t.Fatal("encountered timeout") + select { + case <-sig: + return + case <-ctx.Done(): + err := ctx.Err() + switch { + case errors.Is(err, context.DeadlineExceeded): + t.Fatal("encountered timeout") + case errors.Is(err, context.Canceled): + t.Fatal("operation aborted") + } } }