diff --git a/mempool/reactor_test.go b/mempool/reactor_test.go index 75b946a0e..400e47e84 100644 --- a/mempool/reactor_test.go +++ b/mempool/reactor_test.go @@ -37,7 +37,11 @@ func (ps peerState) GetHeight() int64 { // be received in the others. func TestReactorBroadcastTxMessage(t *testing.T) { config := cfg.TestConfig() - const N = 4 + // if there were more than two reactors, the order of transactions could not be + // asserted in waitForTxsOnReactors (due to transactions gossiping). If we + // replace Connect2Switches (full mesh) with a func, which connects first + // reactor to others and nothing else, this test should also pass with >2 reactors. + const N = 2 reactors := makeAndConnectReactors(config, N) defer func() { for _, r := range reactors { diff --git a/types/validator_set_test.go b/types/validator_set_test.go index 15c33930e..d17d78d1e 100644 --- a/types/validator_set_test.go +++ b/types/validator_set_test.go @@ -1232,21 +1232,21 @@ func TestValSetUpdatePriorityOrderTests(t *testing.T) { func verifyValSetUpdatePriorityOrder(t *testing.T, valSet *ValidatorSet, cfg testVSetCfg, nMaxElections int) { // Run election up to nMaxElections times, sort validators by priorities valSet.IncrementProposerPriority(tmrand.Int()%nMaxElections + 1) - origValsPriSorted := validatorListCopy(valSet.Validators) - sort.Sort(validatorsByPriority(origValsPriSorted)) // apply the changes, get the updated validators, sort by priorities applyChangesToValSet(t, nil, valSet, cfg.addedVals, cfg.updatedVals, cfg.deletedVals) - updatedValsPriSorted := validatorListCopy(valSet.Validators) - sort.Sort(validatorsByPriority(updatedValsPriSorted)) // basic checks assert.Equal(t, cfg.expectedVals, toTestValList(valSet.Validators)) verifyValidatorSet(t, valSet) // verify that the added validators have the smallest priority: - // - they should be at the beginning of valListNewPriority since it is sorted by priority + // - they should be at the beginning of updatedValsPriSorted since it is + // sorted by priority if len(cfg.addedVals) > 0 { + updatedValsPriSorted := validatorListCopy(valSet.Validators) + sort.Sort(validatorsByPriority(updatedValsPriSorted)) + addedValsPriSlice := updatedValsPriSorted[:len(cfg.addedVals)] sort.Sort(ValidatorsByVotingPower(addedValsPriSlice)) assert.Equal(t, cfg.addedVals, toTestValList(addedValsPriSlice))