Skip to content

Commit 2d03f7e

Browse files
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 7629a15) Co-authored-by: hana <[email protected]>
1 parent c6e88e4 commit 2d03f7e

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

svm/src/account_loader.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,6 +2403,7 @@ mod tests {
24032403
let program2_size = std::mem::size_of::<UpgradeableLoaderState>() as u32;
24042404
let mut program2_account = AccountSharedData::default();
24052405
program2_account.set_owner(loader_v3);
2406+
program2_account.set_lamports(LAMPORTS_PER_SOL);
24062407
program2_account.set_executable(true);
24072408
program2_account.set_data(vec![0; program2_size as usize]);
24082409
program2_account
@@ -2413,6 +2414,7 @@ mod tests {
24132414
mock_bank.accounts_map.insert(program2, program2_account);
24142415
let mut programdata2_account = AccountSharedData::default();
24152416
programdata2_account.set_owner(loader_v3);
2417+
programdata2_account.set_lamports(LAMPORTS_PER_SOL);
24162418
programdata2_account.set_data(vec![0; program2_size as usize]);
24172419
programdata2_account
24182420
.set_state(&UpgradeableLoaderState::ProgramData {
@@ -2665,23 +2667,16 @@ mod tests {
26652667
program2_size + upgradeable_loader_size + fee_payer_size,
26662668
);
26672669

2668-
// programdata as readonly instruction account double-counts it
2670+
// programdata as instruction account double-counts it
26692671
let ixns = vec![Instruction::new_with_bytes(
26702672
program2,
26712673
&[],
26722674
vec![account_meta(programdata2, false)],
26732675
)];
2674-
let factor = if ixns[0].accounts[0].is_writable {
2675-
1
2676-
} else {
2677-
2
2678-
};
2676+
26792677
test_data_size(
26802678
ixns,
2681-
program2_size
2682-
+ programdata2_size * factor
2683-
+ upgradeable_loader_size
2684-
+ fee_payer_size,
2679+
program2_size + programdata2_size * 2 + upgradeable_loader_size + fee_payer_size,
26852680
);
26862681

26872682
// both as instruction accounts, for completeness
@@ -2693,17 +2688,9 @@ mod tests {
26932688
account_meta(programdata2, false),
26942689
],
26952690
)];
2696-
let factor = if ixns[0].accounts[0].is_writable {
2697-
0
2698-
} else {
2699-
1
2700-
};
27012691
test_data_size(
27022692
ixns,
2703-
program2_size
2704-
+ programdata2_size * factor
2705-
+ upgradeable_loader_size
2706-
+ fee_payer_size,
2693+
program2_size + programdata2_size + upgradeable_loader_size + fee_payer_size,
27072694
);
27082695

27092696
// writable program bypasses the cache

0 commit comments

Comments
 (0)