Skip to content

Commit 48340d7

Browse files
author
Bengt Lofgren
committed
execute order added as well
1 parent 324fa88 commit 48340d7

File tree

8 files changed

+195
-195
lines changed

8 files changed

+195
-195
lines changed

solana/programs/matching-engine/src/fallback/processor/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pub mod process_instruction;
22
pub use process_instruction::*;
3-
// pub mod burn_and_post;
3+
pub mod burn_and_post;
44
pub mod close_fast_market_order;
5-
// pub mod execute_order;
5+
pub mod execute_order;
66
pub mod initialise_fast_market_order;
77
pub mod place_initial_offer;
88
// pub mod prepare_order_response;

solana/programs/matching-engine/src/fallback/processor/process_instruction.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::close_fast_market_order::close_fast_market_order;
2-
// use super::execute_order::handle_execute_order_shim;
2+
use super::execute_order::handle_execute_order_shim;
33
use super::initialise_fast_market_order::{
44
initialise_fast_market_order, InitialiseFastMarketOrderData,
55
};
@@ -27,7 +27,7 @@ pub enum FallbackMatchingEngineInstruction<'ix> {
2727
InitialiseFastMarketOrder(&'ix InitialiseFastMarketOrderData),
2828
CloseFastMarketOrder,
2929
PlaceInitialOfferCctpShim(&'ix PlaceInitialOfferCctpShimData),
30-
// ExecuteOrderCctpShim,
30+
ExecuteOrderCctpShim,
3131
// PrepareOrderResponseCctpShim(PrepareOrderResponseCctpShimData),
3232
}
3333

@@ -50,10 +50,10 @@ pub fn process_instruction(
5050
}
5151
FallbackMatchingEngineInstruction::PlaceInitialOfferCctpShim(data) => {
5252
place_initial_offer_cctp_shim(accounts, data)
53-
} // FallbackMatchingEngineInstruction::ExecuteOrderCctpShim => {
54-
// handle_execute_order_shim(accounts)
55-
// }
56-
// FallbackMatchingEngineInstruction::PrepareOrderResponseCctpShim(data) => {
53+
}
54+
FallbackMatchingEngineInstruction::ExecuteOrderCctpShim => {
55+
handle_execute_order_shim(accounts)
56+
} // FallbackMatchingEngineInstruction::PrepareOrderResponseCctpShim(data) => {
5757
// prepare_order_response_cctp_shim(accounts, data)
5858
// }
5959
}
@@ -78,9 +78,9 @@ impl<'ix> FallbackMatchingEngineInstruction<'ix> {
7878
FallbackMatchingEngineInstruction::CLOSE_FAST_MARKET_ORDER_SELECTOR => {
7979
Some(Self::CloseFastMarketOrder)
8080
}
81-
// FallbackMatchingEngineInstruction::EXECUTE_ORDER_CCTP_SHIM_SELECTOR => {
82-
// Some(Self::ExecuteOrderCctpShim)
83-
// }
81+
FallbackMatchingEngineInstruction::EXECUTE_ORDER_CCTP_SHIM_SELECTOR => {
82+
Some(Self::ExecuteOrderCctpShim)
83+
}
8484
// FallbackMatchingEngineInstruction::PREPARE_ORDER_RESPONSE_CCTP_SHIM_SELECTOR => {
8585
// Some(Self::PrepareOrderResponseCctpShim(
8686
// PrepareOrderResponseCctpShimData::from_bytes(&instruction_data[8..]).unwrap(),
@@ -112,17 +112,17 @@ impl FallbackMatchingEngineInstruction<'_> {
112112

113113
out
114114
}
115-
// Self::ExecuteOrderCctpShim => {
116-
// let total_capacity = 8; // 8 for the selector (no data)
115+
Self::ExecuteOrderCctpShim => {
116+
let total_capacity = 8; // 8 for the selector (no data)
117117

118-
// let mut out = Vec::with_capacity(total_capacity);
118+
let mut out = Vec::with_capacity(total_capacity);
119119

120-
// out.extend_from_slice(
121-
// &FallbackMatchingEngineInstruction::EXECUTE_ORDER_CCTP_SHIM_SELECTOR,
122-
// );
120+
out.extend_from_slice(
121+
&FallbackMatchingEngineInstruction::EXECUTE_ORDER_CCTP_SHIM_SELECTOR,
122+
);
123123

124-
// out
125-
// }
124+
out
125+
}
126126
Self::InitialiseFastMarketOrder(data) => {
127127
let data_slice = bytemuck::bytes_of(*data);
128128
let total_capacity = 8_usize.saturating_add(data_slice.len()); // 8 for the selector, plus the data length

solana/programs/matching-engine/tests/integration_tests.rs

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -358,60 +358,60 @@ pub async fn test_place_initial_offer_non_shim_blocks_shim() {
358358
testing_engine.execute(instruction_triggers).await;
359359
}
360360

361-
// #[tokio::test]
362-
// // Testing an execute order from arbitrum to ethereum
363-
// // TODO: Flesh out this test to see if the message was posted correctly
364-
// pub async fn test_execute_order_fallback() {
365-
// let transfer_direction = TransferDirection::FromArbitrumToEthereum;
366-
// let vaa_args = VaaArgs {
367-
// post_vaa: false,
368-
// ..VaaArgs::default()
369-
// };
370-
// let testing_context = setup_environment(
371-
// ShimMode::VerifyAndPostSignature,
372-
// transfer_direction,
373-
// Some(vaa_args),
374-
// )
375-
// .await;
376-
// let testing_engine = TestingEngine::new(testing_context).await;
377-
// let instruction_triggers = vec![
378-
// InstructionTrigger::InitializeProgram(InitializeInstructionConfig::default()),
379-
// InstructionTrigger::CreateCctpRouterEndpoints(
380-
// CreateCctpRouterEndpointsInstructionConfig::default(),
381-
// ),
382-
// InstructionTrigger::InitializeFastMarketOrderShim(
383-
// InitializeFastMarketOrderShimInstructionConfig::default(),
384-
// ),
385-
// InstructionTrigger::PlaceInitialOfferShim(PlaceInitialOfferInstructionConfig::default()),
386-
// InstructionTrigger::ExecuteOrderShim(ExecuteOrderInstructionConfig::default()),
387-
// ];
388-
// testing_engine.execute(instruction_triggers).await;
389-
// }
361+
#[tokio::test]
362+
// Testing an execute order from arbitrum to ethereum
363+
// TODO: Flesh out this test to see if the message was posted correctly
364+
pub async fn test_execute_order_fallback() {
365+
let transfer_direction = TransferDirection::FromArbitrumToEthereum;
366+
let vaa_args = VaaArgs {
367+
post_vaa: false,
368+
..VaaArgs::default()
369+
};
370+
let testing_context = setup_environment(
371+
ShimMode::VerifyAndPostSignature,
372+
transfer_direction,
373+
Some(vaa_args),
374+
)
375+
.await;
376+
let testing_engine = TestingEngine::new(testing_context).await;
377+
let instruction_triggers = vec![
378+
InstructionTrigger::InitializeProgram(InitializeInstructionConfig::default()),
379+
InstructionTrigger::CreateCctpRouterEndpoints(
380+
CreateCctpRouterEndpointsInstructionConfig::default(),
381+
),
382+
InstructionTrigger::InitializeFastMarketOrderShim(
383+
InitializeFastMarketOrderShimInstructionConfig::default(),
384+
),
385+
InstructionTrigger::PlaceInitialOfferShim(PlaceInitialOfferInstructionConfig::default()),
386+
InstructionTrigger::ExecuteOrderShim(ExecuteOrderInstructionConfig::default()),
387+
];
388+
testing_engine.execute(instruction_triggers).await;
389+
}
390390

391-
// #[tokio::test]
392-
// pub async fn test_execute_order_shimless() {
393-
// let transfer_direction = TransferDirection::FromArbitrumToEthereum;
394-
// let vaa_args = VaaArgs {
395-
// post_vaa: true,
396-
// ..VaaArgs::default()
397-
// };
398-
// let testing_context = setup_environment(
399-
// ShimMode::VerifyAndPostSignature,
400-
// transfer_direction,
401-
// Some(vaa_args),
402-
// )
403-
// .await;
404-
// let testing_engine = TestingEngine::new(testing_context).await;
405-
// let instruction_triggers = vec![
406-
// InstructionTrigger::InitializeProgram(InitializeInstructionConfig::default()),
407-
// InstructionTrigger::CreateCctpRouterEndpoints(
408-
// CreateCctpRouterEndpointsInstructionConfig::default(),
409-
// ),
410-
// InstructionTrigger::PlaceInitialOfferShimless(PlaceInitialOfferInstructionConfig::default()),
411-
// InstructionTrigger::ExecuteOrderShimless(ExecuteOrderInstructionConfig::default()),
412-
// ];
413-
// testing_engine.execute(instruction_triggers).await;
414-
// }
391+
#[tokio::test]
392+
pub async fn test_execute_order_shimless() {
393+
let transfer_direction = TransferDirection::FromArbitrumToEthereum;
394+
let vaa_args = VaaArgs {
395+
post_vaa: true,
396+
..VaaArgs::default()
397+
};
398+
let testing_context = setup_environment(
399+
ShimMode::VerifyAndPostSignature,
400+
transfer_direction,
401+
Some(vaa_args),
402+
)
403+
.await;
404+
let testing_engine = TestingEngine::new(testing_context).await;
405+
let instruction_triggers = vec![
406+
InstructionTrigger::InitializeProgram(InitializeInstructionConfig::default()),
407+
InstructionTrigger::CreateCctpRouterEndpoints(
408+
CreateCctpRouterEndpointsInstructionConfig::default(),
409+
),
410+
InstructionTrigger::PlaceInitialOfferShimless(PlaceInitialOfferInstructionConfig::default()),
411+
InstructionTrigger::ExecuteOrderShimless(ExecuteOrderInstructionConfig::default()),
412+
];
413+
testing_engine.execute(instruction_triggers).await;
414+
}
415415
// pub async fn test_execute_order_fallback_blocks_shimless() {
416416
// let transfer_direction = TransferDirection::FromArbitrumToEthereum;
417417
// let vaa_args = VaaArgs {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(clippy::expect_used)]
22
pub mod fast_market_order_shim;
33
pub mod post_message;
4-
// pub mod shims_execute_order;
4+
pub mod shims_execute_order;
55
pub mod shims_make_offer;
66
// pub mod shims_prepare_order_response;
77
pub mod verify_shim;

solana/programs/matching-engine/tests/shimful/shims_execute_order.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub async fn execute_order_fallback(
182182

183183
// Considering fast forwarding blocks here for deadline to be reached
184184
let recent_blockhash = test_ctx.borrow().last_blockhash;
185-
utils::setup::fast_forward_slots(test_ctx, 3).await;
185+
utils::setup::fast_forward_slots(&testing_context, 3).await;
186186
let transaction = Transaction::new_signed_with_payer(
187187
&[execute_order_ix],
188188
Some(&payer_signer.pubkey()),

solana/programs/matching-engine/tests/shimless/execute_order.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub async fn execute_order_shimless_test(
158158
payer_signer: &Rc<Keypair>,
159159
expected_error: Option<&ExpectedError>,
160160
) -> Option<ExecuteOrderShimlessFixture> {
161-
crate::utils::setup::fast_forward_slots(&testing_context.test_context, 3).await;
161+
crate::utils::setup::fast_forward_slots(&testing_context, 3).await;
162162
let fixture_accounts = testing_context
163163
.get_fixture_accounts()
164164
.expect("Fixture accounts not found");

solana/programs/matching-engine/tests/shimless/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(clippy::expect_used)]
22

3-
// pub mod execute_order;
3+
pub mod execute_order;
44
pub mod initialize;
55
pub mod make_offer;
66
// pub mod prepare_order_response;

0 commit comments

Comments
 (0)