mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 13:51:21 +00:00
add empty struct examples
This commit is contained in:
@ -9,7 +9,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestProto3Compatibility(t *testing.T) {
|
func TestProto3Compatibility(t *testing.T) {
|
||||||
// TODO(ismail): table tests instead...
|
|
||||||
tm, err := time.Parse("Mon Jan 2 15:04:05 -0700 MST 2006", "Mon Jan 2 15:04:05 -0700 MST 2006")
|
tm, err := time.Parse("Mon Jan 2 15:04:05 -0700 MST 2006", "Mon Jan 2 15:04:05 -0700 MST 2006")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
seconds := tm.Unix()
|
seconds := tm.Unix()
|
||||||
@ -32,7 +31,6 @@ func TestProto3Compatibility(t *testing.T) {
|
|||||||
ValidatorsHash:[]byte("validators hash"),
|
ValidatorsHash:[]byte("validators hash"),
|
||||||
|
|
||||||
}
|
}
|
||||||
// TODO(ismail): add another test where parts are missing (to see if default values are treated equiv.)
|
|
||||||
aminoHeader := Header{
|
aminoHeader := Header{
|
||||||
ChainID: "cosmos",
|
ChainID: "cosmos",
|
||||||
Height:150,
|
Height:150,
|
||||||
@ -57,4 +55,37 @@ func TestProto3Compatibility(t *testing.T) {
|
|||||||
assert.NoError(t, err, "unexpected error")
|
assert.NoError(t, err, "unexpected error")
|
||||||
// This works:
|
// This works:
|
||||||
assert.Equal(t, ab, pb, "encoding doesn't match")
|
assert.Equal(t, ab, pb, "encoding doesn't match")
|
||||||
|
|
||||||
|
emptyLastBlockPb := proto3.Header{
|
||||||
|
ChainID: "cosmos",
|
||||||
|
Height:150,
|
||||||
|
Time: &proto3.Timestamp{Seconds:seconds, Nanos:nanos},
|
||||||
|
NumTxs: 7,
|
||||||
|
LastBlockID: &proto3.BlockID{
|
||||||
|
PartsHeader: &proto3.PartSetHeader{},
|
||||||
|
},
|
||||||
|
TotalTxs: 100,
|
||||||
|
LastCommitHash: []byte("commit hash"),
|
||||||
|
DataHash: []byte("data hash"),
|
||||||
|
ValidatorsHash:[]byte("validators hash"),
|
||||||
|
|
||||||
|
}
|
||||||
|
emptyLastBlockAm := Header{
|
||||||
|
ChainID: "cosmos",
|
||||||
|
Height:150,
|
||||||
|
Time: tm,
|
||||||
|
NumTxs: 7,
|
||||||
|
TotalTxs: 100,
|
||||||
|
LastCommitHash: []byte("commit hash"),
|
||||||
|
DataHash: []byte("data hash"),
|
||||||
|
ValidatorsHash:[]byte("validators hash"),
|
||||||
|
}
|
||||||
|
|
||||||
|
ab, err = cdc.MarshalBinaryBare(emptyLastBlockAm)
|
||||||
|
assert.NoError(t, err, "unexpected error")
|
||||||
|
|
||||||
|
pb, err = proto.Marshal(&emptyLastBlockPb)
|
||||||
|
assert.NoError(t, err, "unexpected error")
|
||||||
|
// This works:
|
||||||
|
assert.Equal(t, ab, pb, "encoding doesn't match")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user