Skip to content
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

Refactor Height parsing logic and add test cases #758

Merged
merged 7 commits into from
Jul 11, 2023

Conversation

DaviRain-Su
Copy link
Contributor

Closes: #752

Description


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests.
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Patch coverage: 97.95% and project coverage change: +0.20 🎉

Comparison is base (bd2c1e6) 73.20% compared to head (362d93a) 73.41%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #758      +/-   ##
==========================================
+ Coverage   73.20%   73.41%   +0.20%     
==========================================
  Files         125      125              
  Lines       16082    16127      +45     
==========================================
+ Hits        11773    11839      +66     
+ Misses       4309     4288      -21     
Impacted Files Coverage Δ
crates/ibc/src/core/ics02_client/height.rs 91.19% <97.95%> (+21.89%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Farhad-Shabani
Copy link
Member

Ahh, my bad. Just noticed yours. Would it work with you we move forward with #759?

@Farhad-Shabani
Copy link
Member

Or you can also port changes that make sense from there?
I found split_once cleaner way. And good to separate tests for valid and invalid cases and including some other cases from #759.

@DaviRain-Su
Copy link
Contributor Author

no problem

@@ -159,6 +159,8 @@ pub enum HeightError {
},
/// attempted to parse an invalid zero height
ZeroHeight,
/// the height(`{raw_height}`) is not valid, this format must be used: \[revision_number\]-\[revision_height\]
InvalidHeight { raw_height: String },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you rename this to smt like InvalidFormat?
This can a bit confusing given the other InvalidHeight we already have under the ClientError enum

Copy link
Member

@Farhad-Shabani Farhad-Shabani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 👌🏻

@Farhad-Shabani Farhad-Shabani merged commit 5784770 into cosmos:main Jul 11, 2023
@DaviRain-Su DaviRain-Su deleted the fix-752 branch July 11, 2023 06:19
Farhad-Shabani pushed a commit that referenced this pull request Sep 9, 2024
* Refactor Height parsing logic and add test cases

* Create 752-fix-752.md

* Refactor error message for invalid height format

* Update height.rs

* Refactored height parsing logic and added tests

* Refactor error message for invalid height format

* Refactor variable name for consistency in `Height` conversion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Height::from_str accepts invalid heights
2 participants