Make UiTokenAmount::ui_amount a String (#15447)

* Make UiTokenAmount::ui_amount a String

* Fixup solana-tokens

* Ignore spl downstream-project
This commit is contained in:
Tyera Eulberg
2021-02-22 13:05:45 -07:00
committed by GitHub
parent f7c0b69fd4
commit d14374bc9f
11 changed files with 152 additions and 127 deletions

View File

@ -5631,7 +5631,7 @@ pub mod tests {
let balance: UiTokenAmount =
serde_json::from_value(result["result"]["value"].clone()).unwrap();
let error = f64::EPSILON;
assert!((balance.ui_amount - 4.2).abs() < error);
assert!((f64::from_str(&balance.ui_amount).unwrap() - 4.2).abs() < error);
assert_eq!(balance.amount, 420.to_string());
assert_eq!(balance.decimals, 2);
@ -5656,7 +5656,7 @@ pub mod tests {
let supply: UiTokenAmount =
serde_json::from_value(result["result"]["value"].clone()).unwrap();
let error = f64::EPSILON;
assert!((supply.ui_amount - 5.0).abs() < error);
assert!((f64::from_str(&supply.ui_amount).unwrap() - 5.0).abs() < error);
assert_eq!(supply.amount, 500.to_string());
assert_eq!(supply.decimals, 2);
@ -5954,7 +5954,7 @@ pub mod tests {
RpcTokenAccountBalance {
address: token_with_different_mint_pubkey.to_string(),
amount: UiTokenAmount {
ui_amount: 0.42,
ui_amount: "0.42".to_string(),
decimals: 2,
amount: "42".to_string(),
}
@ -5962,7 +5962,7 @@ pub mod tests {
RpcTokenAccountBalance {
address: token_with_smaller_balance.to_string(),
amount: UiTokenAmount {
ui_amount: 0.1,
ui_amount: "0.1".to_string(),
decimals: 2,
amount: "10".to_string(),
}
@ -6036,7 +6036,7 @@ pub mod tests {
"mint": mint.to_string(),
"owner": owner.to_string(),
"tokenAmount": {
"uiAmount": 4.2,
"uiAmount": "4.2".to_string(),
"decimals": 2,
"amount": "420",
},
@ -6044,12 +6044,12 @@ pub mod tests {
"state": "initialized",
"isNative": true,
"rentExemptReserve": {
"uiAmount": 0.1,
"uiAmount": "0.1".to_string(),
"decimals": 2,
"amount": "10",
},
"delegatedAmount": {
"uiAmount": 0.3,
"uiAmount": "0.3".to_string(),
"decimals": 2,
"amount": "30",
},