Skip to content

Commit

Permalink
✅ Regenerate examples structure based on the new trdelnik-tests struc…
Browse files Browse the repository at this point in the history
…ture
  • Loading branch information
lukacan committed Dec 28, 2023
1 parent edfaf41 commit 1e73868
Show file tree
Hide file tree
Showing 23 changed files with 346 additions and 174 deletions.
1 change: 1 addition & 0 deletions examples/escrow/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ target
**/*.rs.bk
node_modules
test-ledger
hfuzz_target
94 changes: 47 additions & 47 deletions examples/escrow/.program_client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// DO NOT EDIT - automatically generated file
// DO NOT EDIT - automatically generated file (except `use` statements inside the `*_instruction` module
pub mod escrow_instruction {
use trdelnik_client::*;
pub static PROGRAM_ID: Pubkey = Pubkey::new_from_array([
Expand All @@ -10,15 +10,15 @@ pub mod escrow_instruction {
client: &Client,
i_initializer_amount: u64,
i_taker_amount: u64,
a_initializer: anchor_lang::solana_program::pubkey::Pubkey,
a_initializer_deposit_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_initializer_receive_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_escrow_account: anchor_lang::solana_program::pubkey::Pubkey,
a_system_program: anchor_lang::solana_program::pubkey::Pubkey,
a_token_program: anchor_lang::solana_program::pubkey::Pubkey,
a_initializer: Pubkey,
a_initializer_deposit_token_account: Pubkey,
a_initializer_receive_token_account: Pubkey,
a_escrow_account: Pubkey,
a_system_program: Pubkey,
a_token_program: Pubkey,
signers: impl IntoIterator<Item = Keypair> + Send + 'static,
) -> Result<EncodedConfirmedTransactionWithStatusMeta, ClientError> {
Ok(client
client
.send_instruction(
PROGRAM_ID,
escrow::instruction::InitializeEscrow {
Expand All @@ -35,17 +35,17 @@ pub mod escrow_instruction {
},
signers,
)
.await?)
.await
}
pub fn initialize_escrow_ix(
i_initializer_amount: u64,
i_taker_amount: u64,
a_initializer: anchor_lang::solana_program::pubkey::Pubkey,
a_initializer_deposit_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_initializer_receive_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_escrow_account: anchor_lang::solana_program::pubkey::Pubkey,
a_system_program: anchor_lang::solana_program::pubkey::Pubkey,
a_token_program: anchor_lang::solana_program::pubkey::Pubkey,
a_initializer: Pubkey,
a_initializer_deposit_token_account: Pubkey,
a_initializer_receive_token_account: Pubkey,
a_escrow_account: Pubkey,
a_system_program: Pubkey,
a_token_program: Pubkey,
) -> Instruction {
Instruction {
program_id: PROGRAM_ID,
Expand All @@ -67,14 +67,14 @@ pub mod escrow_instruction {
}
pub async fn cancel_escrow(
client: &Client,
a_initializer: anchor_lang::solana_program::pubkey::Pubkey,
a_pda_deposit_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_pda_account: anchor_lang::solana_program::pubkey::Pubkey,
a_escrow_account: anchor_lang::solana_program::pubkey::Pubkey,
a_token_program: anchor_lang::solana_program::pubkey::Pubkey,
a_initializer: Pubkey,
a_pda_deposit_token_account: Pubkey,
a_pda_account: Pubkey,
a_escrow_account: Pubkey,
a_token_program: Pubkey,
signers: impl IntoIterator<Item = Keypair> + Send + 'static,
) -> Result<EncodedConfirmedTransactionWithStatusMeta, ClientError> {
Ok(client
client
.send_instruction(
PROGRAM_ID,
escrow::instruction::CancelEscrow {},
Expand All @@ -87,14 +87,14 @@ pub mod escrow_instruction {
},
signers,
)
.await?)
.await
}
pub fn cancel_escrow_ix(
a_initializer: anchor_lang::solana_program::pubkey::Pubkey,
a_pda_deposit_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_pda_account: anchor_lang::solana_program::pubkey::Pubkey,
a_escrow_account: anchor_lang::solana_program::pubkey::Pubkey,
a_token_program: anchor_lang::solana_program::pubkey::Pubkey,
a_initializer: Pubkey,
a_pda_deposit_token_account: Pubkey,
a_pda_account: Pubkey,
a_escrow_account: Pubkey,
a_token_program: Pubkey,
) -> Instruction {
Instruction {
program_id: PROGRAM_ID,
Expand All @@ -111,18 +111,18 @@ pub mod escrow_instruction {
}
pub async fn exchange(
client: &Client,
a_taker: anchor_lang::solana_program::pubkey::Pubkey,
a_taker_deposit_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_taker_receive_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_pda_deposit_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_initializer_receive_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_initializer_main_account: anchor_lang::solana_program::pubkey::Pubkey,
a_escrow_account: anchor_lang::solana_program::pubkey::Pubkey,
a_pda_account: anchor_lang::solana_program::pubkey::Pubkey,
a_token_program: anchor_lang::solana_program::pubkey::Pubkey,
a_taker: Pubkey,
a_taker_deposit_token_account: Pubkey,
a_taker_receive_token_account: Pubkey,
a_pda_deposit_token_account: Pubkey,
a_initializer_receive_token_account: Pubkey,
a_initializer_main_account: Pubkey,
a_escrow_account: Pubkey,
a_pda_account: Pubkey,
a_token_program: Pubkey,
signers: impl IntoIterator<Item = Keypair> + Send + 'static,
) -> Result<EncodedConfirmedTransactionWithStatusMeta, ClientError> {
Ok(client
client
.send_instruction(
PROGRAM_ID,
escrow::instruction::Exchange {},
Expand All @@ -139,18 +139,18 @@ pub mod escrow_instruction {
},
signers,
)
.await?)
.await
}
pub fn exchange_ix(
a_taker: anchor_lang::solana_program::pubkey::Pubkey,
a_taker_deposit_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_taker_receive_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_pda_deposit_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_initializer_receive_token_account: anchor_lang::solana_program::pubkey::Pubkey,
a_initializer_main_account: anchor_lang::solana_program::pubkey::Pubkey,
a_escrow_account: anchor_lang::solana_program::pubkey::Pubkey,
a_pda_account: anchor_lang::solana_program::pubkey::Pubkey,
a_token_program: anchor_lang::solana_program::pubkey::Pubkey,
a_taker: Pubkey,
a_taker_deposit_token_account: Pubkey,
a_taker_receive_token_account: Pubkey,
a_pda_deposit_token_account: Pubkey,
a_initializer_receive_token_account: Pubkey,
a_initializer_main_account: Pubkey,
a_escrow_account: Pubkey,
a_pda_account: Pubkey,
a_token_program: Pubkey,
) -> Instruction {
Instruction {
program_id: PROGRAM_ID,
Expand Down
2 changes: 1 addition & 1 deletion examples/escrow/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members = ["programs/*", "trdelnik-tests"]
members = ["programs/*", "trdelnik-tests/poc_tests"]
11 changes: 11 additions & 0 deletions examples/escrow/Trdelnik.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[test]
validator_startup_timeout = 15000


# set for default values
[fuzz]
timeout = 10
iterations = 0
keep_output = false
verbose = false
exit_upon_crash = false
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
[package]
name = "trdelnik-tests"
name = "poc_tests"
version = "0.1.0"
description = "Created with Trdelnik"
edition = "2021"

[dev-dependencies]
[dev-dependencies.trdelnik-client]
path = "../../../../crates/client"

[dev-dependencies.program_client]
path = "../../.program_client"

[dependencies]
assert_matches = "1.4.0"
fehler = "1.0.0"
rstest = "0.12.0"
anchor-spl = "0.28.0"

[dev-dependencies.trdelnik-client]
path = "../../../crates/client"

[dev-dependencies.program_client]
path = "../.program_client"

[dev-dependencies.escrow]
path = "../programs/escrow"
[dependencies.escrow]
path = "../../programs/escrow"
28 changes: 14 additions & 14 deletions examples/fuzzer/.program_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ pub mod fuzzer_instruction {
]);
pub async fn initialize(
client: &Client,
a_counter: anchor_lang::solana_program::pubkey::Pubkey,
a_user: anchor_lang::solana_program::pubkey::Pubkey,
a_system_program: anchor_lang::solana_program::pubkey::Pubkey,
a_counter: Pubkey,
a_user: Pubkey,
a_system_program: Pubkey,
signers: impl IntoIterator<Item = Keypair> + Send + 'static,
) -> Result<EncodedConfirmedTransactionWithStatusMeta, ClientError> {
Ok(client
client
.send_instruction(
PROGRAM_ID,
fuzzer::instruction::Initialize {},
Expand All @@ -24,12 +24,12 @@ pub mod fuzzer_instruction {
},
signers,
)
.await?)
.await
}
pub fn initialize_ix(
a_counter: anchor_lang::solana_program::pubkey::Pubkey,
a_user: anchor_lang::solana_program::pubkey::Pubkey,
a_system_program: anchor_lang::solana_program::pubkey::Pubkey,
a_counter: Pubkey,
a_user: Pubkey,
a_system_program: Pubkey,
) -> Instruction {
Instruction {
program_id: PROGRAM_ID,
Expand All @@ -46,11 +46,11 @@ pub mod fuzzer_instruction {
client: &Client,
i_input1: u8,
i_input2: u8,
a_counter: anchor_lang::solana_program::pubkey::Pubkey,
a_authority: anchor_lang::solana_program::pubkey::Pubkey,
a_counter: Pubkey,
a_authority: Pubkey,
signers: impl IntoIterator<Item = Keypair> + Send + 'static,
) -> Result<EncodedConfirmedTransactionWithStatusMeta, ClientError> {
Ok(client
client
.send_instruction(
PROGRAM_ID,
fuzzer::instruction::Update {
Expand All @@ -63,13 +63,13 @@ pub mod fuzzer_instruction {
},
signers,
)
.await?)
.await
}
pub fn update_ix(
i_input1: u8,
i_input2: u8,
a_counter: anchor_lang::solana_program::pubkey::Pubkey,
a_authority: anchor_lang::solana_program::pubkey::Pubkey,
a_counter: Pubkey,
a_authority: Pubkey,
) -> Instruction {
Instruction {
program_id: PROGRAM_ID,
Expand Down
7 changes: 6 additions & 1 deletion examples/fuzzer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[workspace]
members = ["programs/*", "trdelnik-tests"]
members = [
"programs/*",
"trdelnik-tests/fuzz_tests/fuzz_0",
"trdelnik-tests/fuzz_tests/fuzz_1",
"trdelnik-tests/fuzz_tests/fuzz_2",
]
[profile.release]
overflow-checks = true
lto = "fat"
Expand Down
8 changes: 5 additions & 3 deletions examples/fuzzer/Trdelnik.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[test]
validator_startup_timeout = 15000


# set for default values
[fuzz]
iterations = 500
timeout = 25
timeout = 10
iterations = 1000
keep_output = false
verbose = false
exit_upon_crash = true
exit_upon_crash = false
22 changes: 0 additions & 22 deletions examples/fuzzer/trdelnik-tests/Cargo.toml

This file was deleted.

23 changes: 23 additions & 0 deletions examples/fuzzer/trdelnik-tests/fuzz_tests/fuzz_0/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[[bin]]
name = "fuzz_0"
path = "test_fuzz.rs"

[package]
name = "fuzz_0"
version = "0.1.0"
edition = "2018"

[dependencies]
honggfuzz = "0.5.55"
arbitrary = "1.3.0"
assert_matches = "1.4.0"

[dependencies.trdelnik-client]
path = "../../../../../crates/client"
features = ["fuzzing"]

[dependencies.program_client]
path = "../../../.program_client"

[dependencies.fuzzer]
path = "../../../programs/fuzzer"
23 changes: 23 additions & 0 deletions examples/fuzzer/trdelnik-tests/fuzz_tests/fuzz_1/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[[bin]]
name = "fuzz_1"
path = "test_fuzz.rs"

[package]
name = "fuzz_1"
version = "0.1.0"
edition = "2018"

[dependencies]
honggfuzz = "0.5.55"
arbitrary = "1.3.0"
assert_matches = "1.4.0"

[dependencies.trdelnik-client]
path = "../../../../../crates/client"
features = ["fuzzing"]

[dependencies.program_client]
path = "../../../.program_client"

[dependencies.fuzzer]
path = "../../../programs/fuzzer"
Loading

0 comments on commit 1e73868

Please sign in to comment.