34 lines
1.6 KiB
Rust
34 lines
1.6 KiB
Rust
// file: crates/ksp-onchain-transport-lib/unit_tests/rpc_tokens.rs
|
|
// version: 2
|
|
|
|
#[test]
|
|
fn token_selector_is_exclusive_by_construction() {
|
|
let mint = "11111111111111111111111111111111".parse::<ksp_core_lib::Pubkey>().expect("fixture pubkey must parse");
|
|
assert_eq!(crate::SolanaTokenAccountSelector::Mint(mint).to_json_value(), serde_json::json!({"mint":"11111111111111111111111111111111"}));
|
|
assert_eq!(crate::SolanaTokenAccountSelector::ProgramId(mint).to_json_value(), serde_json::json!({"programId":"11111111111111111111111111111111"}));
|
|
}
|
|
|
|
#[test]
|
|
fn token_amount_fixture_preserves_nullable_ui_amount() {
|
|
let value: serde_json::Value = serde_json::from_str(include_str!("../fixtures/http/token_amount.null_ui.json")).expect("fixture must decode");
|
|
let amount = crate::SolanaTokenAmount::decode_wire("fixture", value).expect("token amount must decode");
|
|
assert_eq!(amount.amount(), "18446744073709551615");
|
|
assert_eq!(amount.decimals(), 9);
|
|
assert_eq!(amount.ui_amount(), std::option::Option::None);
|
|
assert_eq!(amount.ui_amount_string(), "18446744073.709551615");
|
|
}
|
|
|
|
#[test]
|
|
fn staged_token_account_balance_helper_preserves_address_and_amount() {
|
|
let value = serde_json::json!({
|
|
"address":"11111111111111111111111111111111",
|
|
"amount":"10",
|
|
"decimals":2,
|
|
"uiAmount":0.1,
|
|
"uiAmountString":"0.1"
|
|
});
|
|
let balance = crate::SolanaTokenAccountBalance::decode_wire("fixture", value).expect("token account balance must decode");
|
|
assert_eq!(balance.address().to_string(), "11111111111111111111111111111111");
|
|
assert_eq!(balance.amount().amount(), "10");
|
|
}
|