You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
844 B

  1. package types
  2. import (
  3. "testing"
  4. )
  5. func TestVoteSignable(t *testing.T) {
  6. vote := &Vote{
  7. ValidatorAddress: []byte("addr"),
  8. ValidatorIndex: 56789,
  9. Height: 12345,
  10. Round: 23456,
  11. Type: byte(2),
  12. BlockID: BlockID{
  13. Hash: []byte("hash"),
  14. PartsHeader: PartSetHeader{
  15. Total: 1000000,
  16. Hash: []byte("parts_hash"),
  17. },
  18. },
  19. }
  20. signBytes := SignBytes("test_chain_id", vote)
  21. signStr := string(signBytes)
  22. expected := `{"chain_id":"test_chain_id","vote":{"block_id":{"hash":"68617368","parts":{"hash":"70617274735F68617368","total":1000000}},"height":12345,"round":23456,"type":2}}`
  23. if signStr != expected {
  24. // NOTE: when this fails, you probably want to fix up consensus/replay_test too
  25. t.Errorf("Got unexpected sign string for Vote. Expected:\n%v\nGot:\n%v", expected, signStr)
  26. }
  27. }