Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Fix real_number_string_trimmed zero-decimal behavior #15873

Merged
merged 3 commits into from
Mar 15, 2021

Conversation

CriesofCarrots
Copy link
Contributor

Problem

real_number_string_trimmed() (#12466) misbehaves when decimals are zero, incorrectly stripping trailing zeroes. eg:

real_number_string_trimmed(200, 0) = "2"
real_number_string_trimmed(0, 0) = ""

Summary of Changes

Fix; skip trailing-zero and decimal-point removal for zero-decimal amounts

real_number_string_trimmed(200, 0) = "200"
real_number_string_trimmed(0, 0) = "0"

Fixes #15845

Copy link
Contributor

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

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

Nice catch!

@CriesofCarrots CriesofCarrots added the automerge Merge this Pull Request automatically once CI passes label Mar 15, 2021
@codecov
Copy link

codecov bot commented Mar 15, 2021

Codecov Report

Merging #15873 (ffa46ef) into master (5b2da19) will increase coverage by 0.0%.
The diff coverage is 100.0%.

@@           Coverage Diff           @@
##           master   #15873   +/-   ##
=======================================
  Coverage    80.0%    80.0%           
=======================================
  Files         409      409           
  Lines      106389   106416   +27     
=======================================
+ Hits        85152    85177   +25     
- Misses      21237    21239    +2     

@mergify mergify bot merged commit c40bd5f into solana-labs:master Mar 15, 2021
mergify bot pushed a commit that referenced this pull request Mar 15, 2021
* Add failing test

* Don't strip zeroes from zero-decimal amounts

* Add zero-case test

(cherry picked from commit c40bd5f)
mergify bot pushed a commit that referenced this pull request Mar 15, 2021
* Add failing test

* Don't strip zeroes from zero-decimal amounts

* Add zero-case test

(cherry picked from commit c40bd5f)
mergify bot added a commit that referenced this pull request Mar 15, 2021
* Add failing test

* Don't strip zeroes from zero-decimal amounts

* Add zero-case test

(cherry picked from commit c40bd5f)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
mergify bot added a commit that referenced this pull request Mar 15, 2021
* Add failing test

* Don't strip zeroes from zero-decimal amounts

* Add zero-case test

(cherry picked from commit c40bd5f)

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
@CriesofCarrots CriesofCarrots deleted the fix-spl-token-trimmed branch March 30, 2021 16:28
@brooksprumo brooksprumo mentioned this pull request Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rpc: UiAmountString is an empty string instead of 0
2 participants