Skip to content

Commit 899aa34

Browse files
committed
testing a todo for cctp messenger minter program
1 parent 6226414 commit 899aa34

File tree

5 files changed

+73
-27
lines changed

5 files changed

+73
-27
lines changed

solana/Cargo.lock

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

solana/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bytemuck = "1.13.0"
5252
wormhole-svm-shim = { git = "https://github.com/wormhole-foundation/wormhole.git", rev = "33dd6a56541c2d15d3e20faa1330ba542a5fa727" }
5353
wormhole-svm-definitions = { git = "https://github.com/wormhole-foundation/wormhole.git", rev = "33dd6a56541c2d15d3e20faa1330ba542a5fa727", features = ["borsh"] }
5454

55-
[patch."https://github.com/wormholelabs-xyz/wormhole.git"]
55+
[patch."https://github.com/wormhole-foundation/wormhole.git"]
5656
wormhole-svm-shim = { path = "lib/wormhole/svm/wormhole-core-shims/crates/shim" }
5757
wormhole-svm-definitions = { path = "lib/wormhole/svm/wormhole-core-shims/crates/definitions" }
5858

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

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use crate::testing_engine::config::{ExecuteOrderInstructionConfig, InstructionConfig};
1+
use crate::testing_engine::config::{ExecuteOrderInstructionConfig, InstructionConfig, OverwriteAccountField};
22
use crate::testing_engine::setup::{TestingContext, TransferDirection};
33
use crate::testing_engine::state::{OrderExecutedState, TestingEngineState};
44

55
use super::super::utils;
6-
use anchor_spl::token::spl_token;
76
use common::wormhole_cctp_solana::cctp::{
87
MESSAGE_TRANSMITTER_PROGRAM_ID, TOKEN_MESSENGER_MINTER_PROGRAM_ID,
98
};
@@ -49,7 +48,6 @@ pub async fn execute_order_shimful(
4948
current_state,
5049
config,
5150
&fixture_accounts,
52-
config.fast_market_order_address,
5351
);
5452
let program_id = &testing_context.get_matching_engine_program_id();
5553
let payer_signer = config
@@ -107,7 +105,7 @@ pub async fn execute_order_shimful(
107105
}
108106

