Skip to content

Commit ea757c6

Browse files
author
Bengt Lofgren
committed
execute order testing checks improved, fix to prepare order instruction, all tests pass
1 parent 02e0665 commit ea757c6

22 files changed

+1860
-606
lines changed

solana/modules/matching-engine-testing/tests/shimful/shims_execute_order.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,17 @@ impl ExecuteOrderFallbackAccounts {
4242
current_state: &TestingEngineState,
4343
payer_signer: &Pubkey,
4444
fixture_accounts: &utils::account_fixtures::FixtureAccounts,
45+
override_fast_market_order_address: Option<Pubkey>,
4546
) -> Self {
4647
let transfer_direction = current_state.base().transfer_direction;
4748
let auction_accounts = current_state.auction_accounts().unwrap();
4849
let active_auction_state = current_state.auction_state().get_active_auction().unwrap();
49-
let fast_market_order_address = current_state
50-
.fast_market_order()
51-
.unwrap()
52-
.fast_market_order_address;
50+
let fast_market_order_address = override_fast_market_order_address.unwrap_or_else(|| {
51+
current_state
52+
.fast_market_order()
53+
.unwrap()
54+
.fast_market_order_address
55+
});
5356
let remote_token_messenger = match transfer_direction {
5457
TransferDirection::FromEthereumToArbitrum => {
5558
fixture_accounts.arbitrum_remote_token_messenger
@@ -95,7 +98,7 @@ pub struct ExecuteOrderFallbackFixtureAccounts {
9598
pub executor_token: Pubkey,
9699
}
97100

98-
pub async fn execute_order_fallback(
101+
pub async fn execute_order_shimful(
99102
testing_context: &TestingContext,
100103
test_context: &mut ProgramTestContext,
101104
config: &ExecuteOrderInstructionConfig,
@@ -131,7 +134,11 @@ pub async fn execute_order_fallback(
131134
.get_new_latest_blockhash(test_context)
132135
.await
133136
.unwrap();
134-
crate::testing_engine::engine::fast_forward_slots(test_context, 3).await;
137+
let slots_to_fast_forward = config.fast_forward_slots;
138+
if slots_to_fast_forward > 0 {
139+
crate::testing_engine::engine::fast_forward_slots(test_context, slots_to_fast_forward)
140+
.await;
141+
}
135142
let transaction = Transaction::new_signed_with_payer(
136143
&[execute_order_ix],
137144
Some(&payer_signer.pubkey()),
@@ -262,7 +269,7 @@ pub fn create_execute_order_shim_accounts<'ix>(
262269
}
263270
}
264271

265-
pub async fn execute_order_fallback_test(
272+
pub async fn execute_order_shimful_test(
266273
testing_context: &TestingContext,
267274
test_context: &mut ProgramTestContext,
268275
current_state: &TestingEngineState,
@@ -276,9 +283,13 @@ pub async fn execute_order_fallback_test(
276283
.payer_signer
277284
.clone()
278285
.unwrap_or_else(|| testing_context.testing_actors.payer_signer.clone());
279-
let execute_order_fallback_accounts =
280-
ExecuteOrderFallbackAccounts::new(current_state, &payer_signer.pubkey(), &fixture_accounts);
281-
execute_order_fallback(
286+
let execute_order_fallback_accounts = ExecuteOrderFallbackAccounts::new(
287+
current_state,
288+
&payer_signer.pubkey(),
289+
&fixture_accounts,
290+
config.fast_market_order_address,
291+
);
292+
execute_order_shimful(
282293
testing_context,
283294
test_context,
284295
config,

0 commit comments

Comments
 (0)