@@ -6,6 +6,8 @@ use matching_engine::{CCTP_MINT_RECIPIENT, ID as PROGRAM_ID};
6
6
use shimless:: execute_order:: execute_order_shimless_test;
7
7
use solana_program_test:: tokio;
8
8
use solana_sdk:: pubkey:: Pubkey ;
9
+ use testing_engine:: config:: CreateCctpRouterEndpointsInstructionConfig ;
10
+ use utils:: constants;
9
11
mod shimful;
10
12
mod shimless;
11
13
mod testing_engine;
@@ -22,7 +24,7 @@ use shimful::shims::{
22
24
use shimful:: shims_execute_order:: execute_order_fallback_test;
23
25
use shimless:: initialize:: { initialize_program, AuctionParametersConfig } ;
24
26
use shimless:: make_offer:: { improve_offer, place_initial_offer_shimless} ;
25
- use solana_sdk:: transaction:: VersionedTransaction ;
27
+ use solana_sdk:: transaction:: { TransactionError , VersionedTransaction } ;
26
28
use utils:: auction:: AuctionAccounts ;
27
29
use utils:: router:: { add_local_router_endpoint_ix, create_all_router_endpoints_test} ;
28
30
use utils:: setup:: { setup_environment, ShimMode , TestingContext , TransferDirection } ;
@@ -41,13 +43,13 @@ pub async fn test_initialize_program() {
41
43
42
44
let initialize_config = InitializeInstructionConfig :: default ( ) ;
43
45
44
- let testing_engine = TestingEngine :: new (
45
- testing_context,
46
- vec ! [ InstructionTrigger :: InitializeProgram ( initialize_config) ] ,
47
- )
48
- . await ;
46
+ let testing_engine = TestingEngine :: new ( testing_context) . await ;
49
47
50
- testing_engine. execute ( ) . await ;
48
+ testing_engine
49
+ . execute ( vec ! [ InstructionTrigger :: InitializeProgram (
50
+ initialize_config,
51
+ ) ] )
52
+ . await ;
51
53
}
52
54
53
55
/// Test that a CCTP token router endpoint is created for the arbitrum and ethereum chains
@@ -62,16 +64,13 @@ pub async fn test_cctp_token_router_endpoint_creation() {
62
64
63
65
let initialize_config = InitializeInstructionConfig :: default ( ) ;
64
66
65
- let testing_engine = TestingEngine :: new (
66
- testing_context,
67
- vec ! [
68
- InstructionTrigger :: InitializeProgram ( initialize_config) ,
69
- InstructionTrigger :: CreateCctpRouterEndpoints ,
70
- ] ,
71
- )
72
- . await ;
67
+ let testing_engine = TestingEngine :: new ( testing_context) . await ;
73
68
74
- testing_engine. execute ( ) . await ;
69
+ testing_engine
70
+ . execute ( vec ! [ InstructionTrigger :: InitializeProgram (
71
+ initialize_config,
72
+ ) ] )
73
+ . await ;
75
74
}
76
75
77
76
#[ tokio:: test]
@@ -112,19 +111,19 @@ pub async fn test_setup_vaas() {
112
111
113
112
testing_context. verify_vaas ( ) . await ;
114
113
115
- let testing_engine = TestingEngine :: new (
116
- testing_context ,
117
- vec ! [
114
+ let testing_engine = TestingEngine :: new ( testing_context ) . await ;
115
+ testing_engine
116
+ . execute ( vec ! [
118
117
InstructionTrigger :: InitializeProgram ( InitializeInstructionConfig :: default ( ) ) ,
119
- InstructionTrigger :: CreateCctpRouterEndpoints ,
118
+ InstructionTrigger :: CreateCctpRouterEndpoints (
119
+ CreateCctpRouterEndpointsInstructionConfig :: default ( ) ,
120
+ ) ,
120
121
InstructionTrigger :: PlaceInitialOfferShimless (
121
122
PlaceInitialOfferInstructionConfig :: default ( ) ,
122
123
) ,
123
124
InstructionTrigger :: ImproveOfferShimless ( ImproveOfferInstructionConfig :: default ( ) ) ,
124
- ] ,
125
- )
126
- . await ;
127
- testing_engine. execute ( ) . await ;
125
+ ] )
126
+ . await ;
128
127
}
129
128
130
129
#[ tokio:: test]
@@ -380,7 +379,7 @@ pub async fn test_place_initial_offer_fallback() {
380
379
None ,
381
380
)
382
381
. await ;
383
- let _initial_offer_fixture = place_initial_offer_fallback_test (
382
+ let initial_offer_fixture = place_initial_offer_fallback_test (
384
383
& mut testing_context,
385
384
& auction_accounts,
386
385
true , // Expected to pass
@@ -390,13 +389,17 @@ pub async fn test_place_initial_offer_fallback() {
390
389
391
390
// Attempt to improve the offer using the non-fallback method with another solver making the improved offer
392
391
println ! ( "Improving offer" ) ;
392
+ let auction_state = initial_offer_fixture
393
+ . expect ( "Failed to get initial offer fixture" )
394
+ . auction_state ;
393
395
let second_solver = testing_context. testing_actors . solvers [ 1 ] . clone ( ) ;
394
396
improve_offer (
395
397
& mut testing_context,
396
398
PROGRAM_ID ,
397
399
second_solver,
398
400
auction_config_address,
399
401
500_000 ,
402
+ & auction_state,
400
403
None ,
401
404
)
402
405
. await ;
@@ -440,14 +443,19 @@ pub async fn test_place_initial_offer_shim_blocks_non_shim() {
440
443
// Now test without the fallback program
441
444
let mut auction_accounts = initial_offer_fallback_fixture. auction_accounts ;
442
445
auction_accounts. fast_vaa = Some ( first_test_ft. get_vaa_pubkey ( ) ) ;
446
+
447
+ let offer_price = 1__000_000 ;
448
+ let transaction_error = TransactionError :: AccountInUse ;
443
449
place_initial_offer_shimless (
444
450
& mut testing_context,
445
451
& auction_accounts,
446
- first_test_ft,
452
+ & first_test_ft,
453
+ offer_price,
447
454
PROGRAM_ID ,
448
455
Some ( & ExpectedError {
449
456
instruction_index : 0 ,
450
- error : MatchingEngineError :: AccountAlreadyInitialized ,
457
+ error_code : 0 , // This is the error code for account in use
458
+ error_string : transaction_error. to_string ( ) ,
451
459
} ) , // Expected to fail
452
460
)
453
461
. await ;
@@ -480,10 +488,12 @@ pub async fn test_place_initial_offer_non_shim_blocks_shim() {
480
488
)
481
489
. await ;
482
490
// Place initial offer using the shimless instruction
491
+ let offer_price = 1__000_000 ;
483
492
place_initial_offer_shimless (
484
493
& mut testing_context,
485
494
& auction_accounts,
486
- first_test_ft,
495
+ & first_test_ft,
496
+ offer_price,
487
497
PROGRAM_ID ,
488
498
None , // Expected to pass
489
499
)
@@ -585,17 +595,23 @@ pub async fn test_execute_order_shimless() {
585
595
Some ( first_test_fast_transfer_pubkey) ,
586
596
)
587
597
. await ;
588
- place_initial_offer_shimless (
598
+ let offer_price = 1__000_000 ;
599
+ let auction_state = place_initial_offer_shimless (
589
600
& mut testing_context,
590
601
& auction_accounts,
591
- first_test_fast_transfer,
602
+ & first_test_fast_transfer,
603
+ offer_price,
592
604
PROGRAM_ID ,
593
605
None , // Expected to pass
594
606
)
595
607
. await ;
596
-
597
- let execute_order_fixture =
598
- execute_order_shimless_test ( & mut testing_context, & auction_accounts, true ) . await ;
608
+ let execute_order_fixture = execute_order_shimless_test (
609
+ & mut testing_context,
610
+ & auction_accounts,
611
+ & auction_state,
612
+ None ,
613
+ )
614
+ . await ;
599
615
assert ! ( execute_order_fixture. is_some( ) ) ;
600
616
}
601
617
pub async fn test_execute_order_fallback_blocks_shimless ( ) {
@@ -642,9 +658,19 @@ pub async fn test_execute_order_fallback_blocks_shimless() {
642
658
)
643
659
. await
644
660
. expect ( "Failed to execute order" ) ;
645
-
646
- let shimless_execute_order_fixture =
647
- execute_order_shimless_test ( & mut testing_context, & auction_accounts, false ) . await ;
661
+ let auction_state = initial_offer_fallback_fixture. auction_state ;
662
+ let expected_error = Some ( ExpectedError {
663
+ instruction_index : 0 ,
664
+ error_code : MatchingEngineError :: AccountAlreadyInitialized . into ( ) ,
665
+ error_string : MatchingEngineError :: AccountAlreadyInitialized . to_string ( ) ,
666
+ } ) ;
667
+ let shimless_execute_order_fixture = execute_order_shimless_test (
668
+ & mut testing_context,
669
+ & auction_accounts,
670
+ & auction_state,
671
+ expected_error,
672
+ )
673
+ . await ;
648
674
assert ! ( shimless_execute_order_fixture. is_none( ) ) ;
649
675
}
650
676
@@ -713,7 +739,6 @@ pub async fn test_prepare_order_shim_fallback() {
713
739
)
714
740
. await
715
741
. expect ( "Failed to execute order" ) ;
716
-
717
742
shimful:: shims_prepare_order_response:: prepare_order_response_test (
718
743
& testing_context. test_context ,
719
744
& payer_signer,
@@ -769,11 +794,13 @@ pub async fn test_settle_auction_complete() {
769
794
// Try making initial offer using the shim instruction
770
795
let usdc_mint_address = testing_context. get_usdc_mint_address ( ) ;
771
796
let auction_config_address = initialize_fixture. get_auction_config_address ( ) ;
797
+ let router_config = CreateCctpRouterEndpointsInstructionConfig :: default ( ) ;
772
798
let router_endpoints = create_all_router_endpoints_test (
773
799
& testing_context,
774
800
testing_context. testing_actors . owner . pubkey ( ) ,
775
801
initialize_fixture. get_custodian_address ( ) ,
776
802
testing_context. testing_actors . owner . keypair ( ) ,
803
+ router_config. chains ,
777
804
)
778
805
. await ;
779
806
@@ -833,8 +860,8 @@ pub async fn test_settle_auction_complete() {
833
860
& execute_order_fixture,
834
861
& initial_offer_fixture,
835
862
& initialize_fixture,
836
- & router_endpoints . ethereum . endpoint_address ,
837
- & router_endpoints . arbitrum . endpoint_address ,
863
+ & auction_accounts . to_router_endpoint ,
864
+ & auction_accounts . from_router_endpoint ,
838
865
& usdc_mint_address,
839
866
& CCTP_MINT_RECIPIENT ,
840
867
& initialize_fixture. get_custodian_address ( ) ,
0 commit comments