Skip to content

Commit 9a52c06

Browse files
Bengt Lofgrena5-pickle
authored andcommitted
docstrings edited and added
1 parent 940c716 commit 9a52c06

File tree

6 files changed

+281
-21
lines changed

6 files changed

+281
-21
lines changed

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,14 @@ use wormhole_io::TypePrefixedPayload;
3333
/// # Arguments
3434
///
3535
/// * `testing_context` - The testing context
36-
/// * `payer_signer` - The payer signer keypair
37-
/// * `fast_market_order` - The fast market order state
38-
/// * `guardian_set_pubkey` - The guardian set pubkey
39-
/// * `guardian_signatures_pubkey` - The guardian signatures pubkey
40-
/// * `guardian_set_bump` - The guardian set bump
36+
/// * `test_context` - The program test context
4137
/// * `expected_error` - The expected error
38+
/// * `current_state` - The current testing engine state
39+
/// * `config` - The initialization configuration
4240
///
43-
/// # Asserts
41+
/// # Returns
4442
///
45-
/// * The expected error, if any, is reached when executing the instruction
43+
/// * `TestingEngineState` - The updated testing engine state
4644
pub async fn initialize_fast_market_order_shimful(
4745
testing_context: &TestingContext,
4846
test_context: &mut ProgramTestContext,
@@ -134,9 +132,7 @@ pub async fn initialize_fast_market_order_shimful(
134132
/// * `payer_signer` - The payer signer keypair
135133
/// * `program_id` - The program id
136134
/// * `fast_market_order` - The fast market order state
137-
/// * `guardian_set_pubkey` - The guardian set pubkey
138-
/// * `guardian_signatures_pubkey` - The guardian signatures pubkey
139-
/// * `guardian_set_bump` - The guardian set bump
135+
/// * `guardian_signature_info` - Information about guardian signatures
140136
///
141137
/// # Returns
142138
///
@@ -184,7 +180,8 @@ pub fn initialize_fast_market_order_shimful_instruction(
184180
/// # Arguments
185181
///
186182
/// * `testing_context` - The testing context
187-
/// * `refund_recipient_keypair` - The refund recipient keypair that will receive the refund after closing the fast market order account
183+
/// * `test_context` - The program test context
184+
/// * `refund_recipient_keypair` - The refund recipient keypair that will receive the refund
188185
/// * `fast_market_order_address` - The fast market order account address
189186
/// * `expected_error` - The expected error
190187
///

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,17 @@ pub fn create_execute_order_fallback_fixture(
215215
}
216216
}
217217

218+
/// Create the execute order shim accounts
219+
///
220+
/// # Arguments
221+
///
222+
/// * `execute_order_fallback_accounts` - The execute order fallback accounts
223+
/// * `execute_order_fallback_fixture` - The execute order fallback fixture
224+
/// * `clock_id` - The clock id
225+
///
226+
/// # Returns
227+
///
228+
/// The execute order shim accounts
218229
pub fn create_execute_order_shim_accounts<'ix>(
219230
execute_order_fallback_accounts: &'ix ExecuteOrderFallbackAccounts,
220231
execute_order_fallback_fixture: &'ix ExecuteOrderFallbackFixture,

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@ pub async fn place_initial_offer_shimful(
9090
.await
9191
}
9292

93+
/// Evaluate the place initial offer shimful state
94+
///
95+
/// # Arguments
96+
///
97+
/// * `testing_context` - The testing context
98+
/// * `test_context` - The test context
99+
/// * `current_state` - The current state
100+
/// * `config` - The config
101+
/// * `actor_usdc_balance_before` - The actor USDC balance before
102+
/// * `place_initial_offer_accounts` - The place initial offer shimful accounts
103+
///
104+
/// # Returns
105+
///
106+
/// The testing engine state after the place initial offer shimful instruction
93107
pub async fn evaluate_place_initial_offer_shimful_state(
94108
testing_context: &TestingContext,
95109
test_context: &mut ProgramTestContext,
@@ -170,6 +184,20 @@ pub async fn evaluate_place_initial_offer_shimful_state(
170184
current_state.clone()
171185
}
172186

187+
/// Place the initial offer shimful instruction
188+
///
189+
/// Creates the place initial offer shimful instruction
190+
///
191+
/// # Arguments
192+
///
193+
/// * `testing_context` - The testing context
194+
/// * `test_context` - The test context
195+
/// * `current_state` - The current state
196+
/// * `config` - The config
197+
///
198+
/// # Returns
199+
///
200+
/// The place initial offer shimful instruction
173201
pub async fn place_initial_offer_shimful_instruction(
174202
testing_context: &TestingContext,
175203
test_context: &mut ProgramTestContext,

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

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,38 @@ impl PrepareOrderResponseShimAccountsFixture {
145145
}
146146
}
147147

148-
pub struct PrepareOrderResponseShimDataFixture {
148+
/// Prepare order response shim data helper
149+
///
150+
/// This struct is a helper struct used to create the data for the prepare order response instruction
151+
///
152+
/// # Fields
153+
///
154+
/// * `encoded_cctp_message` - The encoded CCTP message
155+
/// * `cctp_attestation` - The CCTP attestation
156+
/// * `finalized_vaa_message_args` - The finalized VAA message args
157+
/// * `fast_market_order` - The fast market order
158+
pub struct PrepareOrderResponseShimDataHelper {
149159
pub encoded_cctp_message: Vec<u8>,
150160
pub cctp_attestation: Vec<u8>,
151161
pub finalized_vaa_message_args: FinalizedVaaMessageArgs,
152162
pub fast_market_order: FastMarketOrderState,
153163
}
154164

155-
// Helper struct for creating the data for the prepare order response instruction
156-
impl PrepareOrderResponseShimDataFixture {
165+
impl PrepareOrderResponseShimDataHelper {
166+
/// Create a new prepare order response shim data helper
167+
///
168+
/// # Arguments
169+
///
170+
/// * `encoded_cctp_message` - The encoded CCTP message
171+
/// * `cctp_attestation` - The CCTP attestation
172+
/// * `consistency_level` - The consistency level
173+
/// * `base_fee` - The base fee
174+
/// * `fast_market_order` - The fast market order
175+
/// * `guardian_set_bump` - The guardian set bump
176+
///
177+
/// # Returns
178+
///
179+
/// The prepare order response shim data helper
157180
pub fn new(
158181
encoded_cctp_message: Vec<u8>,
159182
cctp_attestation: Vec<u8>,
@@ -183,12 +206,25 @@ impl PrepareOrderResponseShimDataFixture {
183206
}
184207

185208
/// Executes the instruction that prepares the order response for the CCTP shim
209+
///
210+
/// # Arguments
211+
///
212+
/// * `testing_context` - The testing context
213+
/// * `test_context` - The test context
214+
/// * `payer_signer` - The payer signer
215+
/// * `accounts` - The prepare order response shim accounts
216+
/// * `data` - The prepare order response shim data
217+
/// * `expected_error` - The expected error
218+
///
219+
/// # Returns
220+
///
221+
/// The prepare order response shim fixture
186222
pub async fn prepare_order_response_cctp_shim(
187223
testing_context: &TestingContext,
188224
test_context: &mut ProgramTestContext,
189225
payer_signer: &Rc<Keypair>,
190226
accounts: PrepareOrderResponseShimAccountsFixture,
191-
data: PrepareOrderResponseShimDataFixture,
227+
data: PrepareOrderResponseShimDataHelper,
192228
expected_error: Option<&ExpectedError>,
193229
) -> Option<PrepareOrderResponseShimFixture> {
194230
let matching_engine_program_id = &testing_context.get_matching_engine_program_id();
@@ -280,6 +316,20 @@ pub async fn prepare_order_response_cctp_shim(
280316
}
281317
}
282318

319+
/// Prepare order response test
320+
///
321+
/// Executes the prepare order response instruction in a testing context
322+
///
323+
/// # Arguments
324+
///
325+
/// * `testing_context` - The testing context
326+
/// * `test_context` - The test context
327+
/// * `config` - The prepare order response instruction config
328+
/// * `current_state` - The current state
329+
///
330+
/// # Returns
331+
///
332+
/// The prepare order response shim fixture (none if failed)
283333
pub async fn prepare_order_response_test(
284334
testing_context: &TestingContext,
285335
test_context: &mut ProgramTestContext,
@@ -337,7 +387,7 @@ pub async fn prepare_order_response_test(
337387
.unwrap();
338388

339389
let deposit_base_fee = utils::cctp_message::get_deposit_base_fee(&deposit);
340-
let prepare_order_response_cctp_shim_data = PrepareOrderResponseShimDataFixture::new(
390+
let prepare_order_response_cctp_shim_data = PrepareOrderResponseShimDataHelper::new(
341391
cctp_token_burn_message.encoded_cctp_burn_message,
342392
cctp_token_burn_message.cctp_attestation,
343393
deposit_vaa_data.consistency_level,

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ impl TestingEngine {
391391
}
392392
}
393393

394+
// --------------------------------------------------------------------------------------------
395+
// Instruction trigger functions
396+
// --------------------------------------------------------------------------------------------
397+
394398
/// Creates the initial state for the testing engine
395399
pub fn create_initial_state(&self) -> TestingEngineState {
396400
let fixture_accounts = self
@@ -536,6 +540,8 @@ impl TestingEngine {
536540
order_executed: current_state.order_executed().cloned(),
537541
}
538542
}
543+
544+
/// Instruction trigger function for placing an initial offer
539545
async fn place_initial_offer_shimless(
540546
&self,
541547
test_context: &mut ProgramTestContext,
@@ -860,6 +866,10 @@ impl TestingEngine {
860866
}
861867
}
862868

869+
// --------------------------------------------------------------------------------------------
870+
// Verification trigger functions
871+
// --------------------------------------------------------------------------------------------
872+
863873
async fn verify_auction_state(
864874
&self,
865875
test_context: &mut ProgramTestContext,
@@ -923,6 +933,10 @@ impl TestingEngine {
923933
current_state.clone()
924934
}
925935

936+
// --------------------------------------------------------------------------------------------
937+
// Combination trigger functions
938+
// --------------------------------------------------------------------------------------------
939+
926940
async fn create_fast_market_order_and_place_initial_offer(
927941
&self,
928942
test_context: &mut ProgramTestContext,
@@ -1038,6 +1052,10 @@ impl TestingEngine {
10381052
.await
10391053
}
10401054

1055+
// --------------------------------------------------------------------------------------------
1056+
// Helper functions for manipulating the state
1057+
// --------------------------------------------------------------------------------------------
1058+
10411059
pub async fn make_auction_passed_penalty_period(
10421060
&self,
10431061
test_context: &mut ProgramTestContext,

0 commit comments

Comments
 (0)