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
Respect precision while formatting Amount #2682
base: master
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 8757209561Details
💛 - Coveralls |
bdb2e5b
to
9881b91
Compare
@@ -211,8 +211,7 @@ impl<T: AsRef<[u8]>> Read for Cursor<T> { | |||
let start_pos = self.pos.try_into().unwrap_or(inner.len()); | |||
let read = core::cmp::min(inner.len().saturating_sub(start_pos), buf.len()); | |||
buf[..read].copy_from_slice(&inner[start_pos..start_pos + read]); | |||
self.pos = | |||
self.pos.saturating_add(read.try_into().unwrap_or(u64::MAX /* unreachable */)); | |||
self.pos = self.pos.saturating_add(read.try_into().unwrap_or(u64::MAX /* unreachable */)); |
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.
In 9881b91:
This appears to be format-only and unrelated to this PR.
Can you add a test which parses |
Done |
Hmmmm, something strange is going on. Your new test passes, but if you replace Can you add the |
I see a bug where values are ignored instead it adds zeros and rounding of. Working on a fix |
All characters beyond the needed precision are truncated In the case of a SignedAmount the default precision is now 8 just like the Amount Replaces self.fmt_value_in() with fmt_satoshi_in() so that FomartOptions is not made public which would be the requirements if self.fmt_value_in() is used. Tests have been improved to handle precision Resolves: rust-bitcoin#2136
I need help understanding how to fix the fuzz tests |
@448-OG possibly you will be better off just trying to write the formatting functions "properly" from scratch rather than tweaking the existing ones, which are pretty complicated. Though I'm doubtful because much of the complexity is inherent to the suffixing system. To try to zero in on fuzztest failures sometimes it's easiest to try minimizing the test cases. Just add a |
All characters beyond the needed precision are truncated
In the case of a SignedAmount the default precision is now 8 just like the Amount
Just like the existing code, no width is added if there exists fractional values just like the existing code works.
Tests have been improved to handle precision
Resolves: #2136