tendermint/consensus/types/proposal_test.go

28 lines
872 B
Go
Raw Normal View History

2015-04-27 20:55:28 -07:00
package consensus
import (
"testing"
2015-07-19 09:40:55 -07:00
acm "github.com/tendermint/tendermint/account"
2015-04-27 20:55:28 -07:00
. "github.com/tendermint/tendermint/common"
_ "github.com/tendermint/tendermint/config/tendermint_test"
2015-04-27 20:55:28 -07:00
"github.com/tendermint/tendermint/types"
)
func TestProposalSignable(t *testing.T) {
proposal := &Proposal{
2015-06-24 14:04:40 -07:00
Height: 12345,
Round: 23456,
BlockPartsHeader: types.PartSetHeader{111, []byte("blockparts")},
POLRound: -1,
2015-04-27 20:55:28 -07:00
}
2015-07-19 09:40:55 -07:00
signBytes := acm.SignBytes(config.GetString("chain_id"), proposal)
2015-04-27 20:55:28 -07:00
signStr := string(signBytes)
2015-06-24 14:04:40 -07:00
expected := Fmt(`{"chain_id":"%s","proposal":{"block_parts_header":{"hash":"626C6F636B7061727473","total":111},"height":12345,"pol_round":-1,"round":23456}}`,
config.GetString("chain_id"))
2015-04-27 20:55:28 -07:00
if signStr != expected {
t.Errorf("Got unexpected sign string for SendTx. Expected:\n%v\nGot:\n%v", expected, signStr)
}
}