mirror of
https://github.com/tendermint/tendermint.git
synced 2025-12-23 06:15:19 +00:00
types: remove unnecessary sort call (#4876)
in TestValSetUpdatePriorityOrderTests https://app.circleci.com/pipelines/github/tendermint/tendermint/3849/workflows/6d241fc8-72a8-4a3b-b3fc-887a48518f82/jobs/114996 also, reduce the number of reactors in TestReactorBroadcastTxMessage https://app.circleci.com/pipelines/github/tendermint/tendermint/3797/workflows/935cda34-dfb3-46e9-8257-92277171c91b/jobs/114562
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user