From e676869f0c5b73986a7a055a4c744f02207a38ac Mon Sep 17 00:00:00 2001 From: tycho garen Date: Thu, 10 Mar 2022 16:39:12 -0500 Subject: [PATCH] fix lint --- internal/consensus/byzantine_test.go | 4 +++- internal/consensus/common_test.go | 15 ++++++++++++--- internal/consensus/pbts_test.go | 4 +++- internal/consensus/reactor_test.go | 5 +++-- internal/consensus/replay_file.go | 4 +++- internal/consensus/state_test.go | 18 ++++++++++++++---- internal/consensus/wal_generator.go | 5 ++++- 7 files changed, 42 insertions(+), 13 deletions(-) diff --git a/internal/consensus/byzantine_test.go b/internal/consensus/byzantine_test.go index 600bb1a1c..42b368efb 100644 --- a/internal/consensus/byzantine_test.go +++ b/internal/consensus/byzantine_test.go @@ -97,7 +97,9 @@ func TestByzantinePrevoteEquivocation(t *testing.T) { require.NoError(t, err) // set private validator pv := privVals[i] - cs.updateStateFromStore(ctx) + if err := cs.updateStateFromStore(ctx); err != nil { + t.Fatal(err) + } cs.SetPrivValidator(ctx, pv) cs.SetTimeoutTicker(tickerFunc()) diff --git a/internal/consensus/common_test.go b/internal/consensus/common_test.go index 8a2d8c68b..7aa2b5d81 100644 --- a/internal/consensus/common_test.go +++ b/internal/consensus/common_test.go @@ -499,7 +499,9 @@ func newStateWithConfigAndBlockStore( if err != nil { t.Fatal(err) } - cs.updateStateFromStore(ctx) + if err := cs.updateStateFromStore(ctx); err != nil { + t.Fatal(err) + } cs.SetPrivValidator(ctx, pv) return cs @@ -549,7 +551,10 @@ func makeState(ctx context.Context, t *testing.T, args makeStateArgs) (*State, [ vss := make([]*validatorStub, validators) cs := newState(ctx, t, args.logger, state, privVals[0], app) - cs.updateStateFromStore(ctx) + + if err := cs.updateStateFromStore(ctx); err != nil { + t.Fatal(err) + } for i := 0; i < validators; i++ { vss[i] = newValidatorStub(privVals[i], int32(i)) @@ -819,7 +824,11 @@ func makeConsensusState( l := logger.With("validator", i, "module", "consensus") css[i] = newStateWithConfigAndBlockStore(ctx, t, l, thisConfig, state, privVals[i], app, blockStore) - css[i].updateStateFromStore(ctx) + + if err := css[i].updateStateFromStore(ctx); err != nil { + t.Fatal(err) + } + css[i].SetTimeoutTicker(tickerFunc()) } diff --git a/internal/consensus/pbts_test.go b/internal/consensus/pbts_test.go index dc31b5c68..7cb7f8126 100644 --- a/internal/consensus/pbts_test.go +++ b/internal/consensus/pbts_test.go @@ -115,7 +115,9 @@ func newPBTSTestHarness(ctx context.Context, t *testing.T, tc pbtsTestConfigurat Validators: validators, }) cs := newState(ctx, t, log.TestingLogger(), state, privVals[0], kvstore.NewApplication()) - cs.updateStateFromStore(ctx) + if err := cs.updateStateFromStore(ctx); err != nil { + t.Fatal(err) + } vss := make([]*validatorStub, validators) for i := 0; i < validators; i++ { vss[i] = newValidatorStub(privVals[i], int32(i)) diff --git a/internal/consensus/reactor_test.go b/internal/consensus/reactor_test.go index 020155515..1a6b40b1b 100644 --- a/internal/consensus/reactor_test.go +++ b/internal/consensus/reactor_test.go @@ -525,7 +525,9 @@ func TestReactorWithEvidence(t *testing.T) { cs.SetPrivValidator(ctx, pv) cs.SetTimeoutTicker(tickerFunc()) - cs.updateStateFromStore(ctx) + if err := cs.updateStateFromStore(ctx); err != nil { + t.Fatal(err) + } states[i] = cs } @@ -533,7 +535,6 @@ func TestReactorWithEvidence(t *testing.T) { rts := setup(ctx, t, n, states, 100) // buffer must be large enough to not deadlock for _, reactor := range rts.reactors { - reactor.state.updateStateFromStore(ctx) reactor.SwitchToConsensus(ctx, reactor.state.state, false) } diff --git a/internal/consensus/replay_file.go b/internal/consensus/replay_file.go index 737ffb66e..1c241f463 100644 --- a/internal/consensus/replay_file.go +++ b/internal/consensus/replay_file.go @@ -150,7 +150,9 @@ func (pb *playback) replayReset(ctx context.Context, count int, newStepSub event if err != nil { return err } - newCS.updateStateFromStore(ctx) + if err := newCS.updateStateFromStore(ctx); err != nil { + return err + } newCS.startForReplay() if err := pb.fp.Close(); err != nil { diff --git a/internal/consensus/state_test.go b/internal/consensus/state_test.go index f61d45472..68d982813 100644 --- a/internal/consensus/state_test.go +++ b/internal/consensus/state_test.go @@ -178,7 +178,9 @@ func TestStateEnterProposeYesPrivValidator(t *testing.T) { defer cancel() cs, _ := makeState(ctx, t, makeStateArgs{config: config, validators: 1}) - cs.updateStateFromStore(ctx) + if err := cs.updateStateFromStore(ctx); err != nil { + t.Fatal(err) + } height, round := cs.Height, cs.Round // Listen for propose timeout event @@ -707,7 +709,9 @@ func TestStateLock_POLUpdateLock(t *testing.T) { // Generate a new proposal block. cs2 := newState(ctx, t, logger, cs1.state, vs2, kvstore.NewApplication()) - cs2.updateStateFromStore(ctx) + if err := cs2.updateStateFromStore(ctx); err != nil { + t.Fatal(err) + } require.NoError(t, err) propR1, propBlockR1 := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round) @@ -1001,7 +1005,10 @@ func TestStateLock_PrevoteNilWhenLockedAndDifferentProposal(t *testing.T) { incrementRound(vs2, vs3, vs4) round++ cs2 := newState(ctx, t, logger, cs1.state, vs2, kvstore.NewApplication()) - cs2.updateStateFromStore(ctx) + if err := cs2.updateStateFromStore(ctx); err != nil { + t.Fatal(err) + } + propR1, propBlockR1 := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round) propBlockR1Parts, err := propBlockR1.MakePartSet(types.BlockPartSizeBytes) require.NoError(t, err) @@ -1109,7 +1116,10 @@ func TestStateLock_POLDoesNotUnlock(t *testing.T) { round++ incrementRound(vs2, vs3, vs4) cs2 := newState(ctx, t, logger, cs1.state, vs2, kvstore.NewApplication()) - cs2.updateStateFromStore(ctx) + if err := cs2.updateStateFromStore(ctx); err != nil { + t.Fatal(err) + } + prop, propBlock := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round) propBlockParts, err := propBlock.MakePartSet(types.BlockPartSizeBytes) require.NoError(t, err) diff --git a/internal/consensus/wal_generator.go b/internal/consensus/wal_generator.go index 2fed612e1..ce08bf089 100644 --- a/internal/consensus/wal_generator.go +++ b/internal/consensus/wal_generator.go @@ -87,7 +87,10 @@ func WALGenerateNBlocks(ctx context.Context, t *testing.T, logger log.Logger, wr if err != nil { t.Fatal(err) } - consensusState.updateStateFromStore(ctx) + + if err := consensusState.updateStateFromStore(ctx); err != nil { + t.Fatal(err) + } if privValidator != nil && privValidator != (*privval.FilePV)(nil) { consensusState.SetPrivValidator(ctx, privValidator)