Skip to content

Commit

Permalink
Fix rustdoc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
febo committed Nov 11, 2024
1 parent fa2aaf9 commit 66195e6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ wasm-bindgen = "0.2"
[dev-dependencies]
anyhow = "1.0.89"
borsh = { version = "1.5.1", features = ["derive", "unstable__schema"] }
solana-account-info = "^2.1"
solana-cpi = "^2.1"
solana-nonce = "^0.0.2"
solana-program = { version = "^2.1", default-features = false }
solana-program-entrypoint = "^2.1"
solana-program-error = { version = "^2.1", features = ["borsh"] }
static_assertions = "1.1.0"
strum = "0.24"
strum_macros = "0.24"
Expand Down
33 changes: 18 additions & 15 deletions interface/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ pub enum SystemInstruction {
/// use borsh::{BorshDeserialize, BorshSerialize};
/// use solana_account_info::{next_account_info, AccountInfo};
/// use solana_cpi::invoke_signed;
/// use solana_program::sysvar::Sysvar;
/// use solana_program::sysvar::{rent::Rent, Sysvar};
/// use solana_program_entrypoint::entrypoint;
/// use solana_program_error::ProgramResult;
/// use solana_pubkey::Pubkey;
Expand Down Expand Up @@ -351,7 +351,7 @@ pub enum SystemInstruction {
/// // This program will sign for it via `invoke_signed`.
/// assert!(!new_account_pda.is_signer);
/// assert!(new_account_pda.is_writable);
/// assert!(system_program::check_id(system_account.key));
/// assert!(program::check_id(system_account.key));
///
/// let new_account_seed = &instr.new_account_seed;
/// let new_account_bump_seed = instr.new_account_bump_seed;
Expand Down Expand Up @@ -457,7 +457,7 @@ pub fn create_account_with_seed(
/// ```
/// # use solana_program::example_mocks::{solana_sdk, solana_rpc_client};
/// use solana_rpc_client::rpc_client::RpcClient;
/// use solana_pubkey::Pubkey
/// use solana_pubkey::Pubkey;
/// use solana_sdk::{
/// signature::{Keypair, Signer},
/// transaction::Transaction,
Expand Down Expand Up @@ -527,7 +527,7 @@ pub fn create_account_with_seed(
/// use borsh::{BorshDeserialize, BorshSerialize};
/// use solana_account_info::{next_account_info, AccountInfo};
/// use solana_cpi::invoke_signed;
/// use solana_program::sysvar::Sysvar;
/// use solana_program::sysvar::{rent::Rent, Sysvar};
/// use solana_program_entrypoint::entrypoint;
/// use solana_program_error::ProgramResult;
/// use solana_pubkey::Pubkey;
Expand Down Expand Up @@ -564,7 +564,7 @@ pub fn create_account_with_seed(
/// // This program will sign for it via `invoke_signed`.
/// assert!(!new_account_pda.is_signer);
/// assert!(new_account_pda.is_writable);
/// assert!(system_program::check_id(system_account.key));
/// assert!(program::check_id(system_account.key));
///
/// let new_account_seed = &instr.new_account_seed;
/// let new_account_bump_seed = instr.new_account_bump_seed;
Expand Down Expand Up @@ -648,7 +648,7 @@ pub fn assign_with_seed(
/// ```
/// # use solana_program::example_mocks::{solana_sdk, solana_rpc_client};
/// use solana_rpc_client::rpc_client::RpcClient;
/// use solana_pubkey::Pubkey
/// use solana_pubkey::Pubkey;
/// use solana_sdk::{
/// signature::{Keypair, Signer},
/// transaction::Transaction,
Expand Down Expand Up @@ -715,16 +715,17 @@ pub fn assign_with_seed(
/// [`invoke_signed`]: https://docs.rs/solana-cpi/latest/solana_cpi/fn.invoke_signed.html
///
/// ```
/// use borsh::{BorshDeserialize, BorshSerialize};
/// # use borsh::{BorshDeserialize, BorshSerialize};
/// use solana_account_info::{next_account_info, AccountInfo};
/// use solana_cpi::invoke_signed;
/// use solana_program::sysvar::Sysvar;
/// use solana_program::sysvar::{rent::Rent, Sysvar};
/// use solana_program_entrypoint::entrypoint;
/// use solana_program_error::ProgramResult;
/// use solana_pubkey::Pubkey;
/// use solana_system_interface::{instruction, program};
///
/// #[derive(BorshSerialize, BorshDeserialize, Debug)]
/// # #[borsh(crate = "borsh")]
/// pub struct CreateAccountInstruction {
/// /// The PDA seed used to distinguish the new account from other PDAs
/// pub new_account_seed: [u8; 16],
Expand Down Expand Up @@ -755,7 +756,7 @@ pub fn assign_with_seed(
/// // This program will sign for it via `invoke_signed`.
/// assert!(!new_account_pda.is_signer);
/// assert!(new_account_pda.is_writable);
/// assert!(system_program::check_id(system_account.key));
/// assert!(program::check_id(system_account.key));
///
/// let new_account_seed = &instr.new_account_seed;
/// let new_account_bump_seed = instr.new_account_bump_seed;
Expand Down Expand Up @@ -844,7 +845,7 @@ pub fn transfer_with_seed(
/// ```
/// # use solana_program::example_mocks::{solana_sdk, solana_rpc_client};
/// use solana_rpc_client::rpc_client::RpcClient;
/// use solana_pubkey::Pubkey
/// use solana_pubkey::Pubkey;
/// use solana_sdk::{
/// signature::{Keypair, Signer},
/// transaction::Transaction,
Expand Down Expand Up @@ -914,7 +915,7 @@ pub fn transfer_with_seed(
/// use borsh::{BorshDeserialize, BorshSerialize};
/// use solana_account_info::{next_account_info, AccountInfo};
/// use solana_cpi::invoke_signed;
/// use solana_program::sysvar::Sysvar;
/// use solana_program::sysvar::{rent::Rent, Sysvar};
/// use solana_program_entrypoint::entrypoint;
/// use solana_program_error::ProgramResult;
/// use solana_pubkey::Pubkey;
Expand Down Expand Up @@ -951,7 +952,7 @@ pub fn transfer_with_seed(
/// // This program will sign for it via `invoke_signed`.
/// assert!(!new_account_pda.is_signer);
/// assert!(new_account_pda.is_writable);
/// assert!(system_program::check_id(system_account.key));
/// assert!(program::check_id(system_account.key));
///
/// let new_account_seed = &instr.new_account_seed;
/// let new_account_bump_seed = instr.new_account_bump_seed;
Expand Down Expand Up @@ -1082,7 +1083,7 @@ pub fn allocate_with_seed(
/// [`invoke_signed`]: https://docs.rs/solana-cpi/latest/solana_cpi/fn.invoke_signed.html
///
/// ```
/// use borsh::{BorshDeserialize, BorshSerialize};
/// # use borsh::{BorshDeserialize, BorshSerialize};
/// use solana_account_info::{next_account_info, next_account_infos, AccountInfo};
/// use solana_cpi::invoke_signed;
/// use solana_program_entrypoint::entrypoint;
Expand All @@ -1095,7 +1096,8 @@ pub fn allocate_with_seed(
/// /// - 0: bank_pda - writable
/// /// - 1: system_program - executable
/// /// - *: to - writable
/// #[derive(BorshSerialize, BorshDeserialize, Debug)]
/// # #[derive(BorshSerialize, BorshDeserialize, Debug)]
/// # #[borsh(crate = "borsh")]
/// pub struct TransferLamportsToManyInstruction {
/// pub bank_pda_bump_seed: u8,
/// pub amount_list: Vec<u64>,
Expand Down Expand Up @@ -1359,6 +1361,7 @@ pub fn create_nonce_account(
/// # use solana_program::example_mocks::solana_sdk;
/// # use solana_program::example_mocks::solana_rpc_client;
/// # use solana_program::example_mocks::solana_rpc_client_nonce_utils;
/// # use solana_sdk::account::Account;
/// use solana_rpc_client::rpc_client::RpcClient;
/// use solana_pubkey::Pubkey;
/// use solana_sdk::{
Expand Down Expand Up @@ -1576,7 +1579,7 @@ pub fn withdraw_nonce_account(
/// new_authority_pubkey: &Pubkey,
/// ) -> Result<()> {
///
/// let instr = system_instruction::authorize_nonce_account(
/// let instr = instruction::authorize_nonce_account(
/// nonce_account_pubkey,
/// &authorized_account.pubkey(),
/// new_authority_pubkey,
Expand Down

0 comments on commit 66195e6

Please sign in to comment.