Skip to content

Commit 6fb4811

Browse files
committed
chore: remove obsolete combine logic and tests
1 parent 75a3ad8 commit 6fb4811

File tree

2 files changed

+1
-99
lines changed

2 files changed

+1
-99
lines changed
Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use super::{
22
cpi_context::CompressedCpiContext,
33
data::{NewAddressParamsPacked, OutputCompressedAccountWithPackedContext},
4-
zero_copy::ZInstructionDataInvokeCpi,
54
};
65
use crate::{
76
compressed_account::PackedCompressedAccountWithMerkleContext,
@@ -21,99 +20,3 @@ pub struct InstructionDataInvokeCpi {
2120
pub is_compress: bool,
2221
pub cpi_context: Option<CompressedCpiContext>,
2322
}
24-
25-
impl<'a, 'info: 'a> ZInstructionDataInvokeCpi<'a> {
26-
pub fn combine(&mut self, other: Vec<ZInstructionDataInvokeCpi<'info>>) {
27-
for other in other {
28-
// TODO: support address creation with cpi context
29-
// issue is that we deserialize address creation params as zero copy slice we cannot push into it
30-
// could reenable by passing it as extra argument without losing performance.
31-
// self.new_address_params
32-
// .extend_from_slice(&other.new_address_params);
33-
for i in other.input_compressed_accounts_with_merkle_context.iter() {
34-
self.input_compressed_accounts_with_merkle_context
35-
.push((*i).clone());
36-
}
37-
for i in other.output_compressed_accounts.iter() {
38-
self.output_compressed_accounts.push((*i).clone());
39-
}
40-
}
41-
}
42-
}
43-
44-
#[cfg(test)]
45-
mod tests {
46-
use std::vec;
47-
48-
use light_zero_copy::borsh::Deserialize;
49-
50-
use super::*;
51-
use crate::{
52-
compressed_account::PackedCompressedAccountWithMerkleContext,
53-
instruction_data::{
54-
data::{NewAddressParamsPacked, OutputCompressedAccountWithPackedContext},
55-
invoke_cpi::InstructionDataInvokeCpi,
56-
zero_copy::ZInstructionDataInvokeCpi,
57-
},
58-
};
59-
60-
// test combine instruction data transfer
61-
#[test]
62-
fn test_combine_instruction_data_transfer() {
63-
let mut instruction_data_transfer = InstructionDataInvokeCpi {
64-
proof: Some(CompressedProof {
65-
a: [0; 32],
66-
b: [0; 64],
67-
c: [0; 32],
68-
}),
69-
new_address_params: vec![NewAddressParamsPacked::default()],
70-
input_compressed_accounts_with_merkle_context: vec![
71-
PackedCompressedAccountWithMerkleContext::default(),
72-
],
73-
output_compressed_accounts: vec![OutputCompressedAccountWithPackedContext::default()],
74-
relay_fee: None,
75-
compress_or_decompress_lamports: Some(1),
76-
is_compress: true,
77-
cpi_context: None,
78-
};
79-
instruction_data_transfer.input_compressed_accounts_with_merkle_context[0]
80-
.merkle_context
81-
.leaf_index = 1;
82-
instruction_data_transfer.output_compressed_accounts[0].merkle_tree_index = 1;
83-
let other = InstructionDataInvokeCpi {
84-
proof: Some(CompressedProof {
85-
a: [0; 32],
86-
b: [0; 64],
87-
c: [0; 32],
88-
}),
89-
input_compressed_accounts_with_merkle_context: vec![
90-
PackedCompressedAccountWithMerkleContext::default(),
91-
],
92-
output_compressed_accounts: vec![OutputCompressedAccountWithPackedContext::default()],
93-
relay_fee: None,
94-
compress_or_decompress_lamports: Some(1),
95-
is_compress: true,
96-
new_address_params: vec![NewAddressParamsPacked::default()],
97-
cpi_context: None,
98-
};
99-
let mut vec = Vec::new();
100-
instruction_data_transfer.serialize(&mut vec).unwrap();
101-
let mut other_vec = Vec::new();
102-
other.serialize(&mut other_vec).unwrap();
103-
let (mut instruction_data_transfer, _) =
104-
ZInstructionDataInvokeCpi::zero_copy_at(&vec).unwrap();
105-
let (other, _) = ZInstructionDataInvokeCpi::zero_copy_at(&other_vec).unwrap();
106-
instruction_data_transfer.combine(vec![other]);
107-
assert_eq!(instruction_data_transfer.new_address_params.len(), 1);
108-
assert_eq!(
109-
instruction_data_transfer
110-
.input_compressed_accounts_with_merkle_context
111-
.len(),
112-
2
113-
);
114-
assert_eq!(
115-
instruction_data_transfer.output_compressed_accounts.len(),
116-
2
117-
);
118-
}
119-
}

programs/system/src/invoke_cpi/process_cpi_context.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,8 @@ mod tests {
233233
use light_zero_copy::borsh::Deserialize;
234234
use pinocchio::pubkey::Pubkey;
235235

236-
use crate::invoke_cpi::processor::clear_cpi_context_account;
237-
238236
use super::*;
237+
use crate::invoke_cpi::processor::clear_cpi_context_account;
239238

240239
fn clean_input_data(instruction_data: &mut InstructionDataInvokeCpi) {
241240
instruction_data.cpi_context = None;

0 commit comments

Comments
 (0)