@@ -92,283 +92,3 @@ async fn init_default_success() {
9292 assert_account_empty ( context, & candy_manager. collection_info . pda ) . await ;
9393 assert ! ( post_balance > pre_balance) ;
9494}
95-
96- #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
97- async fn bot_tax_on_gatekeeper_expire_token ( ) {
98- test_start ( "Bot Tax On Gatekeeper Expire Token" ) ;
99- let mut context = candy_machine_program_test ( ) . start_with_context ( ) . await ;
100- let context = & mut context;
101-
102- let gatekeeper_network = Keypair :: new ( ) ;
103- let gatekeeper_authority = Keypair :: new ( ) ;
104-
105- let client = RpcClient :: new ( "https://api.devnet.solana.com" . to_string ( ) ) ;
106-
107- let gateway_account_pubkey = GATEWAY_ACCOUNT_PUBKEY ;
108- let gateway_executable_pubkey =
109- Pubkey :: from_str ( "D5iXG4Z4hajVFAs8UbmBwdfe7PFqvoT4LNVvt1nKU5bx" ) . unwrap ( ) ;
110- let gateway_account = client. get_account ( & gateway_account_pubkey) . unwrap ( ) ;
111- let gateway_executable_account = client. get_account ( & gateway_executable_pubkey) . unwrap ( ) ;
112- context. set_account ( & gateway_account_pubkey, & gateway_account. into ( ) ) ;
113- context. set_account (
114- & gateway_executable_pubkey,
115- & gateway_executable_account. into ( ) ,
116- ) ;
117-
118- let mut candy_manager = CandyManager :: init (
119- context,
120- None ,
121- false ,
122- None ,
123- None ,
124- Some ( GatekeeperInfo {
125- set : true ,
126- network_expire_feature : None ,
127- gateway_app : GATEWAY_ACCOUNT_PUBKEY ,
128- gateway_token_info : gatekeeper_network. pubkey ( ) ,
129- gatekeeper_config : GatekeeperConfig {
130- gatekeeper_network : gatekeeper_network. pubkey ( ) ,
131- expire_on_use : true ,
132- } ,
133- } ) ,
134- )
135- . await ;
136-
137- airdrop ( context, & candy_manager. minter . pubkey ( ) , sol ( 2.0 ) )
138- . await
139- . unwrap ( ) ;
140-
141- let candy_data = custom_config (
142- candy_manager. authority . pubkey ( ) ,
143- Some ( 0 ) ,
144- true ,
145- true ,
146- None ,
147- None ,
148- None ,
149- Some ( GKConfig {
150- gatekeeper_network : gatekeeper_network. pubkey ( ) ,
151- expire_on_use : true ,
152- } ) ,
153- ) ;
154-
155- candy_manager
156- . create ( context, candy_data. clone ( ) )
157- . await
158- . unwrap ( ) ;
159- candy_manager. fill_config_lines ( context) . await . unwrap ( ) ;
160-
161- let block_hash = context. banks_client . get_latest_blockhash ( ) . await . unwrap ( ) ;
162- let transaction = Transaction :: new_signed_with_payer (
163- & [ instruction:: add_gatekeeper (
164- & candy_manager. minter . pubkey ( ) ,
165- & gatekeeper_authority. pubkey ( ) ,
166- & gatekeeper_network. pubkey ( ) ,
167- ) ] ,
168- Some ( & candy_manager. minter . pubkey ( ) ) ,
169- & [ & candy_manager. minter , & gatekeeper_network] ,
170- block_hash,
171- ) ;
172-
173- context
174- . banks_client
175- . process_transaction ( transaction)
176- . await
177- . unwrap ( ) ;
178-
179- let ( gatekeeper_account, _) = get_gatekeeper_address_with_seed (
180- & gatekeeper_authority. pubkey ( ) ,
181- & gatekeeper_network. pubkey ( ) ,
182- ) ;
183-
184- let start = SystemTime :: now ( ) ;
185- let now = start
186- . duration_since ( UNIX_EPOCH )
187- . expect ( "Time went backwards" ) ;
188-
189- // creating with an already expired token to fail the mint
190- let block_hash = context. banks_client . get_latest_blockhash ( ) . await . unwrap ( ) ;
191- let transaction = Transaction :: new_signed_with_payer (
192- & [ instruction:: issue_vanilla (
193- & context. payer . pubkey ( ) ,
194- & candy_manager. minter . pubkey ( ) ,
195- & gatekeeper_account,
196- & gatekeeper_authority. pubkey ( ) ,
197- & gatekeeper_network. pubkey ( ) ,
198- None ,
199- Some ( now. as_secs ( ) as UnixTimestamp - 10 ) ,
200- ) ] ,
201- Some ( & context. payer . pubkey ( ) ) ,
202- & [ & context. payer , & gatekeeper_authority] ,
203- block_hash,
204- ) ;
205-
206- context
207- . banks_client
208- . process_transaction ( transaction)
209- . await
210- . unwrap ( ) ;
211-
212- let block_hash = context. banks_client . get_latest_blockhash ( ) . await . unwrap ( ) ;
213- context
214- . banks_client
215- . process_transaction ( Transaction :: new_signed_with_payer (
216- & [ instruction:: add_feature_to_network (
217- context. payer . pubkey ( ) ,
218- gatekeeper_network. pubkey ( ) ,
219- NetworkFeature :: UserTokenExpiry ,
220- ) ] ,
221- Some ( & context. payer . pubkey ( ) ) ,
222- & [ & context. payer , & gatekeeper_network] ,
223- block_hash,
224- ) )
225- . await
226- . unwrap ( ) ;
227-
228- candy_manager
229- . mint_and_assert_bot_tax ( context)
230- . await
231- . unwrap ( ) ;
232- }
233-
234- #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
235- async fn bot_tax_on_gatekeeper ( ) {
236- test_start ( "Bot Tax On Gatekeeper" ) ;
237- let mut context = candy_machine_program_test ( ) . start_with_context ( ) . await ;
238- let context = & mut context;
239-
240- let gatekeeper_network = Keypair :: new ( ) ;
241- let gatekeeper_authority = Keypair :: new ( ) ;
242-
243- let client = RpcClient :: new ( "https://api.devnet.solana.com" . to_string ( ) ) ;
244-
245- let gateway_account_pubkey = GATEWAY_ACCOUNT_PUBKEY ;
246- let gateway_executable_pubkey =
247- Pubkey :: from_str ( "D5iXG4Z4hajVFAs8UbmBwdfe7PFqvoT4LNVvt1nKU5bx" ) . unwrap ( ) ;
248- let gateway_account = client. get_account ( & gateway_account_pubkey) . unwrap ( ) ;
249- let gateway_executable_account = client. get_account ( & gateway_executable_pubkey) . unwrap ( ) ;
250- context. set_account ( & gateway_account_pubkey, & gateway_account. into ( ) ) ;
251- context. set_account (
252- & gateway_executable_pubkey,
253- & gateway_executable_account. into ( ) ,
254- ) ;
255-
256- let mut candy_manager = CandyManager :: init (
257- context,
258- None ,
259- false ,
260- None ,
261- None ,
262- Some ( GatekeeperInfo {
263- set : true ,
264- network_expire_feature : None ,
265- gateway_app : GATEWAY_ACCOUNT_PUBKEY ,
266- gateway_token_info : gatekeeper_network. pubkey ( ) ,
267- gatekeeper_config : GatekeeperConfig {
268- gatekeeper_network : gatekeeper_network. pubkey ( ) ,
269- expire_on_use : false ,
270- } ,
271- } ) ,
272- )
273- . await ;
274-
275- airdrop ( context, & candy_manager. minter . pubkey ( ) , sol ( 2.0 ) )
276- . await
277- . unwrap ( ) ;
278-
279- let candy_data = custom_config (
280- candy_manager. authority . pubkey ( ) ,
281- Some ( 0 ) ,
282- true ,
283- true ,
284- None ,
285- None ,
286- None ,
287- Some ( GKConfig {
288- gatekeeper_network : gatekeeper_network. pubkey ( ) ,
289- expire_on_use : false ,
290- } ) ,
291- ) ;
292-
293- candy_manager
294- . create ( context, candy_data. clone ( ) )
295- . await
296- . unwrap ( ) ;
297- candy_manager. fill_config_lines ( context) . await . unwrap ( ) ;
298-
299- let block_hash = context. banks_client . get_latest_blockhash ( ) . await . unwrap ( ) ;
300- let transaction = Transaction :: new_signed_with_payer (
301- & [ instruction:: add_gatekeeper (
302- & candy_manager. minter . pubkey ( ) ,
303- & gatekeeper_authority. pubkey ( ) ,
304- & gatekeeper_network. pubkey ( ) ,
305- ) ] ,
306- Some ( & candy_manager. minter . pubkey ( ) ) ,
307- & [ & candy_manager. minter , & gatekeeper_network] ,
308- block_hash,
309- ) ;
310-
311- context
312- . banks_client
313- . process_transaction ( transaction)
314- . await
315- . unwrap ( ) ;
316-
317- let ( gatekeeper_account, _) = get_gatekeeper_address_with_seed (
318- & gatekeeper_authority. pubkey ( ) ,
319- & gatekeeper_network. pubkey ( ) ,
320- ) ;
321-
322- let block_hash = context. banks_client . get_latest_blockhash ( ) . await . unwrap ( ) ;
323- let transaction = Transaction :: new_signed_with_payer (
324- & [ instruction:: issue_vanilla (
325- & context. payer . pubkey ( ) ,
326- & candy_manager. minter . pubkey ( ) ,
327- & gatekeeper_account,
328- & gatekeeper_authority. pubkey ( ) ,
329- & gatekeeper_network. pubkey ( ) ,
330- None ,
331- None ,
332- ) ] ,
333- Some ( & context. payer . pubkey ( ) ) ,
334- & [ & context. payer , & gatekeeper_authority] ,
335- block_hash,
336- ) ;
337-
338- context
339- . banks_client
340- . process_transaction ( transaction)
341- . await
342- . unwrap ( ) ;
343-
344- let ( gateway_account, _) = get_gateway_token_address_with_seed (
345- & candy_manager. minter . pubkey ( ) ,
346- & None ,
347- & gatekeeper_network. pubkey ( ) ,
348- ) ;
349-
350- let block_hash = context. banks_client . get_latest_blockhash ( ) . await . unwrap ( ) ;
351- // revoking the token so verification fails inside of gateway triggering bot tax
352- let transaction = Transaction :: new_signed_with_payer (
353- & [ instruction:: set_state (
354- & gateway_account,
355- & gatekeeper_authority. pubkey ( ) ,
356- & gatekeeper_account,
357- GatewayTokenState :: Revoked ,
358- ) ] ,
359- Some ( & context. payer . pubkey ( ) ) ,
360- & [ & context. payer , & gatekeeper_authority] ,
361- block_hash,
362- ) ;
363-
364- context
365- . banks_client
366- . process_transaction ( transaction)
367- . await
368- . unwrap ( ) ;
369-
370- candy_manager
371- . mint_and_assert_bot_tax ( context)
372- . await
373- . unwrap ( ) ;
374- }
0 commit comments