Skip to content

Commit 508d00b

Browse files
committed
test: restore verify signer test
1 parent d1deccd commit 508d00b

File tree

2 files changed

+59
-66
lines changed

2 files changed

+59
-66
lines changed

programs/system/src/invoke/verify_signer.rs

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -31,68 +31,68 @@ pub fn input_compressed_accounts_signer_check(
3131
)
3232
}
3333

34-
// #[cfg(test)]
35-
// mod test {
36-
// use anchor_lang::prelude::borsh::BorshSerialize;
37-
// use light_compressed_account::compressed_account::{
38-
// CompressedAccount, PackedCompressedAccountWithMerkleContext,
39-
// };
40-
// use light_zero_copy::borsh::Deserialize;
34+
#[cfg(test)]
35+
mod test {
36+
use borsh::BorshSerialize;
37+
use light_compressed_account::compressed_account::{
38+
CompressedAccount, PackedCompressedAccountWithMerkleContext,
39+
};
40+
use light_zero_copy::borsh::Deserialize;
4141

42-
// use super::*;
42+
use super::*;
4343

44-
// #[test]
45-
// fn test_input_compressed_accounts_signer_check() {
46-
// let authority = Pubkey::new_unique();
44+
#[test]
45+
fn test_input_compressed_accounts_signer_check() {
46+
let authority = solana_pubkey::Pubkey::new_unique().to_bytes();
4747

48-
// let compressed_account_with_context = PackedCompressedAccountWithMerkleContext {
49-
// compressed_account: CompressedAccount {
50-
// owner: authority,
51-
// ..CompressedAccount::default()
52-
// },
53-
// ..PackedCompressedAccountWithMerkleContext::default()
54-
// };
55-
// let bytes = compressed_account_with_context.try_to_vec().unwrap();
56-
// let compressed_account_with_context =
57-
// ZPackedCompressedAccountWithMerkleContext::zero_copy_at(&bytes)
58-
// .unwrap()
59-
// .0;
48+
let compressed_account_with_context = PackedCompressedAccountWithMerkleContext {
49+
compressed_account: CompressedAccount {
50+
owner: authority,
51+
..CompressedAccount::default()
52+
},
53+
..PackedCompressedAccountWithMerkleContext::default()
54+
};
55+
let bytes = compressed_account_with_context.try_to_vec().unwrap();
56+
let compressed_account_with_context =
57+
ZPackedCompressedAccountWithMerkleContext::zero_copy_at(&bytes)
58+
.unwrap()
59+
.0;
6060

61-
// assert_eq!(
62-
// input_compressed_accounts_signer_check(
63-
// &[compressed_account_with_context.clone()],
64-
// &authority
65-
// ),
66-
// Ok(())
67-
// );
61+
assert_eq!(
62+
input_compressed_accounts_signer_check(
63+
&[compressed_account_with_context.clone()],
64+
&authority
65+
),
66+
Ok(())
67+
);
6868

69-
// {
70-
// let invalid_compressed_account_with_context =
71-
// PackedCompressedAccountWithMerkleContext {
72-
// compressed_account: CompressedAccount {
73-
// owner: Pubkey::new_unique(),
74-
// ..CompressedAccount::default()
75-
// },
76-
// ..PackedCompressedAccountWithMerkleContext::default()
77-
// };
69+
{
70+
let invalid_compressed_account_with_context =
71+
PackedCompressedAccountWithMerkleContext {
72+
compressed_account: CompressedAccount {
73+
owner: solana_pubkey::Pubkey::new_unique().to_bytes(),
74+
..CompressedAccount::default()
75+
},
76+
..PackedCompressedAccountWithMerkleContext::default()
77+
};
7878

79-
// let bytes = invalid_compressed_account_with_context
80-
// .try_to_vec()
81-
// .unwrap();
82-
// let invalid_compressed_account_with_context =
83-
// ZPackedCompressedAccountWithMerkleContext::zero_copy_at(&bytes)
84-
// .unwrap()
85-
// .0;
86-
// assert_eq!(
87-
// input_compressed_accounts_signer_check(
88-
// &[
89-
// compressed_account_with_context,
90-
// invalid_compressed_account_with_context
91-
// ],
92-
// &authority
93-
// ),
94-
// Err(SystemProgramError::SignerCheckFailed.into())
95-
// );
96-
// }
97-
// }
98-
// }
79+
let bytes = invalid_compressed_account_with_context
80+
.try_to_vec()
81+
.unwrap();
82+
let invalid_compressed_account_with_context =
83+
ZPackedCompressedAccountWithMerkleContext::zero_copy_at(&bytes)
84+
.unwrap()
85+
.0;
86+
assert_eq!(
87+
input_compressed_accounts_signer_check(
88+
&[
89+
compressed_account_with_context,
90+
invalid_compressed_account_with_context
91+
],
92+
&authority
93+
),
94+
Err(SystemProgramError::SignerCheckFailed.into())
95+
);
96+
}
97+
}
98+
}

programs/system/tests/invoke_instruction.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,6 @@ fn failing_from_account_infos() {
115115
InvokeInstruction::from_account_infos(account_info_array.as_slice()).unwrap();
116116
assert!(invoke_cpi_instruction == ref_invoke_cpi_instruction);
117117
}
118-
// 2. Authority mutable
119-
{
120-
let mut account_info_array = account_info_array.clone();
121-
account_info_array[1] = get_fee_payer_account_info();
122-
let res = InvokeInstruction::from_account_infos(account_info_array.as_slice());
123-
assert!(res == Err(ProgramError::from(AccountError::AccountMutable)));
124-
}
125118
// 3. Registered Program Pda mutable
126119
{
127120
let mut account_info_array = account_info_array.clone();

0 commit comments

Comments
 (0)