1
use crate::types::FPCoin;
2
use cosmwasm_std::Coin;
3
use injective_math::FPDecimal;
4

            
5
#[test]
6
2
fn fp_coin_conversion_uses_integer_units_not_fixed_point_raw_units() {
7
2
    let coin = FPCoin {
8
2
        amount: FPDecimal::must_from_str("4250000.9"),
9
2
        denom: "atom".to_string(),
10
2
    }
11
2
    .to_coin_floor()
12
2
    .unwrap();
13
2

            
14
2
    assert_eq!(coin, Coin::new(4_250_000u128, "atom"));
15
2
}
16

            
17
#[test]
18
2
fn fp_coin_conversion_rejects_negative_amounts() {
19
2
    let result = FPCoin {
20
2
        amount: FPDecimal::must_from_str("-1"),
21
2
        denom: "atom".to_string(),
22
2
    }
23
2
    .to_coin_floor();
24
2

            
25
2
    assert!(result.is_err());
26
2
}