|
|
@ -58,7 +58,9 @@ x * TestHalt1 - if we see +2/3 precommits after timing out into new round, we sh |
|
|
|
func TestStateProposerSelection0(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
|
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) |
|
|
@ -100,7 +102,9 @@ func TestStateProposerSelection0(t *testing.T) { |
|
|
|
func TestStateProposerSelection2(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) // test needs more work for more than 3 validators
|
|
|
|
cs1, vss, err := randState(config, 4) // test needs more work for more than 3 validators
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
height := cs1.Height |
|
|
|
newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) |
|
|
|
|
|
|
@ -139,7 +143,8 @@ func TestStateProposerSelection2(t *testing.T) { |
|
|
|
func TestStateEnterProposeNoPrivValidator(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs, _ := randState(config, 1) |
|
|
|
cs, _, err := randState(config, 1) |
|
|
|
require.NoError(t, err) |
|
|
|
cs.SetPrivValidator(nil) |
|
|
|
height, round := cs.Height, cs.Round |
|
|
|
|
|
|
@ -160,7 +165,8 @@ func TestStateEnterProposeNoPrivValidator(t *testing.T) { |
|
|
|
func TestStateEnterProposeYesPrivValidator(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs, _ := randState(config, 1) |
|
|
|
cs, _, err := randState(config, 1) |
|
|
|
require.NoError(t, err) |
|
|
|
height, round := cs.Height, cs.Round |
|
|
|
|
|
|
|
// Listen for propose timeout event
|
|
|
@ -192,7 +198,8 @@ func TestStateEnterProposeYesPrivValidator(t *testing.T) { |
|
|
|
func TestStateBadProposal(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 2) |
|
|
|
cs1, vss, err := randState(config, 2) |
|
|
|
require.NoError(t, err) |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
vs2 := vss[1] |
|
|
|
|
|
|
@ -252,7 +259,8 @@ func TestStateBadProposal(t *testing.T) { |
|
|
|
func TestStateOversizedBlock(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 2) |
|
|
|
cs1, vss, err := randState(config, 2) |
|
|
|
require.NoError(t, err) |
|
|
|
cs1.state.ConsensusParams.Block.MaxBytes = 2000 |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
vs2 := vss[1] |
|
|
@ -316,7 +324,8 @@ func TestStateOversizedBlock(t *testing.T) { |
|
|
|
func TestStateFullRound1(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs, vss := randState(config, 1) |
|
|
|
cs, vss, err := randState(config, 1) |
|
|
|
require.NoError(t, err) |
|
|
|
height, round := cs.Height, cs.Round |
|
|
|
|
|
|
|
// NOTE: buffer capacity of 0 ensures we can validate prevote and last commit
|
|
|
@ -358,7 +367,8 @@ func TestStateFullRound1(t *testing.T) { |
|
|
|
func TestStateFullRoundNil(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs, vss := randState(config, 1) |
|
|
|
cs, vss, err := randState(config, 1) |
|
|
|
require.NoError(t, err) |
|
|
|
height, round := cs.Height, cs.Round |
|
|
|
|
|
|
|
voteCh := subscribe(cs.eventBus, types.EventQueryVote) |
|
|
@ -378,7 +388,8 @@ func TestStateFullRoundNil(t *testing.T) { |
|
|
|
func TestStateFullRound2(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 2) |
|
|
|
cs1, vss, err := randState(config, 2) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2 := vss[1] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -420,7 +431,8 @@ func TestStateFullRound2(t *testing.T) { |
|
|
|
func TestStateLockNoPOL(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 2) |
|
|
|
cs1, vss, err := randState(config, 2) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2 := vss[1] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -558,7 +570,8 @@ func TestStateLockNoPOL(t *testing.T) { |
|
|
|
|
|
|
|
ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds()) |
|
|
|
|
|
|
|
cs2, _ := randState(config, 2) // needed so generated block is different than locked block
|
|
|
|
cs2, _, err := randState(config, 2) // needed so generated block is different than locked block
|
|
|
|
require.NoError(t, err) |
|
|
|
// before we time out into new round, set next proposal block
|
|
|
|
prop, propBlock := decideProposal(cs2, vs2, vs2.Height, vs2.Round+1) |
|
|
|
if prop == nil || propBlock == nil { |
|
|
@ -610,7 +623,8 @@ func TestStateLockNoPOL(t *testing.T) { |
|
|
|
func TestStateLockPOLRelock(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -654,7 +668,9 @@ func TestStateLockPOLRelock(t *testing.T) { |
|
|
|
signAddVotes(config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4) |
|
|
|
|
|
|
|
// before we timeout to the new round set the new proposal
|
|
|
|
cs2 := newState(cs1.state, vs2, kvstore.NewApplication()) |
|
|
|
cs2, err := newState(cs1.state, vs2, kvstore.NewApplication()) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
prop, propBlock := decideProposal(cs2, vs2, vs2.Height, vs2.Round+1) |
|
|
|
if prop == nil || propBlock == nil { |
|
|
|
t.Fatal("Failed to create proposal block with vs2") |
|
|
@ -709,7 +725,8 @@ func TestStateLockPOLRelock(t *testing.T) { |
|
|
|
func TestStateLockPOLUnlock(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -803,7 +820,8 @@ func TestStateLockPOLUnlock(t *testing.T) { |
|
|
|
func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -843,7 +861,8 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { |
|
|
|
signAddVotes(config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4) |
|
|
|
|
|
|
|
// before we timeout to the new round set the new proposal
|
|
|
|
cs2 := newState(cs1.state, vs2, kvstore.NewApplication()) |
|
|
|
cs2, err := newState(cs1.state, vs2, kvstore.NewApplication()) |
|
|
|
require.NoError(t, err) |
|
|
|
prop, propBlock := decideProposal(cs2, vs2, vs2.Height, vs2.Round+1) |
|
|
|
if prop == nil || propBlock == nil { |
|
|
|
t.Fatal("Failed to create proposal block with vs2") |
|
|
@ -887,7 +906,8 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { |
|
|
|
signAddVotes(config, cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4) |
|
|
|
|
|
|
|
// before we timeout to the new round set the new proposal
|
|
|
|
cs3 := newState(cs1.state, vs3, kvstore.NewApplication()) |
|
|
|
cs3, err := newState(cs1.state, vs3, kvstore.NewApplication()) |
|
|
|
require.NoError(t, err) |
|
|
|
prop, propBlock = decideProposal(cs3, vs3, vs3.Height, vs3.Round+1) |
|
|
|
if prop == nil || propBlock == nil { |
|
|
|
t.Fatal("Failed to create proposal block with vs2") |
|
|
@ -931,7 +951,8 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { |
|
|
|
func TestStateLockPOLSafety1(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -1054,7 +1075,8 @@ func TestStateLockPOLSafety1(t *testing.T) { |
|
|
|
func TestStateLockPOLSafety2(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -1153,7 +1175,8 @@ func TestStateLockPOLSafety2(t *testing.T) { |
|
|
|
func TestProposeValidBlock(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -1245,7 +1268,8 @@ func TestProposeValidBlock(t *testing.T) { |
|
|
|
func TestSetValidBlockOnDelayedPrevote(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -1309,7 +1333,8 @@ func TestSetValidBlockOnDelayedPrevote(t *testing.T) { |
|
|
|
func TestSetValidBlockOnDelayedProposal(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -1367,7 +1392,8 @@ func TestSetValidBlockOnDelayedProposal(t *testing.T) { |
|
|
|
func TestWaitingTimeoutOnNilPolka(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -1390,7 +1416,8 @@ func TestWaitingTimeoutOnNilPolka(t *testing.T) { |
|
|
|
func TestWaitingTimeoutProposeOnNewRound(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -1428,7 +1455,8 @@ func TestWaitingTimeoutProposeOnNewRound(t *testing.T) { |
|
|
|
func TestRoundSkipOnNilPolkaFromHigherRound(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
|
|
|
@ -1466,7 +1494,8 @@ func TestRoundSkipOnNilPolkaFromHigherRound(t *testing.T) { |
|
|
|
func TestWaitTimeoutProposeOnNilPolkaForTheCurrentRound(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, int32(1) |
|
|
|
|
|
|
@ -1495,7 +1524,8 @@ func TestWaitTimeoutProposeOnNilPolkaForTheCurrentRound(t *testing.T) { |
|
|
|
func TestEmitNewValidBlockEventOnCommitWithoutBlock(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, int32(1) |
|
|
|
|
|
|
@ -1531,7 +1561,8 @@ func TestEmitNewValidBlockEventOnCommitWithoutBlock(t *testing.T) { |
|
|
|
func TestCommitFromPreviousRound(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, int32(1) |
|
|
|
|
|
|
@ -1587,7 +1618,8 @@ func TestStartNextHeightCorrectlyAfterTimeout(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
config.Consensus.SkipTimeoutCommit = false |
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
cs1.txNotifier = &fakeTxNotifier{ch: make(chan struct{})} |
|
|
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
@ -1650,7 +1682,8 @@ func TestResetTimeoutPrecommitUponNewHeight(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
config.Consensus.SkipTimeoutCommit = false |
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
@ -1793,7 +1826,8 @@ func TestStateSlashingPrecommits(t *testing.T) { |
|
|
|
func TestStateHalt1(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs1, vss := randState(config, 4) |
|
|
|
cs1, vss, err := randState(config, 4) |
|
|
|
require.NoError(t, err) |
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3] |
|
|
|
height, round := cs1.Height, cs1.Round |
|
|
|
partSize := types.BlockPartSizeBytes |
|
|
@ -1863,7 +1897,8 @@ func TestStateOutputsBlockPartsStats(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
// create dummy peer
|
|
|
|
cs, _ := randState(config, 1) |
|
|
|
cs, _, err := randState(config, 1) |
|
|
|
require.NoError(t, err) |
|
|
|
peer := p2pmock.NewPeer(nil) |
|
|
|
|
|
|
|
// 1) new block part
|
|
|
@ -1907,7 +1942,8 @@ func TestStateOutputsBlockPartsStats(t *testing.T) { |
|
|
|
func TestStateOutputVoteStats(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
cs, vss := randState(config, 2) |
|
|
|
cs, vss, err := randState(config, 2) |
|
|
|
require.NoError(t, err) |
|
|
|
// create dummy peer
|
|
|
|
peer := p2pmock.NewPeer(nil) |
|
|
|
|
|
|
@ -1942,7 +1978,8 @@ func TestStateOutputVoteStats(t *testing.T) { |
|
|
|
func TestSignSameVoteTwice(t *testing.T) { |
|
|
|
config := configSetup(t) |
|
|
|
|
|
|
|
_, vss := randState(config, 2) |
|
|
|
_, vss, err := randState(config, 2) |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
randBytes := tmrand.Bytes(tmhash.Size) |
|
|
|
|
|
|
|