1
1
use std:: rc:: Rc ;
2
2
3
- use crate :: testing_engine:: config:: { ExecuteOrderInstructionConfig , ExpectedError } ;
4
- use crate :: testing_engine:: setup:: { TestingContext , TransferDirection } ;
5
- use crate :: utils:: account_fixtures:: FixtureAccounts ;
3
+ use crate :: shimful:: shims_execute_order:: create_cctp_accounts;
4
+ use crate :: testing_engine:: config:: { ExecuteOrderInstructionConfig , InstructionConfig } ;
5
+ use crate :: testing_engine:: setup:: TestingContext ;
6
+ use crate :: testing_engine:: state:: TestingEngineState ;
6
7
use crate :: utils:: auction:: { AuctionAccounts , AuctionState } ;
7
8
use anchor_lang:: prelude:: * ;
8
9
use anchor_lang:: { InstructionData , ToAccountMetas } ;
9
- use common:: wormhole_cctp_solana:: cctp:: {
10
- MESSAGE_TRANSMITTER_PROGRAM_ID , TOKEN_MESSENGER_MINTER_PROGRAM_ID ,
11
- } ;
10
+
12
11
use matching_engine:: accounts:: { CctpDepositForBurn , WormholePublishMessage } ;
13
12
use matching_engine:: accounts:: {
14
13
ExecuteFastOrderCctp as ExecuteOrderShimlessAccounts , LiquidityLayerVaa , LiveRouterEndpoint ,
@@ -28,12 +27,23 @@ pub struct ExecuteOrderShimlessFixture {
28
27
29
28
pub fn create_execute_order_shimless_accounts (
30
29
testing_context : & TestingContext ,
31
- fixture_accounts : & FixtureAccounts ,
32
30
auction_accounts : & AuctionAccounts ,
33
31
payer_signer : & Rc < Keypair > ,
34
32
auction_state : & AuctionState ,
35
- executor_token : Pubkey ,
33
+ config : & ExecuteOrderInstructionConfig ,
34
+ current_state : & TestingEngineState ,
36
35
) -> ExecuteOrderShimlessAccounts {
36
+ let executor_token = config
37
+ . actor_enum
38
+ . get_actor ( & testing_context. testing_actors )
39
+ . token_account_address ( & config. token_enum )
40
+ . unwrap_or_else ( || {
41
+ auction_state
42
+ . get_active_auction ( )
43
+ . unwrap ( )
44
+ . best_offer
45
+ . offer_token
46
+ } ) ;
37
47
let active_auction_state = auction_state. get_active_auction ( ) . unwrap ( ) ;
38
48
let active_auction_address = active_auction_state. auction_address ;
39
49
let active_auction_custody_token = active_auction_state. auction_custody_token_address ;
@@ -91,46 +101,8 @@ pub fn create_execute_order_shimless_accounts(
91
101
clock : Clock :: id ( ) ,
92
102
rent : Rent :: id ( ) ,
93
103
} ;
94
- let token_messenger_minter_event_authority =
95
- Pubkey :: find_program_address ( & [ EVENT_AUTHORITY_SEED ] , & TOKEN_MESSENGER_MINTER_PROGRAM_ID ) . 0 ;
96
- let local_token = Pubkey :: find_program_address (
97
- & [
98
- b"local_token" ,
99
- & testing_context. get_usdc_mint_address ( ) . to_bytes ( ) ,
100
- ] ,
101
- & TOKEN_MESSENGER_MINTER_PROGRAM_ID ,
102
- )
103
- . 0 ;
104
- let token_messenger_minter_sender_authority =
105
- Pubkey :: find_program_address ( & [ b"sender_authority" ] , & TOKEN_MESSENGER_MINTER_PROGRAM_ID ) . 0 ;
106
- let message_transmitter_config =
107
- Pubkey :: find_program_address ( & [ b"message_transmitter" ] , & MESSAGE_TRANSMITTER_PROGRAM_ID ) . 0 ;
108
- let token_messenger =
109
- Pubkey :: find_program_address ( & [ b"token_messenger" ] , & TOKEN_MESSENGER_MINTER_PROGRAM_ID ) . 0 ;
110
- let remote_token_messenger = match testing_context. transfer_direction {
111
- TransferDirection :: FromEthereumToArbitrum => {
112
- fixture_accounts. arbitrum_remote_token_messenger
113
- }
114
- TransferDirection :: FromArbitrumToEthereum => {
115
- fixture_accounts. ethereum_remote_token_messenger
116
- }
117
- _ => panic ! ( "Unsupported transfer direction" ) ,
118
- } ;
119
- let token_minter =
120
- Pubkey :: find_program_address ( & [ b"token_minter" ] , & TOKEN_MESSENGER_MINTER_PROGRAM_ID ) . 0 ;
121
- let cctp = CctpDepositForBurn {
122
- mint : testing_context. get_usdc_mint_address ( ) ,
123
- local_token,
124
- token_messenger_minter_sender_authority,
125
- message_transmitter_config,
126
- token_messenger,
127
- remote_token_messenger,
128
- token_minter,
129
- token_messenger_minter_event_authority,
130
- message_transmitter_program : MESSAGE_TRANSMITTER_PROGRAM_ID ,
131
- token_messenger_minter_program : TOKEN_MESSENGER_MINTER_PROGRAM_ID ,
132
- } ;
133
104
105
+ let cctp = create_cctp_deposit_for_burn ( current_state, testing_context) ;
134
106
let event_authority = Pubkey :: find_program_address (
135
107
& [ EVENT_AUTHORITY_SEED ] ,
136
108
& testing_context. get_matching_engine_program_id ( ) ,
@@ -156,42 +128,30 @@ pub fn create_execute_order_shimless_accounts(
156
128
pub async fn execute_order_shimless_test (
157
129
testing_context : & TestingContext ,
158
130
test_context : & mut ProgramTestContext ,
131
+ current_state : & TestingEngineState ,
159
132
config : & ExecuteOrderInstructionConfig ,
160
133
auction_accounts : & AuctionAccounts ,
161
- auction_state : & AuctionState ,
162
- expected_error : Option < & ExpectedError > ,
163
134
) -> Option < ExecuteOrderShimlessFixture > {
164
135
let payer_signer = config
165
136
. payer_signer
166
137
. clone ( )
167
138
. unwrap_or_else ( || testing_context. testing_actors . payer_signer . clone ( ) ) ;
139
+ let auction_state = current_state. auction_state ( ) ;
140
+ let expected_error = config. expected_error ( ) ;
168
141
let slots_to_fast_forward = config. fast_forward_slots ;
169
142
if slots_to_fast_forward > 0 {
170
143
crate :: testing_engine:: engine:: fast_forward_slots ( test_context, slots_to_fast_forward)
171
144
. await ;
172
145
}
173
- let executor_token = config
174
- . actor_enum
175
- . get_actor ( & testing_context. testing_actors )
176
- . token_account_address ( & config. token_enum )
177
- . unwrap_or_else ( || {
178
- auction_state
179
- . get_active_auction ( )
180
- . unwrap ( )
181
- . best_offer
182
- . offer_token
183
- } ) ;
184
- let fixture_accounts = testing_context
185
- . get_fixture_accounts ( )
186
- . expect ( "Fixture accounts not found" ) ;
146
+
187
147
let execute_order_accounts: ExecuteOrderShimlessAccounts =
188
148
create_execute_order_shimless_accounts (
189
149
testing_context,
190
- & fixture_accounts,
191
150
auction_accounts,
192
151
& payer_signer,
193
152
auction_state,
194
- executor_token,
153
+ config,
154
+ current_state,
195
155
) ;
196
156
let execute_order_instruction_data = ExecuteOrderShimlessInstruction { } . data ( ) ;
197
157
let execute_order_ix = Instruction {
@@ -219,3 +179,11 @@ pub async fn execute_order_shimless_test(
219
179
None
220
180
}
221
181
}
182
+
183
+ pub fn create_cctp_deposit_for_burn (
184
+ current_state : & TestingEngineState ,
185
+ testing_context : & TestingContext ,
186
+ ) -> CctpDepositForBurn {
187
+ let cctp_accounts = create_cctp_accounts ( current_state, testing_context) ;
188
+ cctp_accounts. into ( )
189
+ }
0 commit comments