Skip to content

Commit e0f97f9

Browse files
Bengt Lofgrena5-pickle
authored andcommitted
[broken] signers not attached properly
1 parent 1a7abb6 commit e0f97f9

File tree

7 files changed

+700
-414
lines changed

7 files changed

+700
-414
lines changed

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

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
use crate::testing_engine::config::ExpectedError;
1+
use crate::testing_engine::config::{
2+
ExpectedError, InitializeFastMarketOrderShimInstructionConfig,
3+
};
4+
use crate::testing_engine::state::{
5+
FastMarketOrderAccountCreatedState, GuardianSetState, TestingEngineState,
6+
};
27

3-
use super::verify_shim::GuardianSignatureInfo;
8+
use super::verify_shim::{create_guardian_signatures, GuardianSignatureInfo};
49
use crate::testing_engine::setup::TestingContext;
510
use crate::utils;
611
use common::messages::FastMarketOrder;
@@ -38,34 +43,86 @@ use wormhole_io::TypePrefixedPayload;
3843
/// # Asserts
3944
///
4045
/// * The expected error, if any, is reached when executing the instruction
41-
pub async fn initialize_fast_market_order_fallback(
46+
pub async fn initialize_fast_market_order_shimful(
4247
testing_context: &TestingContext,
4348
test_context: &mut ProgramTestContext,
44-
payer_signer: &Rc<Keypair>,
45-
fast_market_order: FastMarketOrderState,
46-
guardian_signature_info: &GuardianSignatureInfo,
4749
expected_error: Option<&ExpectedError>,
48-
) {
50+
current_state: &TestingEngineState,
51+
config: &InitializeFastMarketOrderShimInstructionConfig,
52+
) -> TestingEngineState {
4953
let program_id = &testing_context.get_matching_engine_program_id();
50-
let initialize_fast_market_order_ix = initialize_fast_market_order_fallback_instruction(
51-
payer_signer,
54+
let test_vaa_pair = current_state.get_test_vaa_pair(config.vaa_index);
55+
let fast_transfer_vaa = test_vaa_pair.fast_transfer_vaa.clone();
56+
let fast_market_order = create_fast_market_order_state_from_vaa_data(
57+
&fast_transfer_vaa.vaa_data,
58+
config
59+
.close_account_refund_recipient
60+
.unwrap_or_else(|| testing_context.testing_actors.solvers[0].pubkey()),
61+
);
62+
let payer_signer = config
63+
.payer_signer
64+
.clone()
65+
.unwrap_or_else(|| testing_context.testing_actors.payer_signer.clone());
66+
let guardian_signature_info = create_guardian_signatures(
67+
&testing_context,
68+
test_context,
69+
&payer_signer,
70+
&fast_transfer_vaa.vaa_data,
71+
&testing_context.get_wormhole_program_id(),
72+
None,
73+
)
74+
.await
75+
.expect("Failed to create guardian signatures");
76+
77+
let (fast_market_order_account, fast_market_order_bump) = Pubkey::find_program_address(
78+
&[
79+
FastMarketOrderState::SEED_PREFIX,
80+
&fast_market_order.digest(),
81+
&fast_market_order.close_account_refund_recipient.as_ref(),
82+
],
83+
program_id,
84+
);
85+
let initialize_fast_market_order_ix = initialize_fast_market_order_shimful_instruction(
86+
&payer_signer,
5287
program_id,
5388
fast_market_order,
54-
guardian_signature_info,
89+
&guardian_signature_info,
5590
);
5691
let transaction = testing_context
5792
.create_transaction(
5893
test_context,
5994
&[initialize_fast_market_order_ix],
6095
Some(&payer_signer.pubkey()),
61-
&[payer_signer],
96+
&[&payer_signer],
6297
1000000000,
6398
1000000000,
6499
)
65100
.await;
66101
testing_context
67102
.execute_and_verify_transaction(test_context, transaction, expected_error)
68103
.await;
104+
if config.expected_error.is_none() {
105+
TestingEngineState::FastMarketOrderAccountCreated {
106+
base: current_state.base().clone(),
107+
initialized: current_state.initialized().unwrap().clone(),
108+
router_endpoints: current_state.router_endpoints().cloned(),
109+
fast_market_order: FastMarketOrderAccountCreatedState {
110+
fast_market_order_address: fast_market_order_account,
111+
fast_market_order_bump,
112+
fast_market_order,
113+
close_account_refund_recipient: fast_market_order.close_account_refund_recipient,
114+
},
115+
guardian_set_state: GuardianSetState {
116+
guardian_set_address: guardian_signature_info.guardian_set_pubkey,
117+
guardian_signatures_address: guardian_signature_info.guardian_signatures_pubkey,
118+
},
119+
auction_state: current_state.auction_state().clone(),
120+
auction_accounts: current_state.auction_accounts().cloned(),
121+
order_prepared: current_state.order_prepared().cloned(),
122+
}
123+
} else {
124+
current_state.clone()
125+
}
69126
}
70127

71128
/// Creates the initialize fast market order fallback instruction
@@ -84,7 +141,7 @@ pub async fn initialize_fast_market_order_fallback(
84141
/// # Returns
85142
///
86143
/// * `Instruction` - The initialize fast market order fallback instruction
87-
fn initialize_fast_market_order_fallback_instruction(
144+
pub fn initialize_fast_market_order_shimful_instruction(
88145
payer_signer: &Rc<Keypair>,
89146
program_id: &Pubkey,
90147
fast_market_order: FastMarketOrderState,

0 commit comments

Comments
 (0)