|
|
|
@@ -66,9 +66,9 @@ func TestStateProposerSelection0(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
|
newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
|
|
|
|
@@ -116,12 +116,11 @@ func TestStateProposerSelection0(t *testing.T) {
|
|
|
|
|
// Now let's do it all again, but starting from round 2 instead of 0
|
|
|
|
|
func TestStateProposerSelection2(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4) // test needs more work for more than 3 validators
|
|
|
|
|
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4) // test needs more work for more than 3 validators
|
|
|
|
|
height := cs1.Height
|
|
|
|
|
newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
|
|
|
|
|
|
|
|
|
@@ -156,11 +155,11 @@ func TestStateProposerSelection2(t *testing.T) {
|
|
|
|
|
// a non-validator should timeout into the prevote round
|
|
|
|
|
func TestStateEnterProposeNoPrivValidator(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs, _ := randState(ctx, t, config, log.TestingLogger(), 1)
|
|
|
|
|
|
|
|
|
|
cs, _ := makeState(ctx, t, config, logger, 1)
|
|
|
|
|
cs.SetPrivValidator(ctx, nil)
|
|
|
|
|
height, round := cs.Height, cs.Round
|
|
|
|
|
|
|
|
|
@@ -180,10 +179,11 @@ func TestStateEnterProposeNoPrivValidator(t *testing.T) {
|
|
|
|
|
// a validator should not timeout of the prevote round (TODO: unless the block is really big!)
|
|
|
|
|
func TestStateEnterProposeYesPrivValidator(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs, _ := randState(ctx, t, config, log.TestingLogger(), 1)
|
|
|
|
|
cs, _ := makeState(ctx, t, config, logger, 1)
|
|
|
|
|
height, round := cs.Height, cs.Round
|
|
|
|
|
|
|
|
|
|
// Listen for propose timeout event
|
|
|
|
@@ -214,10 +214,11 @@ func TestStateEnterProposeYesPrivValidator(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestStateBadProposal(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 2)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 2)
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
vs2 := vss[1]
|
|
|
|
|
|
|
|
|
@@ -284,10 +285,11 @@ func TestStateBadProposal(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestStateOversizedBlock(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 2)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 2)
|
|
|
|
|
cs1.state.ConsensusParams.Block.MaxBytes = 2000
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
vs2 := vss[1]
|
|
|
|
@@ -363,7 +365,7 @@ func TestStateFullRound1(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs, vss := randState(ctx, t, config, logger, 1)
|
|
|
|
|
cs, vss := makeState(ctx, t, config, logger, 1)
|
|
|
|
|
height, round := cs.Height, cs.Round
|
|
|
|
|
|
|
|
|
|
// NOTE: buffer capacity of 0 ensures we can validate prevote and last commit
|
|
|
|
@@ -404,10 +406,11 @@ func TestStateFullRound1(t *testing.T) {
|
|
|
|
|
// nil is proposed, so prevote and precommit nil
|
|
|
|
|
func TestStateFullRoundNil(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs, vss := randState(ctx, t, config, log.TestingLogger(), 1)
|
|
|
|
|
cs, vss := makeState(ctx, t, config, logger, 1)
|
|
|
|
|
height, round := cs.Height, cs.Round
|
|
|
|
|
|
|
|
|
|
voteCh := subscribe(ctx, t, cs.eventBus, types.EventQueryVote)
|
|
|
|
@@ -426,10 +429,11 @@ func TestStateFullRoundNil(t *testing.T) {
|
|
|
|
|
// where the first validator has to wait for votes from the second
|
|
|
|
|
func TestStateFullRound2(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 2)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 2)
|
|
|
|
|
vs2 := vss[1]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -470,10 +474,11 @@ func TestStateFullRound2(t *testing.T) {
|
|
|
|
|
// two vals take turns proposing. val1 locks on first one, precommits nil on everything else
|
|
|
|
|
func TestStateLock_NoPOL(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 2)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 2)
|
|
|
|
|
vs2 := vss[1]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -616,8 +621,7 @@ func TestStateLock_NoPOL(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
|
|
|
|
|
|
|
|
|
|
// needed so generated block is different than locked block
|
|
|
|
|
cs2, _ := randState(ctx, t, config, log.TestingLogger(), 2)
|
|
|
|
|
cs2, _ := makeState(ctx, t, config, logger, 2) // needed so generated block is different than locked block
|
|
|
|
|
// before we time out into new round, set next proposal block
|
|
|
|
|
prop, propBlock := decideProposal(ctx, t, cs2, vs2, vs2.Height, vs2.Round+1)
|
|
|
|
|
if prop == nil || propBlock == nil {
|
|
|
|
@@ -684,7 +688,7 @@ func TestStateLock_POLUpdateLock(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, logger, 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -788,8 +792,9 @@ func TestStateLock_POLRelock(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -887,8 +892,9 @@ func TestStateLock_PrevoteNilWhenLockedAndMissProposal(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -975,7 +981,7 @@ func TestStateLock_PrevoteNilWhenLockedAndDifferentProposal(t *testing.T) {
|
|
|
|
|
state.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, logger, 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -1076,7 +1082,7 @@ func TestStateLock_POLDoesNotUnlock(t *testing.T) {
|
|
|
|
|
state.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -1212,8 +1218,7 @@ func TestStateLock_MissingProposalWhenPOLSeenDoesNotUpdateLock(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, logger, 4)
|
|
|
|
|
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -1300,8 +1305,9 @@ func TestStateLock_DoesNotLockOnOldProposal(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -1377,7 +1383,7 @@ func TestStateLock_POLSafety1(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -1501,7 +1507,7 @@ func TestStateLock_POLSafety2(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, logger, 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -1601,7 +1607,7 @@ func TestState_PrevotePOLFromPreviousRound(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, logger, 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -1738,11 +1744,12 @@ func TestState_PrevotePOLFromPreviousRound(t *testing.T) {
|
|
|
|
|
// What we want:
|
|
|
|
|
// P0 proposes B0 at R3.
|
|
|
|
|
func TestProposeValidBlock(t *testing.T) {
|
|
|
|
|
cfg := configSetup(t)
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, cfg, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -1772,7 +1779,7 @@ func TestProposeValidBlock(t *testing.T) {
|
|
|
|
|
// the others sign a polka
|
|
|
|
|
bps, err := propBlock.MakePartSet(partSize)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
signAddVotes(ctx, t, cfg, cs1, tmproto.PrevoteType,
|
|
|
|
|
signAddVotes(ctx, t, config, cs1, tmproto.PrevoteType,
|
|
|
|
|
propBlockHash, bps.Header(), vs2,
|
|
|
|
|
vs3, vs4)
|
|
|
|
|
|
|
|
|
@@ -1781,7 +1788,7 @@ func TestProposeValidBlock(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
validatePrecommit(ctx, t, cs1, round, round, vss[0], propBlockHash, propBlockHash)
|
|
|
|
|
|
|
|
|
|
signAddVotes(ctx, t, cfg, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
|
|
|
|
|
signAddVotes(ctx, t, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
|
|
|
|
|
|
|
|
|
|
ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds())
|
|
|
|
|
|
|
|
|
@@ -1798,7 +1805,7 @@ func TestProposeValidBlock(t *testing.T) {
|
|
|
|
|
ensurePrevote(t, voteCh, height, round)
|
|
|
|
|
validatePrevote(ctx, t, cs1, round, vss[0], nil)
|
|
|
|
|
|
|
|
|
|
signAddVotes(ctx, t, cfg, cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
|
|
|
|
|
signAddVotes(ctx, t, config, cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
|
|
|
|
|
|
|
|
|
|
ensurePrecommit(t, voteCh, height, round)
|
|
|
|
|
// we should have precommitted nil during this round because we received
|
|
|
|
@@ -1808,7 +1815,7 @@ func TestProposeValidBlock(t *testing.T) {
|
|
|
|
|
incrementRound(vs2, vs3, vs4)
|
|
|
|
|
incrementRound(vs2, vs3, vs4)
|
|
|
|
|
|
|
|
|
|
signAddVotes(ctx, t, cfg, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
|
|
|
|
|
signAddVotes(ctx, t, config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4)
|
|
|
|
|
|
|
|
|
|
round += 2 // increment by multiple rounds
|
|
|
|
|
|
|
|
|
@@ -1833,11 +1840,12 @@ func TestProposeValidBlock(t *testing.T) {
|
|
|
|
|
// What we want:
|
|
|
|
|
// P0 miss to lock B but set valid block to B after receiving delayed prevote.
|
|
|
|
|
func TestSetValidBlockOnDelayedPrevote(t *testing.T) {
|
|
|
|
|
cfg := configSetup(t)
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, cfg, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -1867,10 +1875,10 @@ func TestSetValidBlockOnDelayedPrevote(t *testing.T) {
|
|
|
|
|
validatePrevote(ctx, t, cs1, round, vss[0], propBlockHash)
|
|
|
|
|
|
|
|
|
|
// vs2 send prevote for propBlock
|
|
|
|
|
signAddVotes(ctx, t, cfg, cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2)
|
|
|
|
|
signAddVotes(ctx, t, config, cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2)
|
|
|
|
|
|
|
|
|
|
// vs3 send prevote nil
|
|
|
|
|
signAddVotes(ctx, t, cfg, cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs3)
|
|
|
|
|
signAddVotes(ctx, t, config, cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs3)
|
|
|
|
|
|
|
|
|
|
ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds())
|
|
|
|
|
|
|
|
|
@@ -1885,7 +1893,7 @@ func TestSetValidBlockOnDelayedPrevote(t *testing.T) {
|
|
|
|
|
assert.True(t, rs.ValidRound == -1)
|
|
|
|
|
|
|
|
|
|
// vs2 send (delayed) prevote for propBlock
|
|
|
|
|
signAddVotes(ctx, t, cfg, cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs4)
|
|
|
|
|
signAddVotes(ctx, t, config, cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs4)
|
|
|
|
|
|
|
|
|
|
ensureNewValidBlock(t, validBlockCh, height, round)
|
|
|
|
|
|
|
|
|
@@ -1901,10 +1909,11 @@ func TestSetValidBlockOnDelayedPrevote(t *testing.T) {
|
|
|
|
|
// receiving delayed Block Proposal.
|
|
|
|
|
func TestSetValidBlockOnDelayedProposal(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -1961,12 +1970,12 @@ func TestSetValidBlockOnDelayedProposal(t *testing.T) {
|
|
|
|
|
// What we want:
|
|
|
|
|
// P0 waits for timeoutPrecommit before starting next round
|
|
|
|
|
func TestWaitingTimeoutOnNilPolka(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -1988,10 +1997,11 @@ func TestWaitingTimeoutOnNilPolka(t *testing.T) {
|
|
|
|
|
// P0 waits for timeoutPropose in the next round before entering prevote
|
|
|
|
|
func TestWaitingTimeoutProposeOnNewRound(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -2028,10 +2038,11 @@ func TestWaitingTimeoutProposeOnNewRound(t *testing.T) {
|
|
|
|
|
// P0 jump to higher round, precommit and start precommit wait
|
|
|
|
|
func TestRoundSkipOnNilPolkaFromHigherRound(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
@@ -2068,11 +2079,11 @@ func TestRoundSkipOnNilPolkaFromHigherRound(t *testing.T) {
|
|
|
|
|
// P0 wait for timeoutPropose to expire before sending prevote.
|
|
|
|
|
func TestWaitTimeoutProposeOnNilPolkaForTheCurrentRound(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, int32(1)
|
|
|
|
|
|
|
|
|
@@ -2100,10 +2111,11 @@ func TestWaitTimeoutProposeOnNilPolkaForTheCurrentRound(t *testing.T) {
|
|
|
|
|
// P0 emit NewValidBlock event upon receiving 2/3+ Precommit for B but hasn't received block B yet
|
|
|
|
|
func TestEmitNewValidBlockEventOnCommitWithoutBlock(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, int32(1)
|
|
|
|
|
|
|
|
|
@@ -2139,10 +2151,11 @@ func TestEmitNewValidBlockEventOnCommitWithoutBlock(t *testing.T) {
|
|
|
|
|
// After receiving block, it executes block and moves to the next height.
|
|
|
|
|
func TestCommitFromPreviousRound(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, int32(1)
|
|
|
|
|
|
|
|
|
@@ -2197,11 +2210,12 @@ func (n *fakeTxNotifier) Notify() {
|
|
|
|
|
// start of the next round
|
|
|
|
|
func TestStartNextHeightCorrectlyAfterTimeout(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
config.Consensus.SkipTimeoutCommit = false
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
cs1.txNotifier = &fakeTxNotifier{ch: make(chan struct{})}
|
|
|
|
|
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
@@ -2262,11 +2276,12 @@ func TestStartNextHeightCorrectlyAfterTimeout(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestResetTimeoutPrecommitUponNewHeight(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
config.Consensus.SkipTimeoutCommit = false
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -2409,10 +2424,11 @@ func TestStateSlashing_Precommits(t *testing.T) {
|
|
|
|
|
// we receive a final precommit after going into next round, but others might have gone to commit already!
|
|
|
|
|
func TestStateHalt1(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss := randState(ctx, t, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss := makeState(ctx, t, config, logger, 4)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
partSize := types.BlockPartSizeBytes
|
|
|
|
@@ -2480,11 +2496,12 @@ func TestStateHalt1(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestStateOutputsBlockPartsStats(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
// create dummy peer
|
|
|
|
|
cs, _ := randState(ctx, t, config, log.TestingLogger(), 1)
|
|
|
|
|
cs, _ := makeState(ctx, t, config, logger, 1)
|
|
|
|
|
peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
@@ -2528,10 +2545,11 @@ func TestStateOutputsBlockPartsStats(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestStateOutputVoteStats(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs, vss := randState(ctx, t, config, log.TestingLogger(), 2)
|
|
|
|
|
cs, vss := makeState(ctx, t, config, logger, 2)
|
|
|
|
|
// create dummy peer
|
|
|
|
|
peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
@@ -2566,10 +2584,11 @@ func TestStateOutputVoteStats(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
func TestSignSameVoteTwice(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
_, vss := randState(ctx, t, config, log.TestingLogger(), 2)
|
|
|
|
|
_, vss := makeState(ctx, t, config, logger, 2)
|
|
|
|
|
|
|
|
|
|
randBytes := tmrand.Bytes(tmhash.Size)
|
|
|
|
|
|
|
|
|
|