mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 20:21:56 +00:00
Catch up with amino 0.13.0 (#2690)
* catch up with amino changes in https://github.com/tendermint/go-amino/pull/222 * WIP: update to amino v0.13.0 * update to fixed amino release
This commit is contained in:
committed by
Ethan Buchman
parent
9795e12ef2
commit
6643c5dd11
@@ -149,7 +149,7 @@ func (b *Block) MakePartSet(partSize int) *PartSet {
|
||||
|
||||
// We prefix the byte length, so that unmarshaling
|
||||
// can easily happen via a reader.
|
||||
bz, err := cdc.MarshalBinary(b)
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(b)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -265,7 +265,7 @@ func TestMaxHeaderBytes(t *testing.T) {
|
||||
ProposerAddress: tmhash.Sum([]byte("proposer_address")),
|
||||
}
|
||||
|
||||
bz, err := cdc.MarshalBinary(h)
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(h)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.EqualValues(t, MaxHeaderBytes, len(bz))
|
||||
|
@@ -105,7 +105,7 @@ func TestMaxEvidenceBytes(t *testing.T) {
|
||||
VoteB: makeVote(val, chainID, math.MaxInt64, math.MaxInt64, math.MaxInt64, math.MaxInt64, blockID2),
|
||||
}
|
||||
|
||||
bz, err := cdc.MarshalBinary(ev)
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(ev)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.EqualValues(t, MaxEvidenceBytes, len(bz))
|
||||
|
@@ -23,7 +23,7 @@ type Heartbeat struct {
|
||||
// SignBytes returns the Heartbeat bytes for signing.
|
||||
// It panics if the Heartbeat is nil.
|
||||
func (heartbeat *Heartbeat) SignBytes(chainID string) []byte {
|
||||
bz, err := cdc.MarshalBinary(CanonicalizeHeartbeat(chainID, heartbeat))
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(CanonicalizeHeartbeat(chainID, heartbeat))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ func TestHeartbeatWriteSignBytes(t *testing.T) {
|
||||
{
|
||||
testHeartbeat := &Heartbeat{ValidatorIndex: 1, Height: 10, Round: 1}
|
||||
signBytes := testHeartbeat.SignBytes(chainID)
|
||||
expected, err := cdc.MarshalBinary(CanonicalizeHeartbeat(chainID, testHeartbeat))
|
||||
expected, err := cdc.MarshalBinaryLengthPrefixed(CanonicalizeHeartbeat(chainID, testHeartbeat))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, expected, signBytes, "Got unexpected sign bytes for Heartbeat")
|
||||
}
|
||||
@@ -47,7 +47,7 @@ func TestHeartbeatWriteSignBytes(t *testing.T) {
|
||||
{
|
||||
testHeartbeat := &Heartbeat{}
|
||||
signBytes := testHeartbeat.SignBytes(chainID)
|
||||
expected, err := cdc.MarshalBinary(CanonicalizeHeartbeat(chainID, testHeartbeat))
|
||||
expected, err := cdc.MarshalBinaryLengthPrefixed(CanonicalizeHeartbeat(chainID, testHeartbeat))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, expected, signBytes, "Got unexpected sign bytes for Heartbeat")
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ func (p *Proposal) String() string {
|
||||
|
||||
// SignBytes returns the Proposal bytes for signing
|
||||
func (p *Proposal) SignBytes(chainID string) []byte {
|
||||
bz, err := cdc.MarshalBinary(CanonicalizeProposal(chainID, p))
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(CanonicalizeProposal(chainID, p))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ func TestProposalSignable(t *testing.T) {
|
||||
chainID := "test_chain_id"
|
||||
signBytes := testProposal.SignBytes(chainID)
|
||||
|
||||
expected, err := cdc.MarshalBinary(CanonicalizeProposal(chainID, testProposal))
|
||||
expected, err := cdc.MarshalBinaryLengthPrefixed(CanonicalizeProposal(chainID, testProposal))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, expected, signBytes, "Got unexpected sign bytes for Proposal")
|
||||
}
|
||||
@@ -57,9 +57,9 @@ func TestProposalVerifySignature(t *testing.T) {
|
||||
|
||||
// serialize, deserialize and verify again....
|
||||
newProp := new(Proposal)
|
||||
bs, err := cdc.MarshalBinary(prop)
|
||||
bs, err := cdc.MarshalBinaryLengthPrefixed(prop)
|
||||
require.NoError(t, err)
|
||||
err = cdc.UnmarshalBinary(bs, &newProp)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(bs, &newProp)
|
||||
require.NoError(t, err)
|
||||
|
||||
// verify the transmitted proposal
|
||||
|
@@ -48,7 +48,7 @@ func NewResultFromResponse(response *abci.ResponseDeliverTx) ABCIResult {
|
||||
|
||||
// Bytes serializes the ABCIResponse using wire
|
||||
func (a ABCIResults) Bytes() []byte {
|
||||
bz, err := cdc.MarshalBinary(a)
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(a)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -79,9 +79,9 @@ func TestValidTxProof(t *testing.T) {
|
||||
|
||||
// read-write must also work
|
||||
var p2 TxProof
|
||||
bin, err := cdc.MarshalBinary(proof)
|
||||
bin, err := cdc.MarshalBinaryLengthPrefixed(proof)
|
||||
assert.Nil(t, err)
|
||||
err = cdc.UnmarshalBinary(bin, &p2)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(bin, &p2)
|
||||
if assert.Nil(t, err, "%d: %d: %+v", h, i, err) {
|
||||
assert.Nil(t, p2.Validate(root), "%d: %d", h, i)
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func testTxProofUnchangable(t *testing.T) {
|
||||
|
||||
// make sure it is valid to start with
|
||||
assert.Nil(t, proof.Validate(root))
|
||||
bin, err := cdc.MarshalBinary(proof)
|
||||
bin, err := cdc.MarshalBinaryLengthPrefixed(proof)
|
||||
assert.Nil(t, err)
|
||||
|
||||
// try mutating the data and make sure nothing breaks
|
||||
@@ -120,7 +120,7 @@ func testTxProofUnchangable(t *testing.T) {
|
||||
// This makes sure that the proof doesn't deserialize into something valid.
|
||||
func assertBadProof(t *testing.T, root []byte, bad []byte, good TxProof) {
|
||||
var proof TxProof
|
||||
err := cdc.UnmarshalBinary(bad, &proof)
|
||||
err := cdc.UnmarshalBinaryLengthPrefixed(bad, &proof)
|
||||
if err == nil {
|
||||
err = proof.Validate(root)
|
||||
if err == nil {
|
||||
|
@@ -272,7 +272,7 @@ func randValidatorSet(numValidators int) *ValidatorSet {
|
||||
}
|
||||
|
||||
func (valSet *ValidatorSet) toBytes() []byte {
|
||||
bz, err := cdc.MarshalBinary(valSet)
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(valSet)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -280,7 +280,7 @@ func (valSet *ValidatorSet) toBytes() []byte {
|
||||
}
|
||||
|
||||
func (valSet *ValidatorSet) fromBytes(b []byte) {
|
||||
err := cdc.UnmarshalBinary(b, &valSet)
|
||||
err := cdc.UnmarshalBinaryLengthPrefixed(b, &valSet)
|
||||
if err != nil {
|
||||
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
|
||||
panic(err)
|
||||
|
@@ -59,7 +59,7 @@ type Vote struct {
|
||||
}
|
||||
|
||||
func (vote *Vote) SignBytes(chainID string) []byte {
|
||||
bz, err := cdc.MarshalBinary(CanonicalizeVote(chainID, vote))
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(CanonicalizeVote(chainID, vote))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ func TestVoteSignable(t *testing.T) {
|
||||
vote := examplePrecommit()
|
||||
signBytes := vote.SignBytes("test_chain_id")
|
||||
|
||||
expected, err := cdc.MarshalBinary(CanonicalizeVote("test_chain_id", vote))
|
||||
expected, err := cdc.MarshalBinaryLengthPrefixed(CanonicalizeVote("test_chain_id", vote))
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, expected, signBytes, "Got unexpected sign bytes for Vote.")
|
||||
@@ -130,9 +130,9 @@ func TestVoteSignableTestVectors(t *testing.T) {
|
||||
func TestVoteProposalNotEq(t *testing.T) {
|
||||
cv := CanonicalizeVote("", &Vote{Height: 1, Round: 1})
|
||||
p := CanonicalizeProposal("", &Proposal{Height: 1, Round: 1})
|
||||
vb, err := cdc.MarshalBinary(cv)
|
||||
vb, err := cdc.MarshalBinaryLengthPrefixed(cv)
|
||||
require.NoError(t, err)
|
||||
pb, err := cdc.MarshalBinary(p)
|
||||
pb, err := cdc.MarshalBinaryLengthPrefixed(p)
|
||||
require.NoError(t, err)
|
||||
require.NotEqual(t, vb, pb)
|
||||
}
|
||||
@@ -154,9 +154,9 @@ func TestVoteVerifySignature(t *testing.T) {
|
||||
|
||||
// serialize, deserialize and verify again....
|
||||
precommit := new(Vote)
|
||||
bs, err := cdc.MarshalBinary(vote)
|
||||
bs, err := cdc.MarshalBinaryLengthPrefixed(vote)
|
||||
require.NoError(t, err)
|
||||
err = cdc.UnmarshalBinary(bs, &precommit)
|
||||
err = cdc.UnmarshalBinaryLengthPrefixed(bs, &precommit)
|
||||
require.NoError(t, err)
|
||||
|
||||
// verify the transmitted vote
|
||||
@@ -230,7 +230,7 @@ func TestMaxVoteBytes(t *testing.T) {
|
||||
err := privVal.SignVote("test_chain_id", vote)
|
||||
require.NoError(t, err)
|
||||
|
||||
bz, err := cdc.MarshalBinary(vote)
|
||||
bz, err := cdc.MarshalBinaryLengthPrefixed(vote)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.EqualValues(t, MaxVoteBytes, len(bz))
|
||||
|
Reference in New Issue
Block a user