109107
/// A helper struct for the accounts for the execute order shimful instruction that disregards the lifetime
110-
struct ExecuteOrderShimfulAccounts {
108+
pub struct ExecuteOrderShimfulAccounts {
111109
pub signer: Pubkey,
112110
pub custodian: Pubkey,
113111
pub fast_market_order_address: Pubkey,
@@ -137,7 +135,6 @@ impl ExecuteOrderShimfulAccounts {
137135
current_state: &TestingEngineState,
138136
config: &ExecuteOrderInstructionConfig,
139137
fixture_accounts: &utils::account_fixtures::FixtureAccounts,
140-
override_fast_market_order_address: Option<Pubkey>,
141138
) -> Self {
142139
let payer_signer = config
143140
.payer_signer
@@ -149,12 +146,6 @@ impl ExecuteOrderShimfulAccounts {
149146
let initial_participant = active_auction_state.initial_offer.participant;
150147
let active_auction = active_auction_state.auction_address;
151148
let custodian = auction_accounts.custodian;
152-
let fast_market_order_address = override_fast_market_order_address.unwrap_or_else(|| {
153-
current_state
154-
.fast_market_order()
155-
.unwrap()
156-
.fast_market_order_address
157-
});
158149
let remote_token_messenger = match transfer_direction {
159150
TransferDirection::FromEthereumToArbitrum => {
160151
fixture_accounts.arbitrum_remote_token_messenger
@@ -208,8 +199,13 @@ impl ExecuteOrderShimfulAccounts {
208199
.0;
209200
let solver = config.actor_enum.get_actor(&testing_context.testing_actors);
210201
let executor_token = solver.token_account_address(&config.token_enum).unwrap();
211-
212-
Self {
202+
let fast_market_order_address = current_state
203+
.fast_market_order()
204+
.map(|fast_market_order| fast_market_order.fast_market_order_address)
205+
.unwrap_or_else(|| {
206+
Pubkey::new_unique()
207+
});
208+
let mut accounts = Self {
213209
signer: payer_signer.pubkey(),
214210
custodian: auction_accounts.custodian,
215211
fast_market_order_address,
@@ -231,7 +227,17 @@ impl ExecuteOrderShimfulAccounts {
231227
cctp_message,
232228
post_message_sequence,
233229
post_message_message,
230+
};
231+
if let Some(overwrite_accounts) = &config.overwrite_accounts {
232+
for field in overwrite_accounts.iter() {
233+
match field {
234+
OverwriteAccountField::CctpTokenMessengerMinter(value) => {
235+
accounts.token_messenger_minter_sender_authority = *value;
236+
}
237+
}
238+
}
234239
}
240+
accounts
235241
}
236242
}
237243

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//!
1111
1212
use std::collections::HashSet;
13-
13+
use anchor_lang::prelude::Pubkey;
1414
use crate::test_scenarios::make_offer::place_initial_offer_shimless;
1515
use crate::testing_engine;
1616
use crate::testing_engine::config::{
@@ -1084,6 +1084,39 @@ pub async fn test_execute_order_shim_emitter_chain_mismatch() {
10841084
.await;
10851085
}
10861086

1087+
/// Cannot execute order shim when the cctp token messenger minter program is not the expected program
1088+
#[tokio::test]
1089+
pub async fn test_execute_order_shim_cctp_token_messenger_minter_program_mismatch() {
1090+
let transfer_direction = TransferDirection::FromEthereumToArbitrum;
1091+
let (place_initial_offer_state, mut test_context, testing_engine) =
1092+
Box::pin(place_initial_offer_shim(
1093+
PlaceInitialOfferInstructionConfig::default(),
1094+
None,
1095+
transfer_direction,
1096+
))
1097+
.await;
1098+
let instruction_triggers = vec![InstructionTrigger::ExecuteOrderShim(
1099+
ExecuteOrderInstructionConfig {
1100+
expected_error: Some(ExpectedError {
1101+
instruction_index: 2,
1102+
error_code: 2006,
1103+
error_string: "ConstraintSeeds".to_string(),
1104+
}),
1105+
overwrite_accounts: Some(OverwriteAccounts(vec![OverwriteAccountField::CctpTokenMessengerMinter(
1106+
Pubkey::new_unique(),
1107+
)])),
1108+
..ExecuteOrderInstructionConfig::default()
1109+
},
1110+
)];
1111+
testing_engine
1112+
.execute(
1113+
&mut test_context,
1114+
instruction_triggers,
1115+
Some(place_initial_offer_state),
1116+
)
1117+
.await;
1118+
}
1119+
10871120
/// Cannot execute order shim before auction duration is over
10881121
#[tokio::test]
10891122
pub async fn test_execute_order_shim_before_auction_duration_is_over() {

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,26 @@ impl InstructionConfig for PrepareOrderResponseInstructionConfig {
177177
}
178178
}
179179

180+
#[derive(Clone)]
181+
pub struct OverwriteAccounts(pub Vec<OverwriteAccountField>);
182+
183+
impl Deref for OverwriteAccounts {
184+
type Target = Vec<OverwriteAccountField>;
185+
186+
fn deref(&self) -> &Self::Target {
187+
&self.0
188+
}
189+
}
190+
191+
#[derive(Clone)]
192+
pub enum OverwriteAccountField {
193+
CctpTokenMessengerMinter(Pubkey),
194+
// Add other fields here if needed
195+
}
196+
180197
#[derive(Clone)]
181198
pub struct ExecuteOrderInstructionConfig {
182-
pub fast_market_order_address: OverwriteCurrentState<Pubkey>,
199+
pub overwrite_accounts: OverwriteCurrentState<OverwriteAccounts>,
183200
pub actor_enum: TestingActorEnum,
184201
pub token_enum: SplTokenEnum,
185202
pub vaa_index: usize,
@@ -194,7 +211,7 @@ impl Default for ExecuteOrderInstructionConfig {
194211
Self {
195212
fast_forward_slots: 3,
196213
actor_enum: TestingActorEnum::default(),
197-
fast_market_order_address: None,
214+
overwrite_accounts: None,
198215
token_enum: SplTokenEnum::default(),
199216
vaa_index: 0,
200217
payer_signer: None,

0 commit comments

Comments
 (0)