Skip to content

Commit

Permalink
fixing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
qrayven committed Aug 3, 2023
1 parent bae2972 commit 0d8df8a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 4 additions & 3 deletions sdk/src/types/block/output/feature/block_issuer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl BlockIssuerFeature {
}

mod dto {
use alloc::vec::Vec;
use serde::{Deserialize, Serialize};

use super::BlockIssuerFeature;
Expand All @@ -71,8 +72,8 @@ mod dto {
kind: u8,
#[serde(with = "string")]
expiry_slot: u64,
#[serde(skip_serializing_if = "alloc::vec::Vec::is_empty", default)]
keys: alloc::vec::Vec<PublicKeyDto>,
#[serde(skip_serializing_if = "Vec::is_empty", default)]
keys: Vec<PublicKeyDto>,
}

impl From<&BlockIssuerFeature> for BlockIssuerFeatureDto {
Expand All @@ -93,7 +94,7 @@ mod dto {
.keys
.into_iter()
.map(PublicKey::try_from)
.collect::<Result<alloc::vec::Vec<PublicKey>, Error>>()?;
.collect::<Result<Vec<PublicKey>, Error>>()?;

Self::new(value.expiry_slot, keys)
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/types/block/rand/output/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::types::block::{
address::rand_address,
bytes::rand_bytes,
number::{rand_number, rand_number_range},
public_key::rand_public_key,
public_key::{rand_public_key, rand_public_keys},

Check failure on line 15 in sdk/src/types/block/rand/output/feature.rs

View workflow job for this annotation

GitHub Actions / crate (ubuntu-latest)

unused import: `rand_public_key`

Check failure on line 15 in sdk/src/types/block/rand/output/feature.rs

View workflow job for this annotation

GitHub Actions / crate (windows-latest)

unused import: `rand_public_key`

Check failure on line 15 in sdk/src/types/block/rand/output/feature.rs

View workflow job for this annotation

GitHub Actions / Check Unused Dependencies

unused import: `rand_public_key`
},
};

Expand Down Expand Up @@ -40,7 +40,7 @@ pub fn rand_tag_feature() -> TagFeature {

/// Generates a random [`BlockIssuerFeature`].
pub fn rand_block_issuer_feature() -> BlockIssuerFeature {
BlockIssuerFeature::new(rand_number::<u64>(), vec![rand_public_key()]).unwrap()
BlockIssuerFeature::new(rand_number::<u64>(), rand_public_keys(1)).unwrap()
}

/// Generates a random [`StakingFeature`].
Expand Down
7 changes: 7 additions & 0 deletions sdk/src/types/block/rand/public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ pub fn rand_ed25519_public_key() -> Ed25519PublicKey {
pub fn rand_public_key() -> PublicKey {
rand_ed25519_public_key().into()
}

/// Generates a vector of random valid public keys of a given length.
pub fn rand_public_keys(len: usize) -> Vec<PublicKey> {
let mut public_keys = (0..len).map(|_| rand_public_key()).collect::<Vec<_>>();
public_keys.sort_by(|a, b| a.cmp(b));
public_keys
}

0 comments on commit 0d8df8a

Please sign in to comment.