@@ -175,6 +175,11 @@ async fn check_same_mint(context: &mut ProgramTestContext, program_id: &Pubkey)
175
175
)
176
176
. await ;
177
177
178
+ context. last_blockhash = context
179
+ . banks_client
180
+ . get_new_latest_blockhash ( & context. last_blockhash )
181
+ . await
182
+ . unwrap ( ) ;
178
183
let transaction = Transaction :: new_signed_with_payer (
179
184
& [ instruction:: recover_nested (
180
185
& wallet. pubkey ( ) ,
@@ -233,6 +238,11 @@ async fn check_different_mints(context: &mut ProgramTestContext, program_id: &Pu
233
238
let destination_token_address =
234
239
create_associated_token_account ( context, & wallet. pubkey ( ) , & nested_mint, program_id) . await ;
235
240
241
+ context. last_blockhash = context
242
+ . banks_client
243
+ . get_new_latest_blockhash ( & context. last_blockhash )
244
+ . await
245
+ . unwrap ( ) ;
236
246
let transaction = Transaction :: new_signed_with_payer (
237
247
& [ instruction:: recover_nested (
238
248
& wallet. pubkey ( ) ,
@@ -291,6 +301,11 @@ async fn check_missing_wallet_signature(context: &mut ProgramTestContext, progra
291
301
292
302
let mut recover = instruction:: recover_nested ( & wallet. pubkey ( ) , & mint, & mint, program_id) ;
293
303
recover. accounts [ 5 ] = AccountMeta :: new ( wallet. pubkey ( ) , false ) ;
304
+ context. last_blockhash = context
305
+ . banks_client
306
+ . get_new_latest_blockhash ( & context. last_blockhash )
307
+ . await
308
+ . unwrap ( ) ;
294
309
let transaction = Transaction :: new_signed_with_payer (
295
310
& [ recover] ,
296
311
Some ( & context. payer . pubkey ( ) ) ,
@@ -342,6 +357,11 @@ async fn check_wrong_signer(context: &mut ProgramTestContext, program_id: &Pubke
342
357
)
343
358
. await ;
344
359
360
+ context. last_blockhash = context
361
+ . banks_client
362
+ . get_new_latest_blockhash ( & context. last_blockhash )
363
+ . await
364
+ . unwrap ( ) ;
345
365
let transaction = Transaction :: new_signed_with_payer (
346
366
& [ instruction:: recover_nested (
347
367
& wrong_wallet. pubkey ( ) ,
@@ -385,14 +405,19 @@ async fn fail_wrong_signer() {
385
405
386
406
async fn check_not_nested ( context : & mut ProgramTestContext , program_id : & Pubkey ) {
387
407
let wallet = Keypair :: new ( ) ;
388
- let wrong_wallet = Keypair :: new ( ) ;
408
+ let wrong_wallet = Pubkey :: new_unique ( ) ;
389
409
let ( mint, mint_authority) = create_mint ( context, program_id) . await ;
390
410
391
411
let owner_associated_token_address =
392
412
create_associated_token_account ( context, & wallet. pubkey ( ) , & mint, program_id) . await ;
393
413
let nested_associated_token_address =
394
- create_associated_token_account ( context, & wrong_wallet. pubkey ( ) , & mint, program_id) . await ;
414
+ create_associated_token_account ( context, & wrong_wallet, & mint, program_id) . await ;
395
415
416
+ context. last_blockhash = context
417
+ . banks_client
418
+ . get_new_latest_blockhash ( & context. last_blockhash )
419
+ . await
420
+ . unwrap ( ) ;
396
421
let transaction = Transaction :: new_signed_with_payer (
397
422
& [ instruction:: recover_nested (
398
423
& wallet. pubkey ( ) ,
@@ -439,7 +464,7 @@ async fn check_wrong_address_derivation_owner(
439
464
program_id : & Pubkey ,
440
465
) {
441
466
let wallet = Keypair :: new ( ) ;
442
- let wrong_wallet = Keypair :: new ( ) ;
467
+ let wrong_wallet = Pubkey :: new_unique ( ) ;
443
468
let ( mint, mint_authority) = create_mint ( context, program_id) . await ;
444
469
445
470
let owner_associated_token_address =
@@ -453,9 +478,14 @@ async fn check_wrong_address_derivation_owner(
453
478
. await ;
454
479
455
480
let wrong_owner_associated_token_address =
456
- get_associated_token_address_with_program_id ( & mint, & wrong_wallet. pubkey ( ) , program_id) ;
481
+ get_associated_token_address_with_program_id ( & mint, & wrong_wallet, program_id) ;
457
482
let mut recover = instruction:: recover_nested ( & wallet. pubkey ( ) , & mint, & mint, program_id) ;
458
483
recover. accounts [ 3 ] = AccountMeta :: new ( wrong_owner_associated_token_address, false ) ;
484
+ context. last_blockhash = context
485
+ . banks_client
486
+ . get_new_latest_blockhash ( & context. last_blockhash )
487
+ . await
488
+ . unwrap ( ) ;
459
489
let transaction = Transaction :: new_signed_with_payer (
460
490
& [ recover] ,
461
491
Some ( & context. payer . pubkey ( ) ) ,
@@ -506,6 +536,11 @@ async fn check_owner_account_does_not_exist(context: &mut ProgramTestContext, pr
506
536
)
507
537
. await ;
508
538
539
+ context. last_blockhash = context
540
+ . banks_client
541
+ . get_new_latest_blockhash ( & context. last_blockhash )
542
+ . await
543
+ . unwrap ( ) ;
509
544
let transaction = Transaction :: new_signed_with_payer (
510
545
& [ instruction:: recover_nested (
511
546
& wallet. pubkey ( ) ,
@@ -559,6 +594,11 @@ async fn fail_wrong_spl_token_program() {
559
594
)
560
595
. await ;
561
596
597
+ context. last_blockhash = context
598
+ . banks_client
599
+ . get_new_latest_blockhash ( & context. last_blockhash )
600
+ . await
601
+ . unwrap ( ) ;
562
602
let transaction = Transaction :: new_signed_with_payer (
563
603
& [ instruction:: recover_nested (
564
604
& wallet. pubkey ( ) ,
@@ -587,7 +627,7 @@ async fn fail_wrong_spl_token_program() {
587
627
#[ tokio:: test]
588
628
async fn fail_destination_not_wallet_ata ( ) {
589
629
let wallet = Keypair :: new ( ) ;
590
- let wrong_wallet = Keypair :: new ( ) ;
630
+ let wrong_wallet = Pubkey :: new_unique ( ) ;
591
631
let dummy_mint = Pubkey :: new_unique ( ) ;
592
632
let pt = program_test_2022 ( dummy_mint, true ) ;
593
633
let program_id = spl_token_2022:: id ( ) ;
@@ -604,13 +644,17 @@ async fn fail_destination_not_wallet_ata() {
604
644
)
605
645
. await ;
606
646
let wrong_destination_associated_token_account_address =
607
- create_associated_token_account ( & mut context, & wrong_wallet. pubkey ( ) , & mint, & program_id)
608
- . await ;
647
+ create_associated_token_account ( & mut context, & wrong_wallet, & mint, & program_id) . await ;
609
648
610
649
let mut recover = instruction:: recover_nested ( & wallet. pubkey ( ) , & mint, & mint, & program_id) ;
611
650
recover. accounts [ 2 ] =
612
651
AccountMeta :: new ( wrong_destination_associated_token_account_address, false ) ;
613
652
653
+ context. last_blockhash = context
654
+ . banks_client
655
+ . get_new_latest_blockhash ( & context. last_blockhash )
656
+ . await
657
+ . unwrap ( ) ;
614
658
let transaction = Transaction :: new_signed_with_payer (
615
659
& [ recover] ,
616
660
Some ( & context. payer . pubkey ( ) ) ,
0 commit comments