native: fix getvalidators to match C# implementation

ValidatorsCount is not initialized at block 0 with C# node (the first voter
initializes it) and until that initialization happens the standby validators
list is being returned as is without sorting.

Fixes state mismatch for the key ffffffff0e00000000000000000000000000000001 in
the first blocks.

It also affects tests as now the first validator is different and it receives
the network fees.
This commit is contained in:
Roman Khimov 2020-06-23 13:26:39 +03:00
parent 66df805f3b
commit 2f8e7e4d33
4 changed files with 36 additions and 24 deletions

View file

@ -213,7 +213,7 @@ func newTestService(t *testing.T) *service {
}
func getTestValidator(i int) (*privateKey, *publicKey) {
key := testchain.PrivateKey(i)
key := testchain.PrivateKeyByID(i)
return &privateKey{PrivateKey: key}, &publicKey{PublicKey: key.PublicKey()}
}
@ -241,9 +241,8 @@ func signTx(t *testing.T, feePerByte util.Fixed8, txs ...*transaction.Transactio
validators := make([]*keys.PublicKey, 4)
privNetKeys := make([]*keys.PrivateKey, 4)
for i := 0; i < 4; i++ {
privateKey, publicKey := getTestValidator(i)
validators[i] = publicKey.PublicKey
privNetKeys[i] = privateKey.PrivateKey
privNetKeys[i] = testchain.PrivateKey(i)
validators[i] = privNetKeys[i].PublicKey()
}
rawScript, err := smartcontract.CreateMultiSigRedeemScript(3, validators)
require.NoError(t, err)