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

Verify the hashing output matches ts-topology #31

Open
JanLewDev opened this issue Oct 21, 2024 · 0 comments
Open

Verify the hashing output matches ts-topology #31

JanLewDev opened this issue Oct 21, 2024 · 0 comments
Labels
tests Tests related

Comments

@JanLewDev
Copy link
Contributor

Verify that the calculated hash of a vertex match ts-topology:

vertexData := map[string]interface{}{
"operation": vertex.Operation,
"deps":      vertex.Dependencies,
"nodeId":    vertex.NodeId,
}
stringified, err := json.Marshal(vertexData)
if err != nil {
k.logger.Error("failed to marshal vertex with hash " + vertex.Hash)
continue
}
computedHash := sha256.Sum256(stringified)

vs

function computeHash<T>(
	nodeId: string,
	operation: Operation,
	deps: Hash[],
): Hash {
	const serialized = JSON.stringify({ operation, deps, nodeId });
	const hash = crypto.createHash("sha256").update(serialized).digest("hex");
	return hash;
}
@JanLewDev JanLewDev added the tests Tests related label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests related
Projects
None yet
Development

No branches or pull requests

1 participant