-
Notifications
You must be signed in to change notification settings - Fork 228
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
Add support for tendermint::chain::Id
constants
#1105
Conversation
If you're happy with the general direction I can add some tests for this specific constructor. |
Codecov Report
@@ Coverage Diff @@
## master #1105 +/- ##
========================================
- Coverage 64.7% 64.7% -0.1%
========================================
Files 240 240
Lines 20789 20808 +19
========================================
+ Hits 13464 13466 +2
- Misses 7325 7342 +17
Continue to review full report at Codecov.
|
cd1f6c6
to
cc889be
Compare
Seems good to me! |
In PeggyJV/ocular#18 we are trying to create a registry of "well-known" chain IDs. I proposed using `tendermint::chain::Id` for this, but to do so we'd need to have a const initializer support. This commit changes the internal representation of `chain::Id` to `Cow<'static, str>`. This permits a `const fn` initializer, but avoids adding a lifetime to `chain::Id` itself. It also adds `chain::Id::new` which is defined as a `const fn`, which can be used to define chain ID constants.
cc889be
to
50ec5ce
Compare
Tests and changelog entry added |
const MAX_LENGTH_CHAIN_ID: &str = "01234567890123456789012345678901234567890123456789"; | ||
const OVERLENGTH_CHAIN_ID: &str = "012345678901234567890123456789012345678901234567890"; |
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.
These need to be constants to test Id::new
, which accepts a &'static str
as an argument.
assert!( | ||
matches!( |
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.
Soon: assert_matches!
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.
LGTM!
In PeggyJV/ocular#18 we are trying to create a registry of "well-known" chain IDs. I proposed using
tendermint::chain::Id
for this, but to do so we'd need to have a const initializer support.This commit changes the internal representation of
chain::Id
toCow<'static, str>
. This permits aconst fn
initializer, but avoids adding a lifetime tochain::Id
itself.It also adds
chain::Id::new
which is defined as aconst fn
, which can be used to define chain ID constants..changelog/