Skip to content

Commit 71927e1

Browse files
author
Bengt Lofgren
committed
idl built
1 parent 369d083 commit 71927e1

File tree

6 files changed

+112
-43
lines changed

6 files changed

+112
-43
lines changed

solana/modules/matching-engine-testing/tests/test_scenarios/execute_order.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,25 @@ use super::make_offer::place_initial_offer_shim;
3131
// TODO: Flesh out this test to see if the message was posted correctly
3232
pub async fn test_execute_order_shim() {
3333
let transfer_direction = TransferDirection::FromEthereumToArbitrum;
34-
execute_order_helper(
34+
Box::pin(execute_order_helper(
3535
ExecuteOrderInstructionConfig::default(),
3636
ShimExecutionMode::Shim,
3737
None,
3838
transfer_direction,
39-
)
39+
))
4040
.await;
4141
}
4242

4343
/// Test that the execute order shimless instruction works correctly
4444
#[tokio::test]
4545
pub async fn test_execute_order_shimless() {
4646
let transfer_direction = TransferDirection::FromEthereumToArbitrum;
47-
execute_order_helper(
47+
Box::pin(execute_order_helper(
4848
ExecuteOrderInstructionConfig::default(),
4949
ShimExecutionMode::Shimless,
5050
None,
5151
transfer_direction,
52-
)
52+
))
5353
.await;
5454
}
5555

