Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions trie/bintrie/binary_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

type (
NodeFlushFn func([]byte, BinaryNode)
NodeFlushFn func(*BitArray, BinaryNode)
NodeResolverFn func([]byte, common.Hash) ([]byte, error)
)

Expand Down Expand Up @@ -54,7 +54,7 @@ type BinaryNode interface {
Hash() common.Hash
GetValuesAtStem([]byte, NodeResolverFn) ([][]byte, error)
InsertValuesAtStem([]byte, [][]byte, NodeResolverFn, int) (BinaryNode, error)
CollectNodes([]byte, NodeFlushFn) error
CollectNodes(*BitArray, NodeFlushFn) error

toDot(parent, path string) string
GetHeight() int
Expand Down
8 changes: 4 additions & 4 deletions trie/bintrie/binary_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,28 +199,28 @@ func TestKeyToPath(t *testing.T) {
name: "depth 0",
depth: 0,
key: []byte{0x80}, // 10000000 in binary
expected: []byte{1},
expected: []byte{1}, // first 1 bit = 1
wantErr: false,
},
{
name: "depth 7",
depth: 7,
key: []byte{0xFF}, // 11111111 in binary
expected: []byte{1, 1, 1, 1, 1, 1, 1, 1},
expected: []byte{0xFF}, // first 8 bits = 0xFF
wantErr: false,
},
{
name: "depth crossing byte boundary",
depth: 10,
key: []byte{0xFF, 0x00}, // 11111111 00000000 in binary
expected: []byte{1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
expected: []byte{0x07, 0xF8}, // first 11 bits = 11111111000 = 0x7F8
wantErr: false,
},
{
name: "max valid depth",
depth: StemSize * 8,
key: make([]byte, HashSize),
expected: make([]byte, StemSize*8+1),
expected: make([]byte, StemSize), // 248 bits of zeros (capped to key length)
wantErr: false,
},
{
Expand Down
Loading