|
|
|
@@ -66,10 +66,10 @@ func TestStateProposerSelection0(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
|
|
|
|
|
newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
|
|
|
|
@@ -118,13 +118,12 @@ 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, err := randState(ctx, config, log.TestingLogger(), 4) // test needs more work for more than 3 validators
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4) // test needs more work for more than 3 validators
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
height := cs1.Height
|
|
|
|
|
newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
|
|
|
|
|
|
|
|
|
@@ -161,10 +160,12 @@ 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, _, err := randState(ctx, config, log.TestingLogger(), 1)
|
|
|
|
|
cs, _, err := makeState(ctx, config, logger, 1)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
cs.SetPrivValidator(nil)
|
|
|
|
|
height, round := cs.Height, cs.Round
|
|
|
|
@@ -185,10 +186,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, _, err := randState(ctx, config, log.TestingLogger(), 1)
|
|
|
|
|
cs, _, err := makeState(ctx, config, logger, 1)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
height, round := cs.Height, cs.Round
|
|
|
|
|
|
|
|
|
@@ -220,10 +222,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, err := randState(ctx, config, log.TestingLogger(), 2)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 2)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
|
vs2 := vss[1]
|
|
|
|
@@ -283,10 +286,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, err := randState(ctx, config, log.TestingLogger(), 2)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 2)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
cs1.state.ConsensusParams.Block.MaxBytes = 2000
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -354,7 +358,7 @@ func TestStateFullRound1(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs, vss, err := randState(ctx, config, logger, 1)
|
|
|
|
|
cs, vss, err := makeState(ctx, config, logger, 1)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
height, round := cs.Height, cs.Round
|
|
|
|
|
|
|
|
|
@@ -396,10 +400,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, err := randState(ctx, config, log.TestingLogger(), 1)
|
|
|
|
|
cs, vss, err := makeState(ctx, config, logger, 1)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
height, round := cs.Height, cs.Round
|
|
|
|
|
|
|
|
|
@@ -419,10 +424,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, err := randState(ctx, config, log.TestingLogger(), 2)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 2)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2 := vss[1]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -464,10 +470,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, err := randState(ctx, config, log.TestingLogger(), 2)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 2)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2 := vss[1]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -605,8 +612,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, _, err := randState(ctx, config, log.TestingLogger(), 2)
|
|
|
|
|
cs2, _, err := makeState(ctx, config, logger, 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(ctx, t, cs2, vs2, vs2.Height, vs2.Round+1)
|
|
|
|
@@ -666,7 +672,7 @@ func TestStateLock_POLUpdateLock(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, config, logger, 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -770,8 +776,9 @@ func TestStateLock_POLRelock(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -871,8 +878,9 @@ func TestStateLock_PrevoteNilWhenLockedAndMissProposal(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -960,7 +968,7 @@ func TestStateLock_PrevoteNilWhenLockedAndDifferentProposal(t *testing.T) {
|
|
|
|
|
state.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, config, logger, 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -1062,7 +1070,7 @@ func TestStateLock_POLDoesNotUnlock(t *testing.T) {
|
|
|
|
|
state.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, config, logger, 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -1199,7 +1207,7 @@ func TestStateLock_MissingProposalWhenPOLSeenDoesNotUpdateLock(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, config, logger, 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -1285,8 +1293,9 @@ func TestStateLock_DoesNotLockOnOldProposal(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -1364,7 +1373,7 @@ func TestStateLock_POLSafety1(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, config, logger, 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -1486,7 +1495,7 @@ func TestStateLock_POLSafety2(t *testing.T) {
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, config, logger, 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -1585,7 +1594,7 @@ func TestState_PrevotePOLFromPreviousRound(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, config, logger, 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -1724,10 +1733,11 @@ func TestState_PrevotePOLFromPreviousRound(t *testing.T) {
|
|
|
|
|
// P0 proposes B0 at R3.
|
|
|
|
|
func TestProposeValidBlock(t *testing.T) {
|
|
|
|
|
cfg := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, cfg, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, cfg, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -1818,10 +1828,11 @@ func TestProposeValidBlock(t *testing.T) {
|
|
|
|
|
// P0 miss to lock B but set valid block to B after receiving delayed prevote.
|
|
|
|
|
func TestSetValidBlockOnDelayedPrevote(t *testing.T) {
|
|
|
|
|
config := configSetup(t)
|
|
|
|
|
logger := log.TestingLogger()
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
cs1, vss, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -1885,10 +1896,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, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -1945,12 +1957,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, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -1973,10 +1985,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, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -2014,10 +2027,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, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -2055,10 +2069,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, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, int32(1)
|
|
|
|
@@ -2087,10 +2102,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, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, int32(1)
|
|
|
|
@@ -2126,10 +2142,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, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, int32(1)
|
|
|
|
@@ -2184,11 +2201,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, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
cs1.txNotifier = &fakeTxNotifier{ch: make(chan struct{})}
|
|
|
|
|
|
|
|
|
@@ -2250,11 +2268,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, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
@@ -2397,10 +2416,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, err := randState(ctx, config, log.TestingLogger(), 4)
|
|
|
|
|
cs1, vss, err := makeState(ctx, config, logger, 4)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
|
|
|
|
|
height, round := cs1.Height, cs1.Round
|
|
|
|
@@ -2468,14 +2488,14 @@ 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, _, err := randState(ctx, config, log.TestingLogger(), 1)
|
|
|
|
|
cs, _, err := makeState(ctx, config, logger, 1)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
// 1) new block part
|
|
|
|
|
parts := types.NewPartSetFromData(tmrand.Bytes(100), 10)
|
|
|
|
@@ -2517,10 +2537,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, err := randState(ctx, config, log.TestingLogger(), 2)
|
|
|
|
|
cs, vss, err := makeState(ctx, config, logger, 2)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
// create dummy peer
|
|
|
|
|
peerID, err := types.NewNodeID("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
|
|
|
|
@@ -2556,10 +2577,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, err := randState(ctx, config, log.TestingLogger(), 2)
|
|
|
|
|
_, vss, err := makeState(ctx, config, logger, 2)
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
randBytes := tmrand.Bytes(tmhash.Size)
|
|
|
|
|