Skip to content

Commit e7d02d4

Browse files
Fix light token Solana 4 tests
1 parent 3d65bf2 commit e7d02d4

4 files changed

Lines changed: 48 additions & 9 deletions

File tree

program-tests/compressed-token-test/tests/light_token/approve_revoke.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,18 @@ async fn test_revoke_fails() {
274274
.await
275275
.unwrap();
276276

277-
// Get the valid Light Token account data
277+
// Revoke only mutates accounts that have an active delegate. Without a
278+
// delegate, wrong-owner data can pass because no external data changes.
279+
let delegate = Keypair::new();
280+
approve_and_assert(
281+
&mut context,
282+
delegate.pubkey(),
283+
100,
284+
"approve_before_wrong_owner_revoke",
285+
)
286+
.await;
287+
288+
// Get the valid delegated Light Token account data.
278289
let valid_account = context
279290
.rpc
280291
.get_account(context.token_account_keypair.pubkey())

program-tests/compressed-token-test/tests/light_token/create.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,19 @@ async fn test_create_compressible_token_account_failing() {
241241
// This will fail during the transfer_lamports_via_cpi call.
242242
// Error: 1 (InsufficientFunds from system program)
243243
{
244-
// Create a payer with insufficient funds (only enough for tx fees + account creation)
244+
// Solana 4 rejects dust transfers to new system accounts, so fund the
245+
// poor payer above the zero-data rent floor while keeping it below the
246+
// amount required for token-account rent and top-ups.
245247
let poor_payer = Keypair::new();
248+
let poor_payer_lamports = context
249+
.rpc
250+
.get_minimum_balance_for_rent_exemption(0)
251+
.await
252+
.unwrap()
253+
+ 20_000;
246254
context
247255
.rpc
248-
.airdrop_lamports(&poor_payer.pubkey(), 10000) // Not enough for additional rent
256+
.airdrop_lamports(&poor_payer.pubkey(), poor_payer_lamports)
249257
.await
250258
.unwrap();
251259

program-tests/compressed-token-test/tests/light_token/create_ata.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,19 @@ async fn test_create_ata_failing() {
453453
// Payer doesn't have enough lamports for rent payment.
454454
// Error: 1 (InsufficientFunds from system program)
455455
{
456-
// Create a payer with insufficient funds (only enough for tx fees)
456+
// Solana 4 rejects dust transfers to new system accounts, so fund the
457+
// poor payer above the zero-data rent floor while keeping it below the
458+
// amount required for ATA rent and top-ups.
457459
let poor_payer = solana_sdk::signature::Keypair::new();
460+
let poor_payer_lamports = context
461+
.rpc
462+
.get_minimum_balance_for_rent_exemption(0)
463+
.await
464+
.unwrap()
465+
+ 20_000;
458466
context
459467
.rpc
460-
.airdrop_lamports(&poor_payer.pubkey(), 10000) // Not enough for rent
468+
.airdrop_lamports(&poor_payer.pubkey(), poor_payer_lamports)
461469
.await
462470
.unwrap();
463471

program-tests/compressed-token-test/tests/light_token/functional_ata.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,14 @@ async fn test_create_ata_with_prefunded_lamports() {
274274
// Derive ATA address
275275
let ata = derive_token_ata(&owner_pubkey, &context.mint_pubkey);
276276

277-
// Pre-fund the ATA address with lamports (simulating attacker donation DoS attempt)
278-
let prefund_amount = 1_000; // 1000 lamports
277+
// Pre-fund the ATA address with enough lamports for Solana 4 to allow the
278+
// transfer to create a zero-data system account.
279+
let prefund_amount = context
280+
.rpc
281+
.get_minimum_balance_for_rent_exemption(0)
282+
.await
283+
.unwrap()
284+
+ 1_000;
279285
let transfer_ix =
280286
solana_system_interface::instruction::transfer(&payer_pubkey, &ata, prefund_amount);
281287

@@ -362,8 +368,14 @@ async fn test_create_token_account_with_prefunded_lamports() {
362368
let payer_pubkey = context.payer.pubkey();
363369
let token_account_pubkey = context.token_account_keypair.pubkey();
364370

365-
// Pre-fund the token account address with lamports (simulating attacker donation DoS attempt)
366-
let prefund_amount = 1_000; // 1000 lamports
371+
// Pre-fund the token account address with enough lamports for Solana 4 to
372+
// allow the transfer to create a zero-data system account.
373+
let prefund_amount = context
374+
.rpc
375+
.get_minimum_balance_for_rent_exemption(0)
376+
.await
377+
.unwrap()
378+
+ 1_000;
367379
let transfer_ix = solana_system_interface::instruction::transfer(
368380
&payer_pubkey,
369381
&token_account_pubkey,

0 commit comments

Comments
 (0)