Refactor: Move InstructionRecorder
into TransactionContext
(#22578)
* Moves InstructionRecorder into TransactionContext. * Adds assertions for number_of_instructions_at_transaction_level.
This commit is contained in:
committed by
GitHub
parent
60850d71ce
commit
b448472037
@ -100,7 +100,7 @@ fn create_inputs() -> TransactionContext {
|
||||
},
|
||||
)
|
||||
.collect::<Vec<_>>();
|
||||
let mut transaction_context = TransactionContext::new(transaction_accounts, 1);
|
||||
let mut transaction_context = TransactionContext::new(transaction_accounts, 1, 1);
|
||||
let instruction_data = vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
||||
transaction_context
|
||||
.push(&[0], &instruction_accounts, &instruction_data)
|
||||
|
@ -456,7 +456,8 @@ mod tests {
|
||||
instruction_accounts,
|
||||
&program_indices,
|
||||
);
|
||||
let mut transaction_context = TransactionContext::new(preparation.transaction_accounts, 1);
|
||||
let mut transaction_context =
|
||||
TransactionContext::new(preparation.transaction_accounts, 1, 1);
|
||||
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
invoke_context
|
||||
.push(
|
||||
|
@ -3285,6 +3285,7 @@ mod tests {
|
||||
let mut transaction_context = TransactionContext::new(
|
||||
vec![(program_id, AccountSharedData::new(0, 0, &bpf_loader::id()))],
|
||||
1,
|
||||
1,
|
||||
);
|
||||
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
invoke_context.push(&[], &[0], &[]).unwrap();
|
||||
@ -3358,6 +3359,7 @@ mod tests {
|
||||
let mut transaction_context = TransactionContext::new(
|
||||
vec![(program_id, AccountSharedData::new(0, 0, &bpf_loader::id()))],
|
||||
1,
|
||||
1,
|
||||
);
|
||||
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
invoke_context.push(&[], &[0], &[]).unwrap();
|
||||
@ -3458,6 +3460,7 @@ mod tests {
|
||||
let mut transaction_context = TransactionContext::new(
|
||||
vec![(program_id, AccountSharedData::new(0, 0, &bpf_loader::id()))],
|
||||
1,
|
||||
1,
|
||||
);
|
||||
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
invoke_context.push(&[], &[0], &[]).unwrap();
|
||||
@ -3496,6 +3499,7 @@ mod tests {
|
||||
let mut transaction_context = TransactionContext::new(
|
||||
vec![(program_id, AccountSharedData::new(0, 0, &bpf_loader::id()))],
|
||||
1,
|
||||
1,
|
||||
);
|
||||
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
invoke_context.push(&[], &[0], &[]).unwrap();
|
||||
@ -3707,6 +3711,7 @@ mod tests {
|
||||
AccountSharedData::new(0, 0, &bpf_loader_deprecated::id()),
|
||||
)],
|
||||
1,
|
||||
1,
|
||||
);
|
||||
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
invoke_context.push(&[], &[0], &[]).unwrap();
|
||||
@ -3864,6 +3869,7 @@ mod tests {
|
||||
let mut transaction_context = TransactionContext::new(
|
||||
vec![(program_id, AccountSharedData::new(0, 0, &bpf_loader::id()))],
|
||||
1,
|
||||
1,
|
||||
);
|
||||
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
invoke_context.sysvar_cache = Cow::Owned(sysvar_cache);
|
||||
@ -4114,6 +4120,7 @@ mod tests {
|
||||
let mut transaction_context = TransactionContext::new(
|
||||
vec![(program_id, AccountSharedData::new(0, 0, &bpf_loader::id()))],
|
||||
1,
|
||||
1,
|
||||
);
|
||||
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
invoke_context.push(&[], &[0], &[]).unwrap();
|
||||
@ -4226,6 +4233,7 @@ mod tests {
|
||||
let mut transaction_context = TransactionContext::new(
|
||||
vec![(program_id, AccountSharedData::new(0, 0, &bpf_loader::id()))],
|
||||
1,
|
||||
1,
|
||||
);
|
||||
let mut invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
invoke_context.push(&[], &[0], &[]).unwrap();
|
||||
|
@ -4999,7 +4999,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_merge() {
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1, 1);
|
||||
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
let stake_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let source_stake_pubkey = solana_sdk::pubkey::new_rand();
|
||||
@ -5110,7 +5110,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_merge_self_fails() {
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1, 1);
|
||||
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
let stake_address = Pubkey::new_unique();
|
||||
let authority_pubkey = Pubkey::new_unique();
|
||||
@ -5156,7 +5156,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_merge_incorrect_authorized_staker() {
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1, 1);
|
||||
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
let stake_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let source_stake_pubkey = solana_sdk::pubkey::new_rand();
|
||||
@ -5226,7 +5226,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_merge_invalid_account_data() {
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1, 1);
|
||||
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
let stake_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let source_stake_pubkey = solana_sdk::pubkey::new_rand();
|
||||
@ -5277,7 +5277,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_merge_fake_stake_source() {
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1, 1);
|
||||
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
let stake_pubkey = solana_sdk::pubkey::new_rand();
|
||||
let source_stake_pubkey = solana_sdk::pubkey::new_rand();
|
||||
@ -5320,7 +5320,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_merge_active_stake() {
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1, 1);
|
||||
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
let base_lamports = 4242424242;
|
||||
let stake_address = Pubkey::new_unique();
|
||||
@ -5943,7 +5943,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_things_can_merge() {
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1, 1);
|
||||
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
let good_stake = Stake {
|
||||
credits_observed: 4242,
|
||||
@ -6042,7 +6042,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_metas_can_merge_pre_v4() {
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1, 1);
|
||||
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
// Identical Metas can merge
|
||||
assert!(MergeKind::metas_can_merge(
|
||||
@ -6129,7 +6129,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_metas_can_merge_v4() {
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1, 1);
|
||||
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
// Identical Metas can merge
|
||||
assert!(MergeKind::metas_can_merge(
|
||||
@ -6276,7 +6276,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_merge_kind_get_if_mergeable() {
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1, 1);
|
||||
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
let authority_pubkey = Pubkey::new_unique();
|
||||
let initial_lamports = 4242424242;
|
||||
@ -6509,7 +6509,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_merge_kind_merge() {
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1, 1);
|
||||
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
let lamports = 424242;
|
||||
let meta = Meta {
|
||||
@ -6588,7 +6588,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_active_stake_merge() {
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1);
|
||||
let mut transaction_context = TransactionContext::new(Vec::new(), 1, 1);
|
||||
let invoke_context = InvokeContext::new_mock(&mut transaction_context, &[]);
|
||||
let delegation_a = 4_242_424_242u64;
|
||||
let delegation_b = 6_200_000_000u64;
|
||||
|
@ -139,6 +139,7 @@ fn do_bench(bencher: &mut Bencher, feature: Option<Pubkey>) {
|
||||
(solana_vote_program::id(), AccountSharedData::default()),
|
||||
],
|
||||
1,
|
||||
1,
|
||||
);
|
||||
|
||||
let mut invoke_context = InvokeContext::new_mock_with_sysvars_and_features(
|
||||
|
Reference in New Issue
Block a user