Skip to content

Commit

Permalink
merge write program match expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
2501babe committed Oct 17, 2024
1 parent 1243830 commit ae63530
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions svm/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,26 +928,23 @@ impl WriteProgramInstruction {
target: Pubkey,
clamp_data_size: Option<u32>,
) -> Transaction {
let instruction_data = match self {
Self::Print => vec![0],
Self::Set => vec![1],
Self::Dealloc => vec![2],
let (instruction_data, account_metas) = match self {
Self::Print => (vec![0], vec![AccountMeta::new_readonly(target, false)]),
Self::Set => (vec![1], vec![AccountMeta::new(target, false)]),
Self::Dealloc => (
vec![2],
vec![
AccountMeta::new(target, false),
AccountMeta::new(solana_sdk::incinerator::id(), false),
],
),
Self::Realloc(new_size) => {
let mut vec = vec![3];
vec.extend_from_slice(&new_size.to_le_bytes());
vec
let mut instruction_data = vec![3];
instruction_data.extend_from_slice(&new_size.to_le_bytes());
(instruction_data, vec![AccountMeta::new(target, false)])
}
};

let account_metas = match self {
Self::Dealloc => vec![
AccountMeta::new(target, false),
AccountMeta::new(solana_sdk::incinerator::id(), false),
],
Self::Print => vec![AccountMeta::new_readonly(target, false)],
_ => vec![AccountMeta::new(target, false)],
};

let mut instructions = vec![];

if let Some(size) = clamp_data_size {
Expand Down

0 comments on commit ae63530

Please sign in to comment.