Skip to content

Commit

Permalink
fix tests && satisfy fmt + clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
kstepanovdev committed Jan 16, 2025
1 parent 4b1d31d commit 24edbb4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
6 changes: 5 additions & 1 deletion postgre-client/tests/asset_filter_client_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,11 @@ mod tests {
None,
None,
None,
&GetByMethodsOptions { show_zero_balance: true, ..Default::default() },
&GetByMethodsOptions {
show_zero_balance: true,
show_unverified_collections: true,
..Default::default()
},
)
.await
.unwrap();
Expand Down
7 changes: 4 additions & 3 deletions postgre-client/tests/asset_index_client_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod tests {
use postgre_client::storage_traits::AssetIndexStorage;
use rand::Rng;
use setup::pg::*;
use solana_sdk::pubkey::Pubkey;
use testcontainers::clients::Cli;

#[tokio::test]
Expand Down Expand Up @@ -86,12 +87,12 @@ mod tests {
// every asset_index will have 3 creators
for asset_index in asset_indexes.iter_mut() {
asset_index.creators.push(Creator {
creator: generate_random_pubkey(),
creator: Pubkey::new_unique(),
creator_verified: rand::thread_rng().gen_bool(0.5),
creator_share: 30,
});
asset_index.creators.push(Creator {
creator: generate_random_pubkey(),
creator: Pubkey::new_unique(),
creator_verified: rand::thread_rng().gen_bool(0.5),
creator_share: 30,
});
Expand Down Expand Up @@ -119,7 +120,7 @@ mod tests {
.map(|asset_index| {
let mut ai = asset_index.clone();
ai.creators.pop();
ai.creators[1].creator = generate_random_pubkey();
ai.creators[1].creator = Pubkey::new_unique();
ai.creators[0].creator_verified = !ai.creators[0].creator_verified;
ai
})
Expand Down
20 changes: 8 additions & 12 deletions tests/setup/src/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,20 @@ pub fn generate_random_vec(n: usize) -> Vec<u8> {
random_vector
}

pub fn generate_random_pubkey() -> Pubkey {
Pubkey::new_unique()
}

pub fn generate_asset_index_records(n: usize) -> Vec<AssetIndex> {
let mut asset_indexes = Vec::new();
for i in 0..n {
let asset_index = AssetIndex {
pubkey: generate_random_pubkey(),
pubkey: Pubkey::new_unique(),
specification_version: SpecificationVersions::V1,
specification_asset_class: SpecificationAssetClass::Nft,
royalty_target_type: RoyaltyTargetType::Creators,
royalty_amount: 1,
slot_created: (n - i) as i64,
owner: Some(generate_random_pubkey()),
delegate: Some(generate_random_pubkey()),
authority: Some(generate_random_pubkey()),
collection: Some(generate_random_pubkey()),
owner: Some(Pubkey::new_unique()),
delegate: Some(Pubkey::new_unique()),
authority: Some(Pubkey::new_unique()),
collection: Some(Pubkey::new_unique()),
is_collection_verified: Some(rand::thread_rng().gen_bool(0.5)),
is_burnt: false,
is_compressible: false,
Expand All @@ -218,7 +214,7 @@ pub fn generate_asset_index_records(n: usize) -> Vec<AssetIndex> {
update_authority: None,
slot_updated: (n + 10 + i) as i64,
creators: vec![Creator {
creator: generate_random_pubkey(),
creator: Pubkey::new_unique(),
creator_verified: rand::thread_rng().gen_bool(0.5),
creator_share: 100,
}],
Expand All @@ -235,8 +231,8 @@ pub fn generate_fungible_asset_index_records(n: usize) -> Vec<FungibleAssetIndex
let mut asset_indexes = Vec::new();
for i in 0..n {
let asset_index = FungibleAssetIndex {
pubkey: generate_random_pubkey(),
owner: Some(generate_random_pubkey()),
pubkey: Pubkey::new_unique(),
owner: Some(Pubkey::new_unique()),
slot_updated: (n + 10 + i) as i64,
fungible_asset_mint: None,
fungible_asset_balance: Some(1),
Expand Down

0 comments on commit 24edbb4

Please sign in to comment.