Anton Kaliaev 5 years ago
committed by GitHub
parent
commit
187120a04d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions
  1. +5
    -1
      mempool/reactor_test.go
  2. +5
    -5
      types/validator_set_test.go

+ 5
- 1
mempool/reactor_test.go View File

@ -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 {


+ 5
- 5
types/validator_set_test.go View File

@ -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))


Loading…
Cancel
Save