express_relay/sdk/
test_helpers.rs

1use {
2    crate::{
3        accounts,
4        instruction,
5        InitializeArgs,
6        ID as EXPRESS_RELAY_PID,
7        SEED_METADATA,
8    },
9    anchor_lang::{
10        prelude::*,
11        solana_program::instruction::Instruction,
12        system_program,
13        InstructionData,
14    },
15};
16
17/// Test helper method to create an instruction to initialize the express relay program.
18/// Should be able to sign transactions with the secret keys of the provided payer and `relayer_signer`.
19/// The fee split is set to 100% for the router, since fee payments to relayer are not important for the integrating program's tests.
20/// Instead it is more important for the integrating program to ensure their router account has enough rent to avoid `InsufficientRent` error.
21pub fn create_initialize_express_relay_ix(
22    payer: Pubkey,
23    admin: Pubkey,
24    relayer_signer: Pubkey,
25    fee_receiver_relayer: Pubkey,
26) -> Instruction {
27    let express_relay_metadata =
28        Pubkey::find_program_address(&[SEED_METADATA], &EXPRESS_RELAY_PID).0;
29
30    let split_router_default = 10000;
31    let split_relayer = 0;
32
33    let accounts_initialize = accounts::Initialize {
34        payer,
35        express_relay_metadata,
36        admin,
37        relayer_signer,
38        fee_receiver_relayer,
39        system_program: system_program::ID,
40    }
41    .to_account_metas(None);
42    let data_initialize = instruction::Initialize {
43        data: InitializeArgs {
44            split_router_default,
45            split_relayer,
46        },
47    }
48    .data();
49
50    Instruction {
51        program_id: EXPRESS_RELAY_PID,
52        accounts:   accounts_initialize,
53        data:       data_initialize,
54    }
55}