2015-08-10 20:38:45 -07:00
|
|
|
package types
|
2015-04-27 20:55:28 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2015-10-22 17:39:06 -07:00
|
|
|
. "github.com/tendermint/go-common"
|
2016-03-06 15:05:50 -08:00
|
|
|
"github.com/tendermint/tendermint/config/tendermint_test"
|
2015-04-27 20:55:28 -07:00
|
|
|
)
|
|
|
|
|
2016-03-06 15:05:50 -08:00
|
|
|
func init() {
|
|
|
|
tendermint_test.ResetConfig("types_proposal_test")
|
|
|
|
}
|
|
|
|
|
2015-04-27 20:55:28 -07:00
|
|
|
func TestProposalSignable(t *testing.T) {
|
|
|
|
proposal := &Proposal{
|
2015-06-24 14:04:40 -07:00
|
|
|
Height: 12345,
|
|
|
|
Round: 23456,
|
2015-08-10 20:38:45 -07:00
|
|
|
BlockPartsHeader: PartSetHeader{111, []byte("blockparts")},
|
2015-06-24 14:04:40 -07:00
|
|
|
POLRound: -1,
|
2015-04-27 20:55:28 -07:00
|
|
|
}
|
2015-11-01 11:34:08 -08:00
|
|
|
signBytes := 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}}`,
|
2015-05-29 14:13:45 -04:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|