consensus: proto migration (#4984)

## Description

migrate consensus to protobuf

Closes: #XXX
This commit is contained in:
Marko
2020-06-10 14:08:47 +02:00
committed by GitHub
parent 5697e144a7
commit d54de61bf6
20 changed files with 873 additions and 217 deletions

View File

@@ -4,6 +4,9 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
tmrand "github.com/tendermint/tendermint/libs/rand"
)
func TestSimpleProofValidateBasic(t *testing.T) {
@@ -39,3 +42,35 @@ func TestSimpleProofValidateBasic(t *testing.T) {
})
}
}
func TestSimpleProofProtoBuf(t *testing.T) {
testCases := []struct {
testName string
ps1 *SimpleProof
expPass bool
}{
{"failure empty", &SimpleProof{}, false},
{"failure nil", nil, false},
{"success",
&SimpleProof{
Total: 1,
Index: 1,
LeafHash: tmrand.Bytes(32),
Aunts: [][]byte{tmrand.Bytes(32), tmrand.Bytes(32), tmrand.Bytes(32)},
}, true},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.testName, func(t *testing.T) {
proto := tc.ps1.ToProto()
p, err := SimpleProofFromProto(proto)
if tc.expPass {
require.NoError(t, err)
require.Equal(t, tc.ps1, p, tc.testName)
} else {
require.Error(t, err, tc.testName)
}
})
}
}

View File

@@ -109,7 +109,7 @@ func BenchmarkSimpleHashAlternatives(b *testing.B) {
func Test_getSplitPoint(t *testing.T) {
tests := []struct {
length int64
want int
want int64
}{
{1, 0},
{2, 1},