Skip to content

Commit 8680311

Browse files
committed
get rid of swap instruction in check_approved_program tests
1 parent 3142052 commit 8680311

File tree

1 file changed

+15
-80
lines changed

1 file changed

+15
-80
lines changed

auction-server/src/auction/service/verification.rs

Lines changed: 15 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,19 +2318,8 @@ mod tests {
23182318

23192319
#[tokio::test]
23202320
async fn test_check_approved_program_when_unsupported_system_program_instruction() {
2321-
let (service, opportunities) = get_service(true);
2322-
let opportunity = opportunities.user_token_specified.clone();
2323-
let bid_amount = 1;
2321+
let (service, _) = get_service(true);
23242322
let searcher = Keypair::new();
2325-
let swap_instruction = svm::Svm::get_swap_instruction(GetSwapInstructionParams {
2326-
searcher: searcher.pubkey(),
2327-
opportunity_params: get_opportunity_params(opportunity.clone()),
2328-
bid_amount,
2329-
deadline: (OffsetDateTime::now_utc() + Duration::seconds(30)).unix_timestamp(),
2330-
fee_receiver_relayer: Pubkey::new_unique(),
2331-
relayer_signer: service.config.chain_config.express_relay.relayer.pubkey(),
2332-
})
2333-
.unwrap();
23342323
let instructions = vec![
23352324
system_instruction::advance_nonce_account(&Pubkey::new_unique(), &Pubkey::new_unique()),
23362325
system_instruction::create_account(
@@ -2354,10 +2343,8 @@ mod tests {
23542343
];
23552344
for instruction in instructions.into_iter() {
23562345
let program_id = instruction.program_id;
2357-
let transaction = Transaction::new_with_payer(
2358-
&[instruction.clone(), swap_instruction.clone()],
2359-
Some(&searcher.pubkey()),
2360-
);
2346+
let transaction =
2347+
Transaction::new_with_payer(&[instruction.clone()], Some(&searcher.pubkey()));
23612348
let instruction = transaction
23622349
.message()
23632350
.instructions
@@ -2374,19 +2361,8 @@ mod tests {
23742361

23752362
#[tokio::test]
23762363
async fn test_check_approved_program_when_unsupported_token_instruction() {
2377-
let (service, opportunities) = get_service(true);
2378-
let opportunity = opportunities.user_token_specified.clone();
2379-
let bid_amount = 1;
2364+
let (service, _) = get_service(true);
23802365
let searcher = Keypair::new();
2381-
let swap_instruction = svm::Svm::get_swap_instruction(GetSwapInstructionParams {
2382-
searcher: searcher.pubkey(),
2383-
opportunity_params: get_opportunity_params(opportunity.clone()),
2384-
bid_amount,
2385-
deadline: (OffsetDateTime::now_utc() + Duration::seconds(30)).unix_timestamp(),
2386-
fee_receiver_relayer: Pubkey::new_unique(),
2387-
relayer_signer: service.config.chain_config.express_relay.relayer.pubkey(),
2388-
})
2389-
.unwrap();
23902366
let instructions = vec![
23912367
spl_token::instruction::initialize_account(
23922368
&spl_token::id(),
@@ -2482,10 +2458,8 @@ mod tests {
24822458
let data = instruction.data.clone();
24832459
let ix_parsed = TokenInstruction::unpack(&data).unwrap();
24842460
let program_id = instruction.program_id;
2485-
let transaction = Transaction::new_with_payer(
2486-
&[instruction.clone(), swap_instruction.clone()],
2487-
Some(&searcher.pubkey()),
2488-
);
2461+
let transaction =
2462+
Transaction::new_with_payer(&[instruction.clone()], Some(&searcher.pubkey()));
24892463
let instruction = transaction
24902464
.message()
24912465
.instructions
@@ -2502,19 +2476,8 @@ mod tests {
25022476

25032477
#[tokio::test]
25042478
async fn test_check_approved_program_when_unsupported_token_2022_instruction() {
2505-
let (service, opportunities) = get_service(true);
2506-
let opportunity = opportunities.user_token_specified.clone();
2507-
let bid_amount = 1;
2479+
let (service, _) = get_service(true);
25082480
let searcher = Keypair::new();
2509-
let swap_instruction = svm::Svm::get_swap_instruction(GetSwapInstructionParams {
2510-
searcher: searcher.pubkey(),
2511-
opportunity_params: get_opportunity_params(opportunity.clone()),
2512-
bid_amount,
2513-
deadline: (OffsetDateTime::now_utc() + Duration::seconds(30)).unix_timestamp(),
2514-
fee_receiver_relayer: Pubkey::new_unique(),
2515-
relayer_signer: service.config.chain_config.express_relay.relayer.pubkey(),
2516-
})
2517-
.unwrap();
25182481
let instructions = vec![
25192482
spl_token_2022::instruction::initialize_account(
25202483
&spl_token_2022::id(),
@@ -2612,10 +2575,8 @@ mod tests {
26122575
let data = instruction.data.clone();
26132576
let ix_parsed = TokenInstruction::unpack(&data).unwrap();
26142577
let program_id = instruction.program_id;
2615-
let transaction = Transaction::new_with_payer(
2616-
&[instruction.clone(), swap_instruction.clone()],
2617-
Some(&searcher.pubkey()),
2618-
);
2578+
let transaction =
2579+
Transaction::new_with_payer(&[instruction.clone()], Some(&searcher.pubkey()));
26192580
let instruction = transaction
26202581
.message()
26212582
.instructions
@@ -2632,19 +2593,8 @@ mod tests {
26322593

26332594
#[tokio::test]
26342595
async fn test_check_approved_program_when_unsupported_associated_token_account_instruction() {
2635-
let (service, opportunities) = get_service(true);
2636-
let opportunity = opportunities.user_token_specified.clone();
2637-
let bid_amount = 1;
2596+
let (service, _) = get_service(true);
26382597
let searcher = Keypair::new();
2639-
let swap_instruction = svm::Svm::get_swap_instruction(GetSwapInstructionParams {
2640-
searcher: searcher.pubkey(),
2641-
opportunity_params: get_opportunity_params(opportunity.clone()),
2642-
bid_amount,
2643-
deadline: (OffsetDateTime::now_utc() + Duration::seconds(30)).unix_timestamp(),
2644-
fee_receiver_relayer: Pubkey::new_unique(),
2645-
relayer_signer: service.config.chain_config.express_relay.relayer.pubkey(),
2646-
})
2647-
.unwrap();
26482598
let instructions = vec![recover_nested(
26492599
&Pubkey::new_unique(),
26502600
&Pubkey::new_unique(),
@@ -2660,10 +2610,8 @@ mod tests {
26602610
})
26612611
.unwrap();
26622612
let program_id = instruction.program_id;
2663-
let transaction = Transaction::new_with_payer(
2664-
&[instruction.clone(), swap_instruction.clone()],
2665-
Some(&searcher.pubkey()),
2666-
);
2613+
let transaction =
2614+
Transaction::new_with_payer(&[instruction.clone()], Some(&searcher.pubkey()));
26672615
let instruction = transaction
26682616
.message()
26692617
.instructions
@@ -2680,26 +2628,13 @@ mod tests {
26802628

26812629
#[tokio::test]
26822630
async fn test_check_approved_program_when_unapproved_program_id() {
2683-
let (service, opportunities) = get_service(true);
2684-
let opportunity = opportunities.user_token_specified.clone();
2685-
let bid_amount = 1;
2631+
let (service, _) = get_service(true);
26862632
let searcher = Keypair::new();
2687-
let swap_instruction = svm::Svm::get_swap_instruction(GetSwapInstructionParams {
2688-
searcher: searcher.pubkey(),
2689-
opportunity_params: get_opportunity_params(opportunity.clone()),
2690-
bid_amount,
2691-
deadline: (OffsetDateTime::now_utc() + Duration::seconds(30)).unix_timestamp(),
2692-
fee_receiver_relayer: Pubkey::new_unique(),
2693-
relayer_signer: service.config.chain_config.express_relay.relayer.pubkey(),
2694-
})
2695-
.unwrap();
26962633
let program_id = Pubkey::new_unique();
26972634
let instruction = Instruction::new_with_bincode(program_id, &"", vec![]);
26982635

2699-
let transaction = Transaction::new_with_payer(
2700-
&[instruction.clone(), swap_instruction.clone()],
2701-
Some(&searcher.pubkey()),
2702-
);
2636+
let transaction =
2637+
Transaction::new_with_payer(&[instruction.clone()], Some(&searcher.pubkey()));
27032638
let instruction = transaction
27042639
.message()
27052640
.instructions

0 commit comments

Comments
 (0)