Skip to content

Commit

Permalink
add a test to check the corner case of the stateless root (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet committed Jan 18, 2022
1 parent 60e681e commit aea74d4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions stateless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,25 @@ func TestStatelessGet(t *testing.T) {
}
}

func TestStatelessComputeCommitmentEmptyRoot(t *testing.T) {
root := &StatelessNode{}
root.ComputeCommitment()
if !Equal(root.hash, &FrZero) {
t.Fatal("invalid commitment for the empty root")
}

root.depth = 10
root.hash = nil
defer func() {
if err := recover(); err == nil {
t.Fatal("should have caught the computation of an invalid node")
}
}()
root.ComputeCommitment()

t.Fatal("should have panicked before")
}

func TestStatelessToDot(t *testing.T) {
key1, _ := hex.DecodeString("0000100000000000000000000000000000000000000000000000000000000000")
root := NewStateless()
Expand Down

0 comments on commit aea74d4

Please sign in to comment.