Skip to content

Commit

Permalink
v2.1: svm: avoid rent collection in loader size test (backport of #35…
Browse files Browse the repository at this point in the history
…55) (#3560)

svm: avoid rent collection in loader size test (#3555)

(cherry picked from commit 7629a152d1c7748ebc3c3a11bf62445eae4c0e02)

Co-authored-by: hana <[email protected]>
  • Loading branch information
mergify[bot] and 2501babe authored Nov 12, 2024
1 parent c6e88e4 commit 2d03f7e
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions svm/src/account_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2403,6 +2403,7 @@ mod tests {
let program2_size = std::mem::size_of::<UpgradeableLoaderState>() 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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2d03f7e

Please sign in to comment.