|
|
@ -57,7 +57,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) |
|
|
@ -99,7 +101,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) |
|
|
|
|
|
|
@ -138,7 +142,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 |
|
|
|
|
|
|
@ -159,7 +164,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
|
|
|
@ -191,7 +197,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] |
|
|
|
|
|
|
@ -251,7 +258,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] |
|
|
@ -315,7 +323,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
|
|
|
@ -357,7 +366,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) |
|
|
@ -377,7 +387,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 |
|
|
|
|
|
|
@ -419,7 +430,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 |
|
|
|
|
|
|
@ -557,7 +569,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 { |
|
|
@ -609,7 +622,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 |
|
|
|
|
|
|
@ -653,7 +667,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") |
|
|
@ -708,7 +724,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 |
|
|
|
|
|
|
@ -802,7 +819,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 |
|
|
|
|
|
|
@ -842,7 +860,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") |
|
|
@ -886,7 +905,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") |
|
|
@ -930,7 +950,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 |
|
|
|
|
|
|
@ -1053,7 +1074,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 |
|
|
|
|
|
|
@ -1152,7 +1174,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 |
|
|
|
|
|
|
@ -1244,7 +1267,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 |
|
|
|
|
|
|
@ -1308,7 +1332,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 |
|
|
|
|
|
|
@ -1366,7 +1391,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 |
|
|
|
|
|
|
@ -1389,7 +1415,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 |
|
|
|
|
|
|
@ -1427,7 +1454,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 |
|
|
|
|
|
|
@ -1465,7 +1493,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) |
|
|
|
|
|
|
@ -1494,7 +1523,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) |
|
|
|
|
|
|
@ -1530,7 +1560,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) |
|
|
|
|
|
|
@ -1586,7 +1617,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] |
|
|
@ -1649,7 +1681,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 |
|
|
@ -1792,7 +1825,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 |
|
|
@ -1862,7 +1896,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) |
|
|
|
peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") |
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
@ -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
|
|
|
|
peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") |
|
|
|
require.NoError(t, err) |
|
|
@ -1943,7 +1979,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) |
|
|
|
|
|
|
|