@@ -75,18 +75,15 @@ pub async fn test_execute_order_after_reopening_fast_market_order_account() {
7575
InitializeFastMarketOrderShimInstructionConfig {
7676
fast_market_order_id: 1,
7777
close_account_refund_recipient: Some(close_account_refund_recipient),
78-
payer_signer: None,
79-
expected_error: None,
80-
expected_log_messages: None,
8178
..InitializeFastMarketOrderShimInstructionConfig::default()
8279
},
8380
),
8481
InstructionTrigger::ExecuteOrderShim(ExecuteOrderInstructionConfig::default()),
8582
];
8683
let mut execution_chain = ExecutionChain::from(instruction_triggers);
87-
execution_chain.push(ExecutionTrigger::Verification(
84+
execution_chain.push(ExecutionTrigger::Verification(Box::new(
8885
VerificationTrigger::VerifyAuctionState(true),
89-
));
86+
)));
9087
let _ = testing_engine
9188
.execute(
9289
&mut test_context,
@@ -114,9 +111,9 @@ pub async fn test_execute_order_shim_after_placing_initial_offer_with_shimless()
114111
InstructionTrigger::ExecuteOrderShim(ExecuteOrderInstructionConfig::default()),
115112
];
116113
let mut execution_chain = ExecutionChain::from(instruction_triggers);
117-
execution_chain.push(ExecutionTrigger::Verification(
114+
execution_chain.push(ExecutionTrigger::Verification(Box::new(
118115
VerificationTrigger::VerifyAuctionState(true),
119-
));
116+
)));
120117
let _ = testing_engine
121118
.execute(
122119
&mut test_context,
@@ -144,9 +141,9 @@ pub async fn test_execute_order_shimless_after_placing_initial_offer_with_shim()
144141
ExecuteOrderInstructionConfig::default(),
145142
)];
146143
let mut execution_chain = ExecutionChain::from(instruction_triggers);
147-
execution_chain.push(ExecutionTrigger::Verification(
144+
execution_chain.push(ExecutionTrigger::Verification(Box::new(
148145
VerificationTrigger::VerifyAuctionState(true),
149-
));
146+
)));
150147
let _ = testing_engine
151148
.execute(
152149
&mut test_context,
@@ -305,9 +302,9 @@ pub async fn execute_order_helper(
305302
ShimExecutionMode::Shimless => vec![InstructionTrigger::ExecuteOrderShimless(config)],
306303
};
307304
let mut execution_chain = ExecutionChain::from(instruction_triggers);
308-
execution_chain.push(ExecutionTrigger::Verification(
305+
execution_chain.push(ExecutionTrigger::Verification(Box::new(
309306
VerificationTrigger::VerifyAuctionState(true),
310-
));
307+
)));
311308
(
312309
testing_engine
313310
.execute(

solana/modules/matching-engine-testing/tests/test_scenarios/prepare_order.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,12 @@ pub async fn test_prepare_order_response_shim_after_reopening_fast_market_order_
222222
transfer_direction,
223223
))
224224
.await;
225-
let reopen_fast_market_order_state = reopen_fast_market_order_shim(
225+
let reopen_fast_market_order_state = Box::pin(reopen_fast_market_order_shim(
226226
place_initial_offer_state,
227227
&mut test_context,
228228
&testing_engine,
229229
None,
230-
)
230+
))
231231
.await;
232232
let instruction_triggers = vec![InstructionTrigger::ExecuteOrderShim(
233233
ExecuteOrderInstructionConfig::default(),
@@ -263,12 +263,12 @@ pub async fn test_prepare_order_response_shim_after_reopening_fast_market_order_
263263
close_account_refund_recipient_keypair: Some(second_solver_keypair),
264264
..CloseFastMarketOrderShimInstructionConfig::default()
265265
};
266-
let double_reopen_fast_market_order_state = reopen_fast_market_order_shim(
266+
let double_reopen_fast_market_order_state = Box::pin(reopen_fast_market_order_shim(
267267
execute_order_state,
268268
&mut test_context,
269269
&testing_engine,
270270
Some((reopen_config, close_config)),
271-
)
271+
))
272272
.await;
273273
let instruction_triggers = vec![InstructionTrigger::PrepareOrderShim(
274274
PrepareOrderInstructionConfig::default(),

solana/modules/matching-engine-testing/tests/test_scenarios/settle_auction.rs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//!
99
//! - `test_settle_auction_complete` - Test that the settle auction instruction works correctly
1010
//!
11+
use crate::test_scenarios::make_offer::{place_initial_offer_shim, reopen_fast_market_order_shim};
1112
use crate::testing_engine;
1213
use crate::testing_engine::config::{
1314
InitializeInstructionConfig, PlaceInitialOfferInstructionConfig,
@@ -20,6 +21,34 @@ use testing_engine::engine::{InstructionTrigger, TestingEngine};
2021
use testing_engine::setup::{setup_environment, ShimMode, TransferDirection};
2122
use utils::vaa::VaaArgs;
2223

24+
/*
25+
Happy path tests section
26+
27+
*****************
28+
****** ******
29+
**** ****
30+
**** ***
31+
*** ***
32+
** *** *** **
33+
** ******* ******* ***
34+
** ******* ******* **
35+
** ******* ******* **
36+
** *** *** **
37+
** **
38+
** * * **
39+
** ** ** **
40+
** **** **** **
41+
** ** ** **
42+
** *** *** **
43+
*** **** **** ***
44+
** ****** ****** **
45+
*** *************** ***
46+
**** ****
47+
**** ****
48+
****** ******
49+
*****************
50+
*/
51+
2352
/// Test that the settle auction instruction works correctly
2453
#[tokio::test]
2554
pub async fn test_settle_auction_complete() {
@@ -53,3 +82,35 @@ pub async fn test_settle_auction_complete() {
5382
.execute(&mut test_context, instruction_triggers, None)
5483
.await;
5584
}
85+
86+
/// Test that the settle auction instruction works with reopened fast market order
87+
#[tokio::test]
88+
pub async fn test_settle_auction_reopened_fast_market_order() {
89+
let (initial_state, mut test_context, testing_engine) = Box::pin(place_initial_offer_shim(
90+
PlaceInitialOfferInstructionConfig::default(),
91+
Some(VaaArgs::default()),
92+
TransferDirection::FromEthereumToArbitrum,
93+
))
94+
.await;
95+
96+
let reopen_fast_market_order_state = Box::pin(reopen_fast_market_order_shim(
97+
initial_state,
98+
&mut test_context,
99+
&testing_engine,
100+
None,
101+
))
102+
.await;
103+
104+
let instruction_triggers = vec![
105+
InstructionTrigger::ExecuteOrderShim(ExecuteOrderInstructionConfig::default()),
106+
InstructionTrigger::PrepareOrderShim(PrepareOrderInstructionConfig::default()),
107+
InstructionTrigger::SettleAuction(SettleAuctionInstructionConfig::default()),
108+
];
109+
testing_engine
110+
.execute(
111+
&mut test_context,
112+
instruction_triggers,
113+
Some(reopen_fast_market_order_state),
114+
)
115+
.await;
116+
}

solana/modules/matching-engine-testing/tests/testing_engine/engine.rs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ pub enum VerificationTrigger {
7171
}
7272

7373
pub enum ExecutionTrigger {
74-
Instruction(InstructionTrigger),
75-
Verification(VerificationTrigger),
74+
Instruction(Box<InstructionTrigger>),
75+
Verification(Box<VerificationTrigger>),
7676
}
7777

7878
impl From<InstructionTrigger> for ExecutionTrigger {
7979
fn from(trigger: InstructionTrigger) -> Self {
80-
ExecutionTrigger::Instruction(trigger)
80+
ExecutionTrigger::Instruction(Box::new(trigger))
8181
}
8282
}
8383

8484
impl From<VerificationTrigger> for ExecutionTrigger {
8585
fn from(trigger: VerificationTrigger) -> Self {
86-
ExecutionTrigger::Verification(trigger)
86+
ExecutionTrigger::Verification(Box::new(trigger))
8787
}
8888
}
8989

@@ -106,9 +106,12 @@ impl DerefMut for ExecutionChain {
106106
impl ExecutionChain {
107107
pub fn instruction_triggers(&self) -> Vec<&InstructionTrigger> {
108108
self.iter()
109-
.filter_map(|trigger| match trigger {
110-
ExecutionTrigger::Instruction(trigger) => Some(trigger),
111-
_ => None,
109+
.filter_map(|trigger| {
110+
if let ExecutionTrigger::Instruction(boxed_trigger) = trigger {
111+
Some(boxed_trigger.as_ref())
112+
} else {
113+
None
114+
}
112115
})
113116
.collect()
114117
}
@@ -274,59 +277,59 @@ impl TestingEngine {
274277
trigger: &ExecutionTrigger,
275278
) -> TestingEngineState {
276279
match trigger {
277-
ExecutionTrigger::Instruction(trigger) => match trigger {
278-
InstructionTrigger::InitializeProgram(config) => {
280+
ExecutionTrigger::Instruction(trigger) => match **trigger {
281+
InstructionTrigger::InitializeProgram(ref config) => {
279282
self.initialize_program(test_context, current_state, config)
280283
.await
281284
}
282-
InstructionTrigger::CreateCctpRouterEndpoints(config) => {
285+
InstructionTrigger::CreateCctpRouterEndpoints(ref config) => {
283286
self.create_cctp_router_endpoints(test_context, current_state, config)
284287
.await
285288
}
286-
InstructionTrigger::InitializeFastMarketOrderShim(config) => {
289+
InstructionTrigger::InitializeFastMarketOrderShim(ref config) => {
287290
self.create_fast_market_order_account(test_context, current_state, config)
288291
.await
289292
}
290-
InstructionTrigger::CloseFastMarketOrderShim(config) => {
293+
InstructionTrigger::CloseFastMarketOrderShim(ref config) => {
291294
self.close_fast_market_order_account(test_context, current_state, config)
292295
.await
293296
}
294-
InstructionTrigger::PlaceInitialOfferShimless(config) => {
297+
InstructionTrigger::PlaceInitialOfferShimless(ref config) => {
295298
self.place_initial_offer_shimless(test_context, current_state, config)
296299
.await
297300
}
298-
InstructionTrigger::PlaceInitialOfferShim(config) => {
301+
InstructionTrigger::PlaceInitialOfferShim(ref config) => {
299302
self.place_initial_offer_shim(test_context, current_state, config)
300303
.await
301304
}
302-
InstructionTrigger::ImproveOfferShimless(config) => {
305+
InstructionTrigger::ImproveOfferShimless(ref config) => {
303306
self.improve_offer_shimless(test_context, current_state, config)
304307
.await
305308
}
306-
InstructionTrigger::ExecuteOrderShim(config) => {
309+
InstructionTrigger::ExecuteOrderShim(ref config) => {
307310
self.execute_order_shim(test_context, current_state, config)
308311
.await
309312
}
310-
InstructionTrigger::ExecuteOrderShimless(config) => {
313+
InstructionTrigger::ExecuteOrderShimless(ref config) => {
311314
self.execute_order_shimless(test_context, current_state, config)
312315
.await
313316
}
314-
InstructionTrigger::PrepareOrderShim(config) => {
317+
InstructionTrigger::PrepareOrderShim(ref config) => {
315318
self.prepare_order_shim(test_context, current_state, config)
316319
.await
317320
}
318-
InstructionTrigger::PrepareOrderShimless(config) => {
321+
InstructionTrigger::PrepareOrderShimless(ref config) => {
319322
self.prepare_order_shimless(test_context, current_state, config)
320323
.await
321324
}
322-
InstructionTrigger::SettleAuction(config) => {
325+
InstructionTrigger::SettleAuction(ref config) => {
323326
self.settle_auction(test_context, current_state, config)
324327
.await
325328
}
326329
},
327-
ExecutionTrigger::Verification(trigger) => match trigger {
330+
ExecutionTrigger::Verification(trigger) => match **trigger {
328331
VerificationTrigger::VerifyAuctionState(expected_to_succeed) => {
329-
self.verify_auction_state(test_context, current_state, *expected_to_succeed)
332+
self.verify_auction_state(test_context, current_state, expected_to_succeed)
330333
.await
331334
}
332335
},

solana/ts/src/idl/json/matching_engine.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3177,7 +3177,11 @@
31773177
"msg": "From and to router endpoints are the same"
31783178
},
31793179
{
3180-
"code": 8050,
3180+
"code": 8576,
3181+
"name": "MismatchingCloseAccountRefundRecipient"
3182+
},
3183+
{
3184+
"code": 8306,
31813185
"name": "InvalidCctpMessage"
31823186
}
31833187
],

solana/ts/src/idl/ts/matching_engine.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3183,7 +3183,11 @@ export type MatchingEngine = {
31833183
"msg": "From and to router endpoints are the same"
31843184
},
31853185
{
3186-
"code": 8050,
3186+
"code": 8576,
3187+
"name": "mismatchingCloseAccountRefundRecipient"
3188+
},
3189+
{
3190+
"code": 8306,
31873191
"name": "invalidCctpMessage"
31883192
}
31893193
],

0 commit comments

Comments
 (0)