Merge pull request #664 from nspcc-dev/sort-validator-keys

core: sort GetValidators() result
This commit is contained in:
Roman Khimov 2020-02-13 21:46:26 +03:00 committed by GitHub
commit 992ccc0b26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View file

@ -194,23 +194,24 @@ func newTestService(t *testing.T) *service {
func getTestValidator(i int) (*privateKey, *publicKey) { func getTestValidator(i int) (*privateKey, *publicKey) {
var wif, password string var wif, password string
// Sorted by public key.
switch i { switch i {
case 0: case 0:
wif = "6PYLmjBYJ4wQTCEfqvnznGJwZeW9pfUcV5m5oreHxqryUgqKpTRAFt9L8Y"
password = "one"
case 1:
wif = "6PYXHjPaNvW8YknSXaKsTWjf9FRxo1s4naV2jdmSQEgzaqKGX368rndN3L" wif = "6PYXHjPaNvW8YknSXaKsTWjf9FRxo1s4naV2jdmSQEgzaqKGX368rndN3L"
password = "two" password = "two"
case 2: case 1:
wif = "6PYX86vYiHfUbpD95hfN1xgnvcSxy5skxfWYKu3ztjecxk6ikYs2kcWbeh"
password = "three"
case 3:
wif = "6PYRXVwHSqFSukL3CuXxdQ75VmsKpjeLgQLEjt83FrtHf1gCVphHzdD4nc" wif = "6PYRXVwHSqFSukL3CuXxdQ75VmsKpjeLgQLEjt83FrtHf1gCVphHzdD4nc"
password = "four" password = "four"
case 2:
wif = "6PYLmjBYJ4wQTCEfqvnznGJwZeW9pfUcV5m5oreHxqryUgqKpTRAFt9L8Y"
password = "one"
case 3:
wif = "6PYX86vYiHfUbpD95hfN1xgnvcSxy5skxfWYKu3ztjecxk6ikYs2kcWbeh"
password = "three"
default: default:
return nil, nil return nil, nil
} }

View file

@ -1413,6 +1413,7 @@ func (bc *Blockchain) GetValidators(txes ...*transaction.Transaction) ([]*keys.P
result = append(result, uniqueSBValidators[i]) result = append(result, uniqueSBValidators[i])
} }
} }
sort.Sort(result)
return result, nil return result, nil
} }