use full hash (#7416)

This commit is contained in:
Nishant Das
2020-10-02 23:08:51 +08:00
committed by GitHub
parent ba01abbc8f
commit b589ddd774
2 changed files with 3 additions and 3 deletions

View File

@@ -79,10 +79,10 @@ func (s *Service) SubscribeToTopic(topic string, opts ...pubsub.SubOpt) (*pubsub
// Content addressable ID function.
//
// ETH2 spec defines the message ID as:
// message-id: SHA256(message.data)[:8]
// message-id: SHA256(message.data)
func msgIDFunction(pmsg *pubsub_pb.Message) string {
h := hashutil.Hash(pmsg.Data)
return string(h[:8])
return string(h[:])
}
func setPubSubParameters() {

View File

@@ -33,6 +33,6 @@ func TestMessageIDFunction_HashesCorrectly(t *testing.T) {
msg := [32]byte{'J', 'U', 'N', 'K'}
pMsg := &pubsubpb.Message{Data: msg[:]}
hashedData := hashutil.Hash(pMsg.Data)
msgID := string(hashedData[:8])
msgID := string(hashedData[:])
assert.Equal(t, msgID, msgIDFunction(pMsg), "Got incorrect msg id")
}