From dc359bd3a51c52803a6af820a36ee41796284e87 Mon Sep 17 00:00:00 2001 From: Anca Zamfir Date: Mon, 11 Mar 2019 16:17:25 +0200 Subject: [PATCH] types: remove check for priority order of existing validators (#3407) When scaling and averaging is invoked, it is possible to have validators with close priorities ending up with same priority. With the current code, this makes it impossible to verify the priority orders before and after updates. Fixes #3383 --- types/validator_set_test.go | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/types/validator_set_test.go b/types/validator_set_test.go index 22f373c73..9fc2d346c 100644 --- a/types/validator_set_test.go +++ b/types/validator_set_test.go @@ -1113,15 +1113,6 @@ func applyChangesToValSet(t *testing.T, valSet *ValidatorSet, valsLists ...[]tes assert.NoError(t, err) } -func isAddressInList(address []byte, valsList []testVal) bool { - for _, val := range valsList { - if bytes.Equal([]byte(val.name), address) { - return true - } - } - return false -} - func TestValSetUpdatePriorityOrderTests(t *testing.T) { const nMaxElections = 5000 @@ -1206,25 +1197,6 @@ func verifyValSetUpdatePriorityOrder(t *testing.T, valSet *ValidatorSet, cfg tes assert.Equal(t, expectedPri, val.ProposerPriority) } } - - // check that the priority order for validators that remained is the same - // as in the original set - remainingValsPriSlice := updatedValsPriSorted[len(cfg.addedVals):] - - for len(remainingValsPriSlice) > 0 { - addressInChanged := remainingValsPriSlice[0].Address - addressInOld := origValsPriSorted[0].Address - - // skip validators in original list that have been removed - if isAddressInList(addressInOld, cfg.deletedVals) { - origValsPriSorted = origValsPriSorted[1:] - continue - } - assert.Equal(t, addressInOld, addressInChanged, "wrong priority order") - - remainingValsPriSlice = remainingValsPriSlice[1:] - origValsPriSorted = origValsPriSorted[1:] - } } //---------------------