1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
pub const DECIMALS: u8 = 9;
solana_program::declare_id!("JUFMnWZ6ksBramrswzjQNraYAgHXbQPeC57URvxdcf8");
pub const PROGRAM_ADDRESS_SEEDS: &[&[u8]] = &["native-mint".as_bytes(), &[255]];
#[cfg(test)]
mod tests {
use {
super::*,
solana_program::{native_token::*, pubkey::Pubkey},
};
#[test]
fn test_decimals() {
assert!(
(lamports_to_sol(42) - crate::amount_to_ui_amount(42, DECIMALS)).abs() < f64::EPSILON
);
assert_eq!(
sol_to_lamports(42.),
crate::ui_amount_to_amount(42., DECIMALS)
);
}
#[test]
fn expected_native_mint_id() {
let native_mint_id =
Pubkey::create_program_address(PROGRAM_ADDRESS_SEEDS, &crate::id()).unwrap();
assert_eq!(id(), native_mint_id);
}
}