-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(hasher): Fix chunk count in
merkleizeImpl
(#147)
* fixed chunk count * space * add test
- Loading branch information
Showing
4 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package testcases | ||
|
||
//go:generate go run ../main.go --path container.go | ||
|
||
type Vec struct { | ||
Values []uint64 `ssz-size:"6"` | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package testcases | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
) | ||
|
||
func TestVectorContainer(t *testing.T) { | ||
v := &Vec{ | ||
Values: []uint64{1, 2, 3, 4, 5, 6}, | ||
} | ||
expectedHash := [32]byte{ | ||
0xac, 0x13, 0x6e, 0xdd, 0xa3, 0xbd, 0xd2, 0xe9, | ||
0x49, 0xa1, 0x9a, 0x94, 0x5b, 0x1a, 0xc5, 0x54, | ||
0xe4, 0xb6, 0x07, 0xd3, 0x39, 0xa4, 0x3c, 0x54, | ||
0x0c, 0x33, 0x60, 0x98, 0xff, 0xf9, 0x7f, 0x2b, | ||
} | ||
h, err := v.HashTreeRoot() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if !bytes.Equal(h[:], expectedHash[:]) { | ||
t.Fatalf("hash mismatch") | ||
} | ||
} |