-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Cover all errors in concurrent Merkle tree
Make sure all errors are covered: * `HeightZero` - add new tests. * `ChangelogZero` - add new tests. * `RootsZero` - add new tests and fix the checks. * `TreeFull` - was already tested. * `BatchGreatedThanChangelog` - was already tested. * `InvalidProofLength` - add new tests. * `InvalidProof` - add new tests. * `CannotUpdateEmpty` - add new tests. * `EmptyLeaves` - add new tests. * `StructBufferSize` - add new tests. * `FilledSubtreesBufferSize` - add new tests. * `ChangelogBufferSize` - add new tests. * `RootBufferSize` - add new tests. * `CanopyBufferSize` - add new tests. Also, remove error variants which we don't want anymore: * `HeightHigherThanMax` - not used anymore, there is no limit of height. * `RootHigherThanMax` - it was an error we used to return in `root()` method. It's removed here, because it's not reproducable at all. We always ensure the bound of roots, so it's fine to panic in `root()`. * `BytesRead` - not used anymore. All methods for byte serialization return specific errors like `StructBufferSize` or `ChangelogBufferSize` when the sizes of provided byte buffers are incorrect. * `CannotUpdateLeaf` - not used anymore. The original idea behing this error comes from SPL concurrent Merkle tree whitepaper and the fact that patching the Merkle proof when the same leaf was updated, can't guarantee the correctness of the patched proof. But performing such patching needs to be done anyway for indexed Merkle trees. * `AppendOnly` - not used anymore. Our concurrent Merkle tree always needs to have a changelog. The reason is that we use changelog also as a storage for Merkle paths that we compute during appends and updates. * `EmptyChangelogEntries` - not used anymore. * `MerklePathsEmptyNode` - not used anymore. Error variant which is not tested: * `BoundedVecError` - it's not reproducable. This error variant is returned only when bounds of roots, changelogs, subtrees etc. are violated. Which should never happen - if it does, it's a bug.
- Loading branch information
1 parent
2f71c66
commit fecaf10
Showing
8 changed files
with
739 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.