Skip to content

Commit

Permalink
✅ update test_program so it can be simply expanded, update expected code
Browse files Browse the repository at this point in the history
  • Loading branch information
lukacan committed Feb 14, 2024
1 parent 286e301 commit 608c93d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
1 change: 1 addition & 0 deletions crates/client/src/fuzzer/fuzzer_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ pub fn generate_source_code(idl: &Idl) -> String {

let fuzzer_module: syn::ItemMod = parse_quote! {
pub mod #fuzz_instructions_module_name {
use trdelnik_client::fuzzing::*;
use crate::accounts_snapshots::*;

#[derive(Arbitrary, Clone, DisplayIx, FuzzTestExecutor, FuzzDeserialize)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ mod instructions {
error_msg: VestingError::InvalidAmount.to_string(),
error_origin: Some(anchor_lang::error::ErrorOrigin::Source(
anchor_lang::error::Source {
filename: "programs/fuzz_example3/src/instructions/initialize.rs",
filename: "src/instructions/initialize.rs",
line: 18u32,
},
)),
Expand All @@ -124,7 +124,7 @@ mod instructions {
error_msg: VestingError::InvalidTimeRange.to_string(),
error_origin: Some(anchor_lang::error::ErrorOrigin::Source(
anchor_lang::error::Source {
filename: "programs/fuzz_example3/src/instructions/initialize.rs",
filename: "src/instructions/initialize.rs",
line: 20u32,
},
)),
Expand All @@ -140,7 +140,7 @@ mod instructions {
error_msg: VestingError::InvalidInterval.to_string(),
error_origin: Some(anchor_lang::error::ErrorOrigin::Source(
anchor_lang::error::Source {
filename: "programs/fuzz_example3/src/instructions/initialize.rs",
filename: "src/instructions/initialize.rs",
line: 22u32,
},
)),
Expand All @@ -156,7 +156,7 @@ mod instructions {
error_msg: VestingError::InvalidInterval.to_string(),
error_origin: Some(anchor_lang::error::ErrorOrigin::Source(
anchor_lang::error::Source {
filename: "programs/fuzz_example3/src/instructions/initialize.rs",
filename: "src/instructions/initialize.rs",
line: 23u32,
},
)),
Expand Down Expand Up @@ -365,7 +365,7 @@ mod instructions {
error_code_number: anchor_lang::error::ErrorCode::TryingToInitPayerAsProgramAccount.into(),
error_msg: anchor_lang::error::ErrorCode::TryingToInitPayerAsProgramAccount.to_string(),
error_origin: Some(anchor_lang::error::ErrorOrigin::Source(anchor_lang::error::Source {
filename: "programs/fuzz_example3/src/instructions/initialize.rs",
filename: "src/instructions/initialize.rs",
line: 64u32,
})),
compared_values: None,
Expand Down Expand Up @@ -1364,7 +1364,7 @@ pub mod state {
.to_string(),
error_origin: Some(anchor_lang::error::ErrorOrigin::Source(
anchor_lang::error::Source {
filename: "programs/fuzz_example3/src/state.rs",
filename: "src/state.rs",
line: 3u32,
},
)),
Expand Down Expand Up @@ -1764,7 +1764,7 @@ mod __private {
.to_string(),
error_origin: Some(anchor_lang::error::ErrorOrigin::Source(
anchor_lang::error::Source {
filename: "programs/fuzz_example3/src/lib.rs",
filename: "src/lib.rs",
line: 11u32,
},
)),
Expand Down Expand Up @@ -3424,7 +3424,7 @@ mod __private {
error_msg: anchor_lang::error::ErrorCode::RequireEqViolated.to_string(),
error_origin: Some(anchor_lang::error::ErrorOrigin::Source(
anchor_lang::error::Source {
filename: "programs/fuzz_example3/src/lib.rs",
filename: "src/lib.rs",
line: 11u32,
},
)),
Expand Down Expand Up @@ -3466,7 +3466,7 @@ mod __private {
error_msg: anchor_lang::error::ErrorCode::RequireGteViolated.to_string(),
error_origin: Some(anchor_lang::error::ErrorOrigin::Source(
anchor_lang::error::Source {
filename: "programs/fuzz_example3/src/lib.rs",
filename: "src/lib.rs",
line: 11u32,
},
)),
Expand All @@ -3492,7 +3492,7 @@ mod __private {
let ix = instruction::InitVesting::deserialize(&mut &__ix_data[..])
.map_err(|_| anchor_lang::error::ErrorCode::InstructionDidNotDeserialize)?;
let instruction::InitVesting {
recipient,
i_recipient,
amount,
start_at,
end_at,
Expand All @@ -3515,7 +3515,7 @@ mod __private {
__remaining_accounts,
__bumps,
),
recipient,
i_recipient,
amount,
start_at,
end_at,
Expand Down Expand Up @@ -3557,13 +3557,13 @@ pub mod fuzz_example3 {
use super::*;
pub fn init_vesting(
ctx: Context<InitVesting>,
recipient: Pubkey,
i_recipient: Pubkey,
amount: u64,
start_at: u64,
end_at: u64,
interval: u64,
) -> Result<()> {
_init_vesting(ctx, recipient, amount, start_at, end_at, interval)
_init_vesting(ctx, i_recipient, amount, start_at, end_at, interval)
}
pub fn withdraw_unlocked(ctx: Context<WithdrawUnlocked>) -> Result<()> {
_withdraw_unlocked(ctx)
Expand All @@ -3579,7 +3579,7 @@ pub mod instruction {
use super::*;
#[doc = r" Instruction."]
pub struct InitVesting {
pub recipient: Pubkey,
pub i_recipient: Pubkey,
pub amount: u64,
pub start_at: u64,
pub end_at: u64,
Expand All @@ -3597,7 +3597,7 @@ pub mod instruction {
&self,
writer: &mut W,
) -> ::core::result::Result<(), borsh::maybestd::io::Error> {
borsh::BorshSerialize::serialize(&self.recipient, writer)?;
borsh::BorshSerialize::serialize(&self.i_recipient, writer)?;
borsh::BorshSerialize::serialize(&self.amount, writer)?;
borsh::BorshSerialize::serialize(&self.start_at, writer)?;
borsh::BorshSerialize::serialize(&self.end_at, writer)?;
Expand All @@ -3617,7 +3617,7 @@ pub mod instruction {
reader: &mut R,
) -> ::core::result::Result<Self, borsh::maybestd::io::Error> {
Ok(Self {
recipient: borsh::BorshDeserialize::deserialize_reader(reader)?,
i_recipient: borsh::BorshDeserialize::deserialize_reader(reader)?,
amount: borsh::BorshDeserialize::deserialize_reader(reader)?,
start_at: borsh::BorshDeserialize::deserialize_reader(reader)?,
end_at: borsh::BorshDeserialize::deserialize_reader(reader)?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub mod fuzz_example3_fuzz_instructions {
}
#[derive(Arbitrary, Clone)]
pub struct InitVestingData {
pub recipient: Pubkey,
pub i_recipient: AccountId,
pub amount: u64,
pub start_at: u64,
pub end_at: u64,
Expand Down Expand Up @@ -57,7 +57,7 @@ pub mod fuzz_example3_fuzz_instructions {
_fuzz_accounts: &mut FuzzAccounts,
) -> Result<Self::IxData, FuzzingError> {
let data = fuzz_example3::instruction::InitVesting {
recipient: todo!(),
i_recipient: todo!(),
amount: todo!(),
start_at: todo!(),
end_at: todo!(),
Expand Down Expand Up @@ -123,6 +123,7 @@ pub mod fuzz_example3_fuzz_instructions {
escrow: AccountsStorage<todo!()>,
escrow_pda_authority: AccountsStorage<todo!()>,
escrow_token_account: AccountsStorage<todo!()>,
i_recipient: AccountsStorage<todo!()>,
mint: AccountsStorage<todo!()>,
recipient: AccountsStorage<todo!()>,
recipient_token_account: AccountsStorage<todo!()>,
Expand Down
2 changes: 2 additions & 0 deletions crates/client/tests/test_program/fuzz_example3/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[workspace]

[package]
name = "fuzz_example3"
version = "0.1.0"
Expand Down
4 changes: 2 additions & 2 deletions crates/client/tests/test_program/fuzz_example3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ pub mod fuzz_example3 {

pub fn init_vesting(
ctx: Context<InitVesting>,
recipient: Pubkey,
i_recipient: Pubkey,
amount: u64,
start_at: u64,
end_at: u64,
interval: u64,
) -> Result<()> {
_init_vesting(ctx, recipient, amount, start_at, end_at, interval)
_init_vesting(ctx, i_recipient, amount, start_at, end_at, interval)
}

pub fn withdraw_unlocked(ctx: Context<WithdrawUnlocked>) -> Result<()> {
Expand Down

0 comments on commit 608c93d

Please sign in to comment.