Skip to content

Commit 2a504f8

Browse files
committed
fix: compressed-token-sdk tests
1 parent 448a641 commit 2a504f8

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

program-tests/sdk-token-test/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ pub mod sdk_token_test {
118118

119119
#[derive(Accounts)]
120120
pub struct Generic<'info> {
121+
// fee payer and authority are the same
121122
#[account(mut)]
122123
pub signer: Signer<'info>,
123124
}

sdk-libs/compressed-token-sdk/tests/account_metas_test.rs

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ fn test_to_compressed_token_account_metas_with_optional_accounts() {
9696
let registered_program_pda = Pubkey::new_unique();
9797
let account_compression_authority = Pubkey::new_unique();
9898
let system_program = Pubkey::default();
99+
let cpi_authority = Pubkey::from(CPI_AUTHORITY_PDA);
99100

100101
// Optional accounts
101102
let token_pool_pda = Pubkey::new_unique();
102103
let compress_or_decompress_token_account = Pubkey::new_unique();
103-
let token_program = Pubkey::new_unique();
104+
let spl_token_program = Pubkey::new_unique();
104105

105106
// Create TestAccounts and get AccountInfo references
106107
let mut fee_payer_account = TestAccount::new(fee_payer, Pubkey::default(), 0);
@@ -109,6 +110,7 @@ fn test_to_compressed_token_account_metas_with_optional_accounts() {
109110
let mut light_system_account =
110111
TestAccount::new(Pubkey::from(LIGHT_SYSTEM_PROGRAM_ID), Pubkey::default(), 0);
111112
let mut authority_account = TestAccount::new(authority, Pubkey::default(), 0);
113+
let mut cpi_authority_account = TestAccount::new(cpi_authority, Pubkey::default(), 0);
112114
let mut registered_program_account =
113115
TestAccount::new(registered_program_pda, Pubkey::default(), 0);
114116
let mut noop_account = TestAccount::new(Pubkey::from(NOOP_PROGRAM_ID), Pubkey::default(), 0);
@@ -119,7 +121,7 @@ fn test_to_compressed_token_account_metas_with_optional_accounts() {
119121
Pubkey::default(),
120122
0,
121123
);
122-
let mut token_program_account = TestAccount::new(
124+
let mut ctoken_program_account = TestAccount::new(
123125
Pubkey::from(COMPRESSED_TOKEN_PROGRAM_ID),
124126
Pubkey::default(),
125127
0,
@@ -132,45 +134,45 @@ fn test_to_compressed_token_account_metas_with_optional_accounts() {
132134
let mut compress_decompress_account =
133135
TestAccount::new(compress_or_decompress_token_account, Pubkey::default(), 0);
134136
compress_decompress_account.writable = true;
135-
let mut token_program_ctx_account = TestAccount::new(token_program, Pubkey::default(), 0);
137+
let mut spl_token_program_account = TestAccount::new(spl_token_program, Pubkey::default(), 0);
136138

137139
let fee_payer_info = fee_payer_account.get_account_info();
138140
let authority_info = authority_account.get_account_info();
139141

140142
// Create account infos in the correct order for CpiAccounts with all optional accounts
141143
let account_infos = vec![
142-
light_system_account.get_account_info(), // 0: light_system_program
143-
authority_info.clone(), // 1: authority
144+
cpi_authority_account.get_account_info(), // 1: authority (not cpi_authority)
145+
light_system_account.get_account_info(), // 0: light_system_program
144146
registered_program_account.get_account_info(), // 2: registered_program_pda
145-
noop_account.get_account_info(), // 3: noop_program
147+
noop_account.get_account_info(), // 3: noop_program
146148
compression_authority_account.get_account_info(), // 4: account_compression_authority
147149
compression_program_account.get_account_info(), // 5: account_compression_program
148-
token_program_account.get_account_info(), // 6: invoking_program (self_program)
149-
token_pool_account.get_account_info(), // 7: token_pool_pda
150+
ctoken_program_account.get_account_info(), // 6: invoking_program (self_program)
151+
token_pool_account.get_account_info(), // 7: token_pool_pda
150152
compress_decompress_account.get_account_info(), // 8: decompression_recipient (compress_or_decompress_token_account)
153+
spl_token_program_account.get_account_info(), // 10: cpi_context (spl_token_program)
151154
system_program_account.get_account_info(), // 9: system_program
152-
token_program_ctx_account.get_account_info(), // 10: cpi_context (token_program)
153155
];
154156

155157
let reference = light_compressed_token::accounts::TransferInstruction {
156158
fee_payer,
157159
authority,
160+
light_system_program: Pubkey::from(LIGHT_SYSTEM_PROGRAM_ID),
161+
cpi_authority_pda: Pubkey::from(CPI_AUTHORITY_PDA),
158162
registered_program_pda,
159163
noop_program: Pubkey::from(NOOP_PROGRAM_ID),
160164
account_compression_authority,
161165
account_compression_program: Pubkey::from(ACCOUNT_COMPRESSION_PROGRAM_ID),
162166
self_program: Pubkey::from(COMPRESSED_TOKEN_PROGRAM_ID),
163-
cpi_authority_pda: Pubkey::from(CPI_AUTHORITY_PDA),
164-
light_system_program: Pubkey::from(LIGHT_SYSTEM_PROGRAM_ID),
165167
token_pool_pda: Some(token_pool_pda),
166168
compress_or_decompress_token_account: Some(compress_or_decompress_token_account),
167-
token_program: Some(token_program),
169+
token_program: Some(spl_token_program),
168170
system_program,
169171
};
170172

171173
// Create CpiAccounts with config that enables all optional accounts
172174
let config = CpiAccountsConfig {
173-
cpi_context: true,
175+
cpi_context: false,
174176
compress: true,
175177
decompress: false,
176178
};
@@ -193,13 +195,4 @@ fn test_to_compressed_token_account_metas_with_optional_accounts() {
193195
*cpi_accounts.light_system_program().unwrap().key,
194196
Pubkey::from(LIGHT_SYSTEM_PROGRAM_ID)
195197
);
196-
// assert_eq!(
197-
// cpi_accounts.account_compression_authority(),
198-
// Some(account_compression_authority)
199-
// );
200-
// assert_eq!(cpi_accounts.fee_payer(), Some(fee_payer_info));
201-
// assert_eq!(
202-
// cpi_accounts.account_compression_authority(),
203-
// Some(account_compression_authority)
204-
// );
205198
}

0 commit comments

Comments
 (0)