mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-08 06:15:33 +00:00
consensus: proto migration (#4984)
## Description migrate consensus to protobuf Closes: #XXX
This commit is contained in:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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},
|
||||
|
||||
Reference in New Issue
Block a user