Skip to content

Commit

Permalink
test: fix TestNamespacedMerkleTree_calculateAbsenceIndex_Panic (#169)
Browse files Browse the repository at this point in the history
Closes #158
  • Loading branch information
rootulp authored Mar 30, 2023
1 parent fc5ccb4 commit a20a723
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,17 @@ func TestNamespacedMerkleTree_calculateAbsenceIndex_Panic(t *testing.T) {
nID namespace.ID
pushData []namespaceDataPair
}{
{"((0,0) == nID < minNID == (0,1))", []byte{0, 0}, generateLeafData(nidLen, 1, 3, []byte{})},
{"((0,3) == nID > maxNID == (0,2))", []byte{0, 3}, generateLeafData(nidLen, 1, 3, []byte{})},
{"empty tree", []byte{0, 0}, []namespaceDataPair{}},
{"non-empty tree with 2 leaves: ((0,0) == nID < minNID == (0,1))", []byte{0, 0}, generateLeafData(nidLen, 1, 3, []byte{})},
{"non-empty tree with 2 leaves: ((0,3) == nID > maxNID == (0,2))", []byte{0, 3}, generateLeafData(nidLen, 1, 3, []byte{})},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
n := New(sha256.New(), NamespaceIDSize(2))
for _, d := range tt.pushData {
err := n.Push(namespace.PrefixedData(append(d.ID, d.Data...)))
assert.NoError(t, err)
}
shouldPanic(t,
func() { n.calculateAbsenceIndex(tt.nID) })
})
Expand Down

0 comments on commit a20a723

Please sign in to comment.