From 2d03f7e512f90d3a2c0baea134c809a58e9855a1 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 22:17:25 -0800 Subject: [PATCH] v2.1: svm: avoid rent collection in loader size test (backport of #3555) (#3560) svm: avoid rent collection in loader size test (#3555) (cherry picked from commit 7629a152d1c7748ebc3c3a11bf62445eae4c0e02) Co-authored-by: hana <81144685+2501babe@users.noreply.github.com> --- svm/src/account_loader.rs | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/svm/src/account_loader.rs b/svm/src/account_loader.rs index 2af7322b8f..d156e59329 100644 --- a/svm/src/account_loader.rs +++ b/svm/src/account_loader.rs @@ -2403,6 +2403,7 @@ mod tests { let program2_size = std::mem::size_of::() as u32; let mut program2_account = AccountSharedData::default(); program2_account.set_owner(loader_v3); + program2_account.set_lamports(LAMPORTS_PER_SOL); program2_account.set_executable(true); program2_account.set_data(vec![0; program2_size as usize]); program2_account @@ -2413,6 +2414,7 @@ mod tests { mock_bank.accounts_map.insert(program2, program2_account); let mut programdata2_account = AccountSharedData::default(); programdata2_account.set_owner(loader_v3); + programdata2_account.set_lamports(LAMPORTS_PER_SOL); programdata2_account.set_data(vec![0; program2_size as usize]); programdata2_account .set_state(&UpgradeableLoaderState::ProgramData { @@ -2665,23 +2667,16 @@ mod tests { program2_size + upgradeable_loader_size + fee_payer_size, ); - // programdata as readonly instruction account double-counts it + // programdata as instruction account double-counts it let ixns = vec![Instruction::new_with_bytes( program2, &[], vec![account_meta(programdata2, false)], )]; - let factor = if ixns[0].accounts[0].is_writable { - 1 - } else { - 2 - }; + test_data_size( ixns, - program2_size - + programdata2_size * factor - + upgradeable_loader_size - + fee_payer_size, + program2_size + programdata2_size * 2 + upgradeable_loader_size + fee_payer_size, ); // both as instruction accounts, for completeness @@ -2693,17 +2688,9 @@ mod tests { account_meta(programdata2, false), ], )]; - let factor = if ixns[0].accounts[0].is_writable { - 0 - } else { - 1 - }; test_data_size( ixns, - program2_size - + programdata2_size * factor - + upgradeable_loader_size - + fee_payer_size, + program2_size + programdata2_size + upgradeable_loader_size + fee_payer_size, ); // writable program bypasses the cache