Browse Source

clean up

pull/8127/head
tycho garen 3 years ago
committed by M. J. Fromberger
parent
commit
76c25e3a77
2 changed files with 15 additions and 8 deletions
  1. +1
    -1
      internal/consensus/common_test.go
  2. +14
    -7
      internal/consensus/reactor_test.go

+ 1
- 1
internal/consensus/common_test.go View File

@ -908,7 +908,7 @@ func randConsensusNetWithPeers(
css[i] = newStateWithConfig(ctx, t, logger.With("validator", i, "module", "consensus"), thisConfig, state, privVal, app) css[i] = newStateWithConfig(ctx, t, logger.With("validator", i, "module", "consensus"), thisConfig, state, privVal, app)
css[i].SetTimeoutTicker(tickerFunc()) css[i].SetTimeoutTicker(tickerFunc())
require.NoError(t, css[i].Start(ctx))
css[i].updateStateFromStore(ctx)
} }
return css, genDoc, peer0Config, func() { return css, genDoc, peer0Config, func() {
for _, dir := range configRootDirs { for _, dir := range configRootDirs {


+ 14
- 7
internal/consensus/reactor_test.go View File

@ -276,15 +276,22 @@ func waitForAndValidateBlockWithTx(
var wg sync.WaitGroup var wg sync.WaitGroup
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
wg.Add(1) 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")
}
} }
} }


Loading…
Cancel
Save