From 06e4f9f0006a7efd64dd934e16711d4d26b1bb01 Mon Sep 17 00:00:00 2001 From: Stevengre Date: Wed, 29 Oct 2025 14:37:11 +0800 Subject: [PATCH 1/3] feat(spl): add domain data test --- .../src/entrypoint-runtime-verification.rs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/program/src/entrypoint-runtime-verification.rs b/program/src/entrypoint-runtime-verification.rs index 3416249..3c98d29 100644 --- a/program/src/entrypoint-runtime-verification.rs +++ b/program/src/entrypoint-runtime-verification.rs @@ -209,6 +209,42 @@ fn get_rent(_account_info: &AccountInfo) -> solana_rent::Rent { // fn cheatcode_is_multisig(_: &AccountInfo) {} // fn cheatcode_is_rent(_: &AccountInfo) {} +// special test for basic domain data access (SPL types) +#[inline(never)] +fn test_ptoken_domain_data(acc: &AccountInfo, mint: &AccountInfo, rent: &AccountInfo) { + // Mutate mint via standard unpack/pack flow; use unwraps for brevity in tests + let mut m = Mint::unpack_unchecked(&mint.data.borrow()).unwrap(); + m.is_initialized = true; + Mint::pack(m, &mut mint.data.borrow_mut()).unwrap(); + let m2 = Mint::unpack(&mint.data.borrow()).unwrap(); + assert!(m2.is_initialized); + + // Set Account.is_native in the simplest way (parity with p-token's boolean set_native(true)) + let mut a = Account::unpack_unchecked(&acc.data.borrow()).unwrap(); + a.is_native = solana_program_option::COption::Some(0); + Account::pack(a, &mut acc.data.borrow_mut()).unwrap(); + // Verify via the same wrapper accessor used elsewhere + let iacc = get_account(acc); + assert!(iacc.is_native()); + + // Basic owner self-check + let owner = acc.owner; + assert_eq!(acc.owner, owner); + + // Compare Rent from Sysvar::get vs account; fallback if not a real rent sysvar + let sysrent = solana_rent::Rent::get().unwrap(); + let min_a = sysrent.minimum_balance(10); + let prent = solana_rent::Rent::from_account_info(rent).unwrap_or(sysrent); + let min_b = prent.minimum_balance(10); + assert_eq!(min_a, min_b); +} + +// wrapper to ensure the test is retained in SMIR/IR outputs +#[no_mangle] +pub unsafe extern "C" fn use_tests(acc: &AccountInfo) { + test_ptoken_domain_data(acc, acc, acc); +} + // Inline `assume` is used directly in test harnesses; no helper functions needed. /// Inner instruction processor that dispatches to proof harnesses From 959173d36bd84b15f91b79add6c8ffa68254b0ee Mon Sep 17 00:00:00 2001 From: JianHong Zhao Date: Thu, 30 Oct 2025 08:03:47 +0800 Subject: [PATCH 2/3] Apply suggestion from @jberthold Co-authored-by: Jost Berthold --- program/src/entrypoint-runtime-verification.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/src/entrypoint-runtime-verification.rs b/program/src/entrypoint-runtime-verification.rs index 3c98d29..64ec737 100644 --- a/program/src/entrypoint-runtime-verification.rs +++ b/program/src/entrypoint-runtime-verification.rs @@ -211,7 +211,7 @@ fn get_rent(_account_info: &AccountInfo) -> solana_rent::Rent { // special test for basic domain data access (SPL types) #[inline(never)] -fn test_ptoken_domain_data(acc: &AccountInfo, mint: &AccountInfo, rent: &AccountInfo) { +fn test_spltoken_domain_data(acc: &AccountInfo, mint: &AccountInfo, rent: &AccountInfo) { // Mutate mint via standard unpack/pack flow; use unwraps for brevity in tests let mut m = Mint::unpack_unchecked(&mint.data.borrow()).unwrap(); m.is_initialized = true; From 49d0517a87b98ed3a3084bd473f76c7907935dcb Mon Sep 17 00:00:00 2001 From: JianHong Zhao Date: Thu, 30 Oct 2025 08:03:53 +0800 Subject: [PATCH 3/3] Apply suggestion from @jberthold Co-authored-by: Jost Berthold --- program/src/entrypoint-runtime-verification.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/src/entrypoint-runtime-verification.rs b/program/src/entrypoint-runtime-verification.rs index 64ec737..525fa12 100644 --- a/program/src/entrypoint-runtime-verification.rs +++ b/program/src/entrypoint-runtime-verification.rs @@ -242,7 +242,7 @@ fn test_spltoken_domain_data(acc: &AccountInfo, mint: &AccountInfo, rent: &Accou // wrapper to ensure the test is retained in SMIR/IR outputs #[no_mangle] pub unsafe extern "C" fn use_tests(acc: &AccountInfo) { - test_ptoken_domain_data(acc, acc, acc); + test_spltoken_domain_data(acc, acc, acc); } // Inline `assume` is used directly in test harnesses; no helper functions needed.