-
Notifications
You must be signed in to change notification settings - Fork 0
consistency proof: fix edge case with 0 sized tree #9
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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "size1": 0, | ||
| "size2": 1, | ||
| "root1": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", | ||
| "root2": "ZG9uJ3QgY2FyZSAy", | ||
| "proof": [], | ||
| "desc": "size1 is zero and size2 is not zero", | ||
| "wantErr": true | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,8 +154,11 @@ func TestTreeConsistencyProof(t *testing.T) { | |
| if _, err := mt.ConsistencyProof(6, 3); err == nil { | ||
| t.Error("ConsistencyProof(6, 3) succeeded unexpectedly") | ||
| } | ||
| if _, err := mt.ConsistencyProof(0, 3); err == nil { | ||
| t.Error("ConsistencyProof(0, 3) succeeded unexpectedly") | ||
| } | ||
|
|
||
| for size1 := range uint64(8) + 1 { | ||
| for size1 := uint64(1); size1 <= 8; size1++ { | ||
|
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. In |
||
| for size2 := size1; size2 <= 8; size2++ { | ||
| t.Run(fmt.Sprintf("%d:%d", size1, size2), func(t *testing.T) { | ||
| got, err := mt.ConsistencyProof(size1, size2) | ||
|
|
@@ -178,8 +181,8 @@ func TestTreeConsistencyProofFuzz(t *testing.T) { | |
| for treeSize := uint64(1); treeSize <= 256; treeSize++ { | ||
| mt := newTree(entries[:treeSize]) | ||
| for range 8 { | ||
| size2 := rand.Uint64N(treeSize + 1) | ||
| size1 := rand.Uint64N(size2 + 1) | ||
| size2 := rand.Uint64N(treeSize) + 1 | ||
| size1 := rand.Uint64N(size2) + 1 | ||
|
|
||
| got, err := mt.ConsistencyProof(size1, size2) | ||
| if err != nil { | ||
|
|
||
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.
For consistency with the error message in
proof/proof.go(which uses"consistency proof from an empty tree is meaningless"), please update this error message to include the article "an".