Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash calculation based on proto.Structs #1315

Closed
antho1404 opened this issue Sep 9, 2019 · 0 comments · Fixed by #1318
Closed

Hash calculation based on proto.Structs #1315

antho1404 opened this issue Sep 9, 2019 · 0 comments · Fixed by #1318
Assignees
Labels
bug Something isn't working

Comments

@antho1404
Copy link
Member

With the migration to proto.structs instead of map[string]interface{} the hash calculation doesn't work anymore.

If an event has exactly the same instanceHash and eventKey but different data, the generated hash will be exactly the same which is wrong. We should have different hash.

This problem should also apply to the execution and its inputs

To reproduce:

package event

import (
	"testing"

	"github.com/gogo/protobuf/types"
	"github.com/mesg-foundation/engine/hash"
	"github.com/stretchr/testify/require"
)

func TestHashEvent(t *testing.T) {
	e1 := Create(hash.Int(0), "-", &types.Struct{
		Fields: map[string]*types.Value{
			"foo": &types.Value{
				Kind: &types.Value_StringValue{
					StringValue: "bar",
				},
			},
		},
	})
	e2 := Create(hash.Int(0), "-", &types.Struct{
		Fields: map[string]*types.Value{
			"foo": &types.Value{
				Kind: &types.Value_StringValue{
					StringValue: "bar2",
				},
			},
		},
	})
	require.NotEqual(t, e1.Hash, e2.Hash)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants