-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify some light client types and testing (#132)
* Differentiate error from verify_commit_(trusting vs full) - use same names as in current spec * Fix failing test :-) * Refactoring and simplifications: param struct for TrustedState, SignedHeader - as a result of parametrarizing `TrustedState<C, H>` and `SignedHeader<C, H>` (instead of trait with assoc. types) a few things have to be (re)parametrarized and other can be completely deleted as they are redundant and consumers can use the param structs instead of the trait impls: - parametrarize Store<C, H> too - delete mocks: MockSignedHeader, MockState - delete impl for block::signed_header::SignedHeader - delete impl for lite::TrustedState in JSON tests - remove `State` and state.rs module from implementation completely - adapt params in verifier to match generic params of TrustedState & SignedHeader - remove dep on block::Height by making lite::Height a u64 alias * Remove obsolete TODO: we don't take a ref anymore * some checked arithmetic for height * type alias Mock types * Add TrustThresholdFraction and a default for it - remove `DefaultTrustLevel` from tests - remove TrustThresholdOneThird and TrustThresholdTwoThirds from tendermint-lite (the latter was not used and the first duplicates the default impl) - use TrustThresholdFraction::default() instead * remove obsolete clone * remove unused lifetime (initially introduced to get rid of `clone`s in constructor) * improve doc * remove TestSuite struct from JSON tests * Add tests for TrustThresholdFraction * add test-case for `is_within_trust_period` to increase test-coverage * remove `votes_len` from commit; add a validate method to commit - rename `validate_untrusted` -> `validate` which calls the new method on Commit - simplify tests (`Option`s are not longer needed) - move length matches check to impl of `validate` * unexport `verify_single` and use `verify_and_update_single` in tests instead - use MemStore of light crate in tests as a Mock * type alias doesn't need to be `pub` here * update doc comment and revert to making State public in tendermint-lite * Remove len & is_empty() from ValidatSet trait * add some very simple unit tests for basic types * update comments and move mock types into a mock module (only accessible in the super module) - mocks can be used in both types.rs and verifier.rs without decreasing codecov * add missing #[cfg(test)] attribute (saves some compile time) * remove store from inner recursion function - rename _verify_and_update_bisection -> verify_and_update_bisection_inner * remove store from `verify_and_update_bisection` too * rename some public methods of the verifier to be more aligned with the spec - verify_and_update_single -> verify_single - verify_and_update_bisection -> verify_bisection - remove store from public facing functions * make trust_level satisfy Copy + Clone and don't pass by reference * refactor bisection to return a list of intermediate states (using memoization) * use Vec instead of HashMap to memoize / return the interm. sates * rename test helpers the assert_single_* * WIP: quick first test for bisection * WIP: add debug output to mocks & modify init_trusted_state to take next_vals too * WIP: minor refactoring: intro method to ensure uniqueness in the returned states * Add some comments and clean-up the code to be slightly more consistent for @Shivani912 to take over :-) * fix accidentally broken test
- Loading branch information
Showing
14 changed files
with
709 additions
and
558 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
pub mod requester; | ||
pub mod state; | ||
pub mod store; | ||
pub mod threshold; |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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.