1515 solana_system_interface:: program as system_program,
1616 spl_single_pool:: {
1717 error:: SinglePoolError ,
18- find_pool_onramp_address , id,
18+ id,
1919 instruction:: { self , SinglePoolInstruction } ,
2020 } ,
2121 spl_token_interface as spl_token,
@@ -36,7 +36,6 @@ async fn build_instructions(
3636 context : & mut ProgramTestContext ,
3737 accounts : & SinglePoolAccounts ,
3838 test_mode : TestMode ,
39- remove_onramp : bool ,
4039) -> ( Vec < Instruction > , usize ) {
4140 let initialize_instructions = if test_mode == TestMode :: Initialize {
4241 let slot = context. genesis_config ( ) . epoch_schedule . first_normal_slot + 1 ;
@@ -86,7 +85,7 @@ async fn build_instructions(
8685 vec ! [ ]
8786 } ;
8887
89- let mut deposit_instructions = instruction:: deposit (
88+ let deposit_instructions = instruction:: deposit (
9089 & id ( ) ,
9190 & accounts. pool ,
9291 & accounts. alice_stake . pubkey ( ) ,
@@ -95,7 +94,7 @@ async fn build_instructions(
9594 & accounts. alice . pubkey ( ) ,
9695 ) ;
9796
98- let mut withdraw_instructions = if test_mode == TestMode :: Withdraw {
97+ let withdraw_instructions = if test_mode == TestMode :: Withdraw {
9998 let transaction = Transaction :: new_signed_with_payer (
10099 & deposit_instructions,
101100 Some ( & accounts. alice . pubkey ( ) ) ,
@@ -131,17 +130,6 @@ async fn build_instructions(
131130 vec ! [ ]
132131 } ;
133132
134- if remove_onramp {
135- let instruction = match test_mode {
136- TestMode :: Deposit => deposit_instructions. last_mut ( ) . unwrap ( ) ,
137- TestMode :: Withdraw => withdraw_instructions. last_mut ( ) . unwrap ( ) ,
138- TestMode :: Initialize => unreachable ! ( ) ,
139- } ;
140-
141- assert_eq ! ( instruction. accounts[ 2 ] . pubkey, accounts. onramp_account) ;
142- instruction. accounts . remove ( 2 ) ;
143- }
144-
145133 // ints hardcoded to guard against instructions moving with code changes
146134 // if these asserts fail, update them to match the new multi-instruction builders
147135 let ( instructions, index, enum_tag) = match test_mode {
@@ -159,28 +147,17 @@ async fn build_instructions(
159147// test that account addresses are checked properly
160148#[ test_matrix(
161149 [ StakeProgramVersion :: Stable , StakeProgramVersion :: Beta , StakeProgramVersion :: Edge ] ,
162- [ TestMode :: Initialize , TestMode :: Deposit , TestMode :: Withdraw ] ,
163- [ false , true ]
150+ [ TestMode :: Initialize , TestMode :: Deposit , TestMode :: Withdraw ]
164151) ]
165152#[ tokio:: test]
166- async fn fail_account_checks (
167- stake_version : StakeProgramVersion ,
168- test_mode : TestMode ,
169- remove_onramp : bool ,
170- ) {
171- // initialize does not take the onramp account
172- if test_mode == TestMode :: Initialize && remove_onramp {
173- return ;
174- }
175-
153+ async fn fail_account_checks ( stake_version : StakeProgramVersion , test_mode : TestMode ) {
176154 let Some ( program_test) = program_test ( stake_version) else {
177155 return ;
178156 } ;
179157 let mut context = program_test. start_with_context ( ) . await ;
180158
181159 let accounts = SinglePoolAccounts :: default ( ) ;
182- let ( instructions, i) =
183- build_instructions ( & mut context, & accounts, test_mode, remove_onramp) . await ;
160+ let ( instructions, i) = build_instructions ( & mut context, & accounts, test_mode) . await ;
184161 let bad_pubkey = pubkey ! ( "BAD1111111111111111111111111111111111111111" ) ;
185162
186163 for j in 0 ..instructions[ i] . accounts . len ( ) {
@@ -192,18 +169,6 @@ async fn fail_account_checks(
192169 continue ;
193170 }
194171
195- // while onramp is optional, an incorrect onramp misaligns all subsequent accounts
196- // this is not a problem for the program and causes the mint to fail to validate, but requires tweaking this test
197- if !remove_onramp && instruction_pubkey == accounts. pool {
198- if let Some ( onramp_account) = instructions[ i]
199- . accounts
200- . iter_mut ( )
201- . find ( |account| account. pubkey == accounts. onramp_account )
202- {
203- onramp_account. pubkey = find_pool_onramp_address ( & id ( ) , & bad_pubkey) ;
204- }
205- }
206-
207172 instructions[ i] . accounts [ j] . pubkey = bad_pubkey;
208173
209174 let transaction = Transaction :: new_signed_with_payer (
@@ -226,7 +191,7 @@ async fn fail_account_checks(
226191 } else if instruction_pubkey == accounts. stake_account {
227192 check_error ( e, SinglePoolError :: InvalidPoolStakeAccount )
228193 } else if instruction_pubkey == accounts. onramp_account {
229- // NOTE add onramp error here when onramp is mandatory
194+ check_error ( e , SinglePoolError :: InvalidPoolOnRampAccount )
230195 } else if instruction_pubkey == accounts. stake_authority {
231196 check_error ( e, SinglePoolError :: InvalidPoolStakeAuthority )
232197 } else if instruction_pubkey == accounts. mint_authority {
0 commit comments