Skip to content

Commit 5014202

Browse files
committed
refine the spl-token domain test
1 parent e397276 commit 5014202

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

program/src/entrypoint-runtime-verification.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,15 @@ fn cheatcode_is_spl_rent(_: &AccountInfo) {}
277277
#[inline(never)]
278278
fn test_spltoken_domain_data(acc: &AccountInfo, mint: &AccountInfo, rent: &AccountInfo) {
279279
// Mutate mint via standard unpack/pack flow; use unwraps for brevity in tests
280+
cheatcode_is_spl_mint(mint);
280281
let mut m = Mint::unpack_unchecked(&mint.data.borrow()).unwrap();
281282
m.is_initialized = true;
282283
Mint::pack(m, &mut mint.data.borrow_mut()).unwrap();
283284
let m2 = Mint::unpack(&mint.data.borrow()).unwrap();
284285
assert!(m2.is_initialized);
285286

286287
// Set Account.is_native in the simplest way (parity with p-token's boolean set_native(true))
288+
cheatcode_is_spl_account(acc);
287289
let mut a = Account::unpack_unchecked(&acc.data.borrow()).unwrap();
288290
a.is_native = solana_program_option::COption::Some(0);
289291
Account::pack(a, &mut acc.data.borrow_mut()).unwrap();
@@ -295,12 +297,16 @@ fn test_spltoken_domain_data(acc: &AccountInfo, mint: &AccountInfo, rent: &Accou
295297
let owner = acc.owner;
296298
assert_eq!(acc.owner, owner);
297299

298-
// Compare Rent from Sysvar::get vs account; fallback if not a real rent sysvar
300+
// Compare Rent behavior using the sysvar getter and the provided account
299301
let sysrent = solana_rent::Rent::get().unwrap();
300-
let min_a = sysrent.minimum_balance(10);
302+
let rent_collected = 10;
303+
let (sys_burnt, sys_distributed) = sysrent.calculate_burn(rent_collected);
304+
assert!(sysrent.burn_percent > 100 || (sys_burnt <= rent_collected && sys_distributed <= rent_collected));
305+
306+
cheatcode_is_spl_rent(rent);
301307
let prent = solana_rent::Rent::from_account_info(rent).unwrap_or(sysrent);
302-
let min_b = prent.minimum_balance(10);
303-
assert_eq!(min_a, min_b);
308+
let (acct_burnt, acct_distributed) = prent.calculate_burn(rent_collected);
309+
assert!(prent.burn_percent > 100 || (acct_burnt <= rent_collected && acct_distributed <= rent_collected));
304310
}
305311

306312
// wrapper to ensure the test is retained in SMIR/IR outputs

0 commit comments

Comments
 (0)