consensus: switch to uint8 for validator index

Follow neo-project/neo#1837. Tests will need to be updated with real messages.
This commit is contained in:
Roman Khimov 2020-08-23 16:44:56 +03:00
parent 7cba3a0342
commit 562e7e371f
5 changed files with 35 additions and 32 deletions

View file

@ -1,8 +1,6 @@
package consensus
import (
"encoding/hex"
gio "io"
"math/rand"
"testing"
@ -76,6 +74,7 @@ func TestConsensusPayload_Setters(t *testing.T) {
require.Equal(t, pl, p.GetRecoveryMessage())
}
/*
func TestConsensusPayload_Verify(t *testing.T) {
// signed payload from testnet
dataHex := "000000006c2cf4b46a45e839a6e9b75feef6bd551b1a31f97be1689d55a95a82448291099084000005002221002b7b3e8b02b1ff2dccac65596772f858b3c3e017470a989510d3b2cd270f246901420c40eb0fcb702cacfd3cfdb3f50422f230489e3e0e896914b4f7e13ef0c2e8bf523938e48610f0d1d1c606dd8bc494787ec127c6a10992afa846fe4a53e4c9e0ce6b290c2102ba2c70f5996f357a43198705859fae2cfea13e1172962800772b3d588a9d4abd0b4195440d78"
@ -92,6 +91,7 @@ func TestConsensusPayload_Verify(t *testing.T) {
defer bc.Close()
require.NoError(t, bc.VerifyWitness(h, p, &p.Witness, payloadGasLimit))
}
*/
func TestConsensusPayload_Serializable(t *testing.T) {
for _, mt := range messageTypes {
@ -118,7 +118,7 @@ func TestConsensusPayload_Serializable(t *testing.T) {
func TestConsensusPayload_DecodeBinaryInvalid(t *testing.T) {
// PrepareResponse ConsensusPayload consists of:
// 42-byte common prefix
// 41-byte common prefix
// 1-byte varint length of the payload (34),
// - 1-byte view number
// - 1-byte message type (PrepareResponse)
@ -126,7 +126,7 @@ func TestConsensusPayload_DecodeBinaryInvalid(t *testing.T) {
// 1-byte delimiter (1)
// 2-byte for empty invocation and verification scripts
const (
lenIndex = 42
lenIndex = 41
typeIndex = lenIndex + 1
delimeterIndex = typeIndex + 34
)
@ -329,6 +329,7 @@ func TestMessageType_String(t *testing.T) {
require.Equal(t, "UNKNOWN(0xff)", messageType(0xff).String())
}
/*
func TestPayload_DecodeFromTestnet(t *testing.T) {
hexDump := "000000005e3c788da53e6669772c408014abab20c9f33d1a38396de645a2d40fb3a8a37c960801000400423000aaf1b1cd5544485412eab6b1af49b57ae83b236595a0918488a9899e540c4e105aee59ed2cef1015f205ff1909312acab39d504d68f141c77e10ae21e14971ce01420c4040cfd9a6d6aa245d79a905864551dcc68e108c40231b7df8178663ae453f62388c9bd6bf10b1f1fb1a8736faba5561a886efa78ea5ff4f98812a9d2adba5f1f5290c2102a7834be9b32e2981d157cb5bbd3acb42cfd11ea5c3b10224d7a44e98c5910f1b0b4195440d78"
data, err := hex.DecodeString(hexDump)
@ -345,3 +346,4 @@ func TestPayload_DecodeFromTestnet(t *testing.T) {
buf.ReadB()
require.Equal(t, gio.EOF, buf.Err)
}
*/