Skip to content

Commit

Permalink
Fix NFT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Jan 12, 2024
1 parent b38e29d commit 172821a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
13 changes: 11 additions & 2 deletions sdk/src/types/block/rand/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,22 @@ use crate::types::block::{
rand_state_controller_address_unlock_condition_different_from,
},
},
transaction::rand_transaction_id,
transaction::rand_transaction_id_with_slot_index,
},
slot::SlotIndex,
};

/// Generates a random output id with a given slot index.
pub fn rand_output_id_with_slot_index(slot_index: impl Into<SlotIndex>) -> OutputId {
OutputId::new(
rand_transaction_id_with_slot_index(slot_index),
rand_number_range(OUTPUT_INDEX_RANGE),
)
}

/// Generates a random [`OutputId`].
pub fn rand_output_id() -> OutputId {
OutputId::new(rand_transaction_id(), rand_number_range(OUTPUT_INDEX_RANGE))
rand_output_id_with_slot_index(rand_number::<u32>())
}

/// Generates a random [`BasicOutput`].
Expand Down
18 changes: 9 additions & 9 deletions sdk/tests/client/input_selection/nft_outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use iota_sdk::{
address::Address,
output::{feature::MetadataFeature, unlock_condition::AddressUnlockCondition, NftId, NftOutputBuilder, Output},
protocol::protocol_parameters,
rand::output::rand_output_metadata,
rand::output::{rand_output_id_with_slot_index, rand_output_metadata_with_id},
},
};
use pretty_assertions::{assert_eq, assert_ne};
Expand Down Expand Up @@ -453,7 +453,7 @@ fn nft_in_output_and_sender() {
None,
),
],
None,
Some(SLOT_INDEX),
);
let outputs = build_outputs([
Nft(
Expand Down Expand Up @@ -915,7 +915,7 @@ fn increase_nft_amount() {
None,
),
],
None,
Some(SLOT_INDEX),
);
let outputs = build_outputs([Nft(
3_000_000,
Expand Down Expand Up @@ -970,7 +970,7 @@ fn decrease_nft_amount() {
None,
),
],
None,
Some(SLOT_INDEX),
);
let outputs = build_outputs([Nft(
1_000_000,
Expand Down Expand Up @@ -1037,7 +1037,7 @@ fn prefer_basic_to_nft() {
None,
),
],
None,
Some(SLOT_INDEX),
);
let outputs = build_outputs([Basic(
1_000_000,
Expand Down Expand Up @@ -1093,7 +1093,7 @@ fn take_amount_from_nft_to_fund_basic() {
None,
),
],
None,
Some(SLOT_INDEX),
);
let outputs = build_outputs([Basic(
1_200_000,
Expand Down Expand Up @@ -1161,7 +1161,7 @@ fn nft_burn_should_validate_nft_sender() {
None,
),
],
None,
Some(SLOT_INDEX),
);
let outputs = build_outputs([Basic(
3_000_000,
Expand Down Expand Up @@ -1217,7 +1217,7 @@ fn nft_burn_should_validate_nft_address() {
None,
),
],
None,
Some(SLOT_INDEX),
);
let outputs = build_outputs([Basic(
3_000_000,
Expand Down Expand Up @@ -1328,7 +1328,7 @@ fn changed_immutable_metadata() {

let inputs = [InputSigningData {
output: nft_output.clone(),
output_metadata: rand_output_metadata(),
output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)),
chain: None,
}];

Expand Down

0 comments on commit 172821a

Please sign in to comment.