-
Notifications
You must be signed in to change notification settings - Fork 0
testonly + reftests #14
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,6 +196,43 @@ func TestTreeConsistencyProofFuzz(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| func TestSubtreeTreeConsistencyProof(t *testing.T) { | ||
| entries := LeafInputs() | ||
| mt := newTree(entries) | ||
| validateTree(t, mt, 8) | ||
|
|
||
| if _, err := mt.SubtreeConsistencyProof(0, 6, 3); err == nil { | ||
| t.Error("SubtreeConsistencyProof(0, 6, 3) succeeded unexpectedly (size < end)") | ||
| } | ||
| if _, err := mt.SubtreeConsistencyProof(3, 3, 8); err == nil { | ||
| t.Error("SubtreeConsistencyProof(3, 3, 8) succeeded unexpectedly (start >= end)") | ||
| } | ||
| if _, err := mt.SubtreeConsistencyProof(1, 3, 8); err == nil { | ||
| t.Error("SubtreeConsistencyProof(1, 3, 8) succeeded unexpectedly (invalid subtree)") | ||
| } | ||
|
Comment on lines
+204
to
+212
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be beneficial to also test that if _, err := mt.SubtreeConsistencyProof(0, 6, 3); err == nil {
t.Error("SubtreeConsistencyProof(0, 6, 3) succeeded unexpectedly")
}
if _, err := mt.SubtreeConsistencyProof(1, 3, 4); err == nil {
t.Error("SubtreeConsistencyProof(1, 3, 4) succeeded unexpectedly")
}
Comment on lines
+204
to
+212
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To ensure comprehensive test coverage of the new if _, err := mt.SubtreeConsistencyProof(0, 6, 3); err == nil {
t.Error("SubtreeConsistencyProof(0, 6, 3) succeeded unexpectedly")
}
if _, err := mt.SubtreeConsistencyProof(3, 3, 8); err == nil {
t.Error("SubtreeConsistencyProof(3, 3, 8) succeeded unexpectedly (start >= end)")
}
if _, err := mt.SubtreeConsistencyProof(1, 3, 8); err == nil {
t.Error("SubtreeConsistencyProof(1, 3, 8) succeeded unexpectedly (invalid alignment)")
} |
||
|
|
||
| maxSize := uint64(len(entries)) | ||
| for end := uint64(1); end <= maxSize; end++ { | ||
| for size := end; size <= maxSize; size++ { | ||
| for start := range end { | ||
| if err := isSubtreeValid(start, end); err != nil { | ||
| continue | ||
| } | ||
| t.Run(fmt.Sprintf("%d:%d:%d", start, end, size), func(t *testing.T) { | ||
| got, err := mt.SubtreeConsistencyProof(start, end, size) | ||
| if err != nil { | ||
| t.Fatalf("SubtreeConsistencyProof: %v", err) | ||
| } | ||
| want := refSubtreeConsistencyProof(start, end, entries[:size], true, mt.hasher) | ||
| if diff := cmp.Diff(got, want, cmpopts.EquateEmpty()); diff != "" { | ||
| t.Errorf("SubtreeConsistencyProof: diff (-got +want)\n%s", diff) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestTreeAppend(t *testing.T) { | ||
| entries := genEntries(256) | ||
| mt1 := newTree(entries) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a minor grammatical typo in the comment:
on right of splitshould beon the right of split.