Skip to content

Commit 61e7f94

Browse files
committed
fix: prevent compressible account funding with 1 epoch
1 parent 19842c7 commit 61e7f94

11 files changed

Lines changed: 146 additions & 66 deletions

File tree

program-tests/compressed-token-test/tests/account.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ async fn test_compressible_account_with_custom_rent_payer_close_with_owner() ->
400400
.get_minimum_balance_for_rent_exemption(COMPRESSIBLE_TOKEN_ACCOUNT_SIZE as usize)
401401
.await?;
402402

403-
let num_prepaid_epochs = 1;
403+
let num_prepaid_epochs = 2;
404404
let lamports_per_write = Some(100);
405405

406406
// Initialize compressible token account
@@ -571,7 +571,7 @@ async fn test_compressible_account_with_custom_rent_payer_close_with_compression
571571
.get_minimum_balance_for_rent_exemption(COMPRESSIBLE_TOKEN_ACCOUNT_SIZE as usize)
572572
.await?;
573573

574-
let num_prepaid_epochs = 1;
574+
let num_prepaid_epochs = 2;
575575
let lamports_per_write = Some(100);
576576

577577
// Initialize compressible token account
@@ -824,7 +824,7 @@ async fn test_compress_and_close_with_compression_authority() -> Result<(), RpcE
824824
owner_pubkey: context.owner_keypair.pubkey(),
825825
compressible_config: context.compressible_config,
826826
rent_sponsor: context.rent_sponsor,
827-
pre_pay_num_epochs: 1,
827+
pre_pay_num_epochs: 2,
828828
lamports_per_write: Some(150),
829829
payer: payer_pubkey,
830830
compress_to_account_pubkey: None,
@@ -842,7 +842,7 @@ async fn test_compress_and_close_with_compression_authority() -> Result<(), RpcE
842842
)
843843
.await?;
844844

845-
// Top up rent for one more epoch
845+
// Top up rent for one more epoch (total: 2 prepaid + 1 topped up = 3 epochs)
846846
context
847847
.rpc
848848
.airdrop_lamports(
@@ -852,9 +852,9 @@ async fn test_compress_and_close_with_compression_authority() -> Result<(), RpcE
852852
.await
853853
.unwrap();
854854

855-
// Advance to epoch 1 to make the account compressible
856-
// Account was created with 0 epochs of rent prepaid, so it's instantly compressible
857-
// But we still need to advance time to trigger the rent authority logic
855+
// Advance to epoch 1 (account not yet compressible - still has 2 epochs remaining)
856+
// Account was created with 2 epochs prepaid + 1 topped up = 3 epochs total
857+
// At epoch 1, only 1 epoch has passed, so 2 epochs of funding remain
858858
context.rpc.warp_to_slot(SLOTS_PER_EPOCH + 1).unwrap();
859859
let forster_keypair = context.rpc.test_accounts.protocol.forester.insecure_clone();
860860
// This doesnt work anymore we need to invoke the registry program now
@@ -877,10 +877,10 @@ async fn test_compress_and_close_with_compression_authority() -> Result<(), RpcE
877877
"{}",
878878
result.unwrap_err().to_string()
879879
);
880-
// Advance to epoch 1 to make the account compressible
881-
// Account was created with 0 epochs of rent prepaid, so it's instantly compressible
882-
// But we still need to advance time to trigger the rent authority logic
883-
context.rpc.warp_to_slot((SLOTS_PER_EPOCH * 2) + 1).unwrap();
880+
// Advance to epoch 3 to make the account compressible
881+
// Account was created with 2 epochs prepaid + 1 topped up = 3 epochs total
882+
// At epoch 3, all 3 epochs have passed, so the account is now compressible
883+
context.rpc.warp_to_slot((SLOTS_PER_EPOCH * 3) + 1).unwrap();
884884

885885
// Create a fresh destination pubkey to receive the compression incentive
886886
let destination = solana_sdk::signature::Keypair::new();

0 commit comments

Comments
 (0)