|
|
@ -40,17 +40,17 @@ func TestHeartbeatWriteSignBytes(t *testing.T) { |
|
|
|
|
|
|
|
hb := &Heartbeat{ValidatorIndex: 1, Height: 10, Round: 1} |
|
|
|
hb.WriteSignBytes("0xdeadbeef", buf, &n, &err) |
|
|
|
require.Equal(t, string(buf.Bytes()), `{"chain_id":"0xdeadbeef","heartbeat":{"height":10,"round":1,"sequence":0,"validator_address":"","validator_index":1}}`) |
|
|
|
require.Equal(t, buf.String(), `{"chain_id":"0xdeadbeef","heartbeat":{"height":10,"round":1,"sequence":0,"validator_address":"","validator_index":1}}`) |
|
|
|
|
|
|
|
buf.Reset() |
|
|
|
plainHb := &Heartbeat{} |
|
|
|
plainHb.WriteSignBytes("0xdeadbeef", buf, &n, &err) |
|
|
|
require.Equal(t, string(buf.Bytes()), `{"chain_id":"0xdeadbeef","heartbeat":{"height":0,"round":0,"sequence":0,"validator_address":"","validator_index":0}}`) |
|
|
|
require.Equal(t, buf.String(), `{"chain_id":"0xdeadbeef","heartbeat":{"height":0,"round":0,"sequence":0,"validator_address":"","validator_index":0}}`) |
|
|
|
|
|
|
|
require.Panics(t, func() { |
|
|
|
buf.Reset() |
|
|
|
var nilHb *Heartbeat |
|
|
|
nilHb.WriteSignBytes("0xdeadbeef", buf, &n, &err) |
|
|
|
require.Equal(t, string(buf.Bytes()), "null") |
|
|
|
require.Equal(t, buf.String(), "null") |
|
|
|
}) |
|
|
|
} |