From 40fe4a3bf83ed0d00760151a34e7e4532fa33fb0 Mon Sep 17 00:00:00 2001 From: Marko Date: Thu, 3 Jun 2021 12:42:06 +0000 Subject: [PATCH] test: HeaderHash test vector (#6531) ## Decription Tag teaming with callum on debugging, wrote this to test headerHash changes from 0.34 to master. Its useful going forward as well. --- types/block_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/types/block_test.go b/types/block_test.go index 0022a2ee2..21b251901 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -1312,3 +1312,37 @@ func TestCommit_ValidateBasic(t *testing.T) { }) } } + +func TestHeaderHashVector(t *testing.T) { + chainID := "test" + h := Header{ + Version: version.Consensus{Block: 1, App: 1}, + ChainID: chainID, + Height: 50, + Time: time.Date(math.MaxInt64, 0, 0, 0, 0, 0, math.MaxInt64, time.UTC), + LastBlockID: BlockID{}, + LastCommitHash: []byte("f2564c78071e26643ae9b3e2a19fa0dc10d4d9e873aa0be808660123f11a1e78"), + DataHash: []byte("f2564c78071e26643ae9b3e2a19fa0dc10d4d9e873aa0be808660123f11a1e78"), + ValidatorsHash: []byte("f2564c78071e26643ae9b3e2a19fa0dc10d4d9e873aa0be808660123f11a1e78"), + NextValidatorsHash: []byte("f2564c78071e26643ae9b3e2a19fa0dc10d4d9e873aa0be808660123f11a1e78"), + ConsensusHash: []byte("f2564c78071e26643ae9b3e2a19fa0dc10d4d9e873aa0be808660123f11a1e78"), + AppHash: []byte("f2564c78071e26643ae9b3e2a19fa0dc10d4d9e873aa0be808660123f11a1e78"), + + LastResultsHash: []byte("f2564c78071e26643ae9b3e2a19fa0dc10d4d9e873aa0be808660123f11a1e78"), + + EvidenceHash: []byte("f2564c78071e26643ae9b3e2a19fa0dc10d4d9e873aa0be808660123f11a1e78"), + ProposerAddress: []byte("2915b7b15f979e48ebc61774bb1d86ba3136b7eb"), + } + + testCases := []struct { + header Header + expBytes string + }{ + {header: h, expBytes: "87b6117ac7f827d656f178a3d6d30b24b205db2b6a3a053bae8baf4618570bfc"}, + } + + for _, tc := range testCases { + hash := tc.header.Hash() + require.Equal(t, tc.expBytes, hex.EncodeToString(hash)) + } +}