diff --git a/bindings/core/src/method/secret_manager.rs b/bindings/core/src/method/secret_manager.rs index a4298f2b1e..2a13acbca0 100644 --- a/bindings/core/src/method/secret_manager.rs +++ b/bindings/core/src/method/secret_manager.rs @@ -99,7 +99,7 @@ pub enum SecretManagerMethod { /// Expected response: [`Ok`](crate::Response::Ok) #[cfg(feature = "stronghold")] #[cfg_attr(docsrs, doc(cfg(feature = "stronghold")))] - ClearStrongholdPassword + ClearStrongholdPassword, } #[cfg(test)] diff --git a/sdk/src/types/block/error.rs b/sdk/src/types/block/error.rs index 6e293465ad..672be985dc 100644 --- a/sdk/src/types/block/error.rs +++ b/sdk/src/types/block/error.rs @@ -196,7 +196,7 @@ pub enum Error { DuplicateOutputChain(ChainId), InvalidField(&'static str), NullDelegationValidatorId, - InvalidEpochDelta { + InvalidEpochDiff { created: EpochIndex, target: EpochIndex, }, @@ -429,8 +429,8 @@ impl fmt::Display for Error { Self::DuplicateOutputChain(chain_id) => write!(f, "duplicate output chain {chain_id}"), Self::InvalidField(field) => write!(f, "invalid field: {field}"), Self::NullDelegationValidatorId => write!(f, "null delegation validator ID"), - Self::InvalidEpochDelta { created, target } => { - write!(f, "invalid epoch delta: created {created}, target {target}") + Self::InvalidEpochDiff { created, target } => { + write!(f, "invalid epoch diff: created {created}, target {target}") } Self::TrailingCapabilityBytes => write!(f, "capability bytes have trailing zeroes"), Self::RestrictedAddressCapability(cap) => write!(f, "restricted address capability: {cap:?}"), diff --git a/sdk/src/types/block/mana/parameters.rs b/sdk/src/types/block/mana/parameters.rs index e6d68aa698..127e0b2320 100644 --- a/sdk/src/types/block/mana/parameters.rs +++ b/sdk/src/types/block/mana/parameters.rs @@ -58,13 +58,13 @@ impl ManaParameters { (1 << self.bits_count) - 1 } - fn decay(&self, mut mana: u64, epoch_delta: u32) -> u64 { - if mana == 0 || epoch_delta == 0 || self.decay_factors().is_empty() { + fn decay(&self, mut mana: u64, epoch_diff: u32) -> u64 { + if mana == 0 || epoch_diff == 0 || self.decay_factors().is_empty() { return mana; } // we keep applying the lookup table factors as long as n epochs are left - let mut remaining_epochs = epoch_delta; + let mut remaining_epochs = epoch_diff; while remaining_epochs > 0 { let epochs_to_decay = remaining_epochs.min(self.decay_factors().len() as u32); @@ -80,13 +80,14 @@ impl ManaParameters { mana } - fn generate_mana(&self, amount: u64, slot_delta: u32) -> u64 { - if self.generation_rate() == 0 || slot_delta == 0 { + fn generate_mana(&self, amount: u64, slot_diff: u32) -> u64 { + if self.generation_rate() == 0 || slot_diff == 0 { return 0; } + fixed_point_multiply( amount, - slot_delta * self.generation_rate() as u32, + slot_diff * self.generation_rate() as u32, self.generation_rate_exponent(), ) } @@ -116,17 +117,18 @@ impl ProtocolParameters { slot_index_created: impl Into, slot_index_target: impl Into, ) -> Result { - let (slot_index_created, slot_index_target) = (slot_index_created.into(), slot_index_target.into()); let (epoch_index_created, epoch_index_target) = ( self.epoch_index_of(slot_index_created), self.epoch_index_of(slot_index_target), ); + if epoch_index_created > epoch_index_target { - return Err(Error::InvalidEpochDelta { + return Err(Error::InvalidEpochDiff { created: epoch_index_created, target: epoch_index_target, }); } + Ok(self .mana_parameters() .decay(mana, epoch_index_target.0 - epoch_index_created.0)) @@ -140,12 +142,14 @@ impl ProtocolParameters { claimed_epoch: impl Into, ) -> Result { let (reward_epoch, claimed_epoch) = (reward_epoch.into(), claimed_epoch.into()); + if reward_epoch > claimed_epoch { - return Err(Error::InvalidEpochDelta { + return Err(Error::InvalidEpochDiff { created: reward_epoch, target: claimed_epoch, }); } + Ok(self.mana_parameters().decay(reward, claimed_epoch.0 - reward_epoch.0)) } @@ -162,8 +166,9 @@ impl ProtocolParameters { self.epoch_index_of(slot_index_created), self.epoch_index_of(slot_index_target), ); + if epoch_index_created > epoch_index_target { - return Err(Error::InvalidEpochDelta { + return Err(Error::InvalidEpochDiff { created: epoch_index_created, target: epoch_index_target, }); @@ -171,6 +176,7 @@ impl ProtocolParameters { if slot_index_created >= slot_index_target { return Ok(0); } + let mana_parameters = self.mana_parameters(); Ok(if epoch_index_created == epoch_index_target { @@ -189,14 +195,14 @@ impl ProtocolParameters { mana_parameters.decay_factor_epochs_sum_exponent() + mana_parameters.generation_rate_exponent() - self.slots_per_epoch_exponent(), ); - let epoch_delta = epoch_index_target.0 - epoch_index_created.0; + let epoch_diff = epoch_index_target.0 - epoch_index_created.0; let slots_before_next_epoch = self.first_slot_of(epoch_index_created + 1) - slot_index_created; let slots_since_epoch_start = slot_index_target - self.first_slot_of(epoch_index_target); let potential_mana_n = mana_parameters.decay( mana_parameters.generate_mana(amount, slots_before_next_epoch.0), - epoch_delta, + epoch_diff, ); - let potential_mana_n_1 = mana_parameters.decay(c, epoch_delta - 1); + let potential_mana_n_1 = mana_parameters.decay(c, epoch_diff - 1); let potential_mana_0 = c + mana_parameters.generate_mana(amount, slots_since_epoch_start.0) - (c >> mana_parameters.decay_factors_exponent()); potential_mana_0 - potential_mana_n_1 + potential_mana_n @@ -290,7 +296,7 @@ mod test { fn mana_decay_negative_delta() { assert_eq!( params().mana_with_decay(100, params().first_slot_of(2), params().first_slot_of(1)), - Err(Error::InvalidEpochDelta { + Err(Error::InvalidEpochDiff { created: 2.into(), target: 1.into() }) @@ -349,7 +355,7 @@ mod test { fn potential_mana_negative_delta() { assert_eq!( params().potential_mana(100, params().first_slot_of(2), params().first_slot_of(1)), - Err(Error::InvalidEpochDelta { + Err(Error::InvalidEpochDiff { created: 2.into(), target: 1.into() }) diff --git a/sdk/src/types/block/rand/transaction.rs b/sdk/src/types/block/rand/transaction.rs index 20036d143b..5a12cdcac1 100644 --- a/sdk/src/types/block/rand/transaction.rs +++ b/sdk/src/types/block/rand/transaction.rs @@ -1,9 +1,18 @@ // Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use crate::types::block::{payload::signed_transaction::TransactionId, rand::bytes::rand_bytes_array}; +use crate::types::block::{ + payload::signed_transaction::{TransactionHash, TransactionId}, + rand::{bytes::rand_bytes_array, number::rand_number}, + slot::SlotIndex, +}; + +/// Generates a random transaction id with a given slot index. +pub fn rand_transaction_id_with_slot_index(slot_index: impl Into) -> TransactionId { + TransactionHash::new(rand_bytes_array()).into_transaction_id(slot_index.into()) +} /// Generates a random transaction id. pub fn rand_transaction_id() -> TransactionId { - TransactionId::new(rand_bytes_array()) + rand_transaction_id_with_slot_index(rand_number::()) } diff --git a/sdk/src/types/block/semantic/mod.rs b/sdk/src/types/block/semantic/mod.rs index 109915b869..e9bf091ef3 100644 --- a/sdk/src/types/block/semantic/mod.rs +++ b/sdk/src/types/block/semantic/mod.rs @@ -16,7 +16,9 @@ pub use self::{ }; use crate::types::block::{ address::Address, - output::{AccountId, AnchorOutput, ChainId, FoundryId, NativeTokens, Output, OutputId, TokenId}, + output::{ + AccountId, AnchorOutput, ChainId, FoundryId, MinimumOutputAmount, NativeTokens, Output, OutputId, TokenId, + }, payload::signed_transaction::{Transaction, TransactionCapabilityFlag, TransactionSigningHash}, protocol::ProtocolParameters, unlock::Unlock, @@ -160,7 +162,37 @@ impl<'a> SemanticValidationContext<'a> { .checked_add(amount) .ok_or(Error::ConsumedAmountOverflow)?; - self.input_mana = self.input_mana.checked_add(mana).ok_or(Error::ConsumedManaOverflow)?; + let potential_mana = { + // Deposit amount doesn't generate mana + let min_deposit = consumed_output.minimum_amount(self.protocol_parameters.storage_score_parameters()); + let generation_amount = consumed_output.amount().saturating_sub(min_deposit); + + self.protocol_parameters.potential_mana( + generation_amount, + output_id.transaction_id().slot_index(), + self.transaction.creation_slot(), + ) + }?; + + // Add potential mana + self.input_mana = self + .input_mana + .checked_add(potential_mana) + .ok_or(Error::ConsumedManaOverflow)?; + + let stored_mana = self.protocol_parameters.mana_with_decay( + mana, + output_id.transaction_id().slot_index(), + self.transaction.creation_slot(), + )?; + + // Add stored mana + self.input_mana = self + .input_mana + .checked_add(stored_mana) + .ok_or(Error::ConsumedManaOverflow)?; + + // TODO: Add reward mana https://github.com/iotaledger/iota-sdk/issues/1310 if let Some(consumed_native_token) = consumed_native_token { let native_token_amount = self @@ -221,8 +253,17 @@ impl<'a> SemanticValidationContext<'a> { .checked_add(amount) .ok_or(Error::CreatedAmountOverflow)?; + // Add stored mana self.output_mana = self.output_mana.checked_add(mana).ok_or(Error::CreatedManaOverflow)?; + // Add allotted mana + for mana_allotment in self.transaction.allotments() { + self.output_mana = self + .output_mana + .checked_add(mana_allotment.mana()) + .ok_or(Error::CreatedManaOverflow)?; + } + if let Some(created_native_token) = created_native_token { let native_token_amount = self .output_native_tokens @@ -251,11 +292,17 @@ impl<'a> SemanticValidationContext<'a> { return Ok(Some(TransactionFailureReason::SumInputsOutputsAmountMismatch)); } - // TODO re-enable with https://github.com/iotaledger/iota-sdk/issues/1692 - // if self.input_mana > self.output_mana && - // !self.transaction.has_capability(TransactionCapabilityFlag::BurnMana) { // TODO: add a variant https://github.com/iotaledger/iota-sdk/issues/1430 - // return Ok(Some(TransactionFailureReason::SemanticValidationFailed)); - // } + if self.input_mana != self.output_mana { + if self.input_mana > self.output_mana { + if !self.transaction.has_capability(TransactionCapabilityFlag::BurnMana) { + return Ok(Some( + TransactionFailureReason::TransactionCapabilityManaBurningNotAllowed, + )); + } + } else { + return Ok(Some(TransactionFailureReason::InvalidManaAmount)); + } + } // Validation of input native tokens. let mut native_token_ids = self.input_native_tokens.keys().collect::>(); diff --git a/sdk/tests/client/input_selection/account_outputs.rs b/sdk/tests/client/input_selection/account_outputs.rs index a350d1a584..ade83ef47a 100644 --- a/sdk/tests/client/input_selection/account_outputs.rs +++ b/sdk/tests/client/input_selection/account_outputs.rs @@ -25,14 +25,17 @@ fn input_account_eq_output_account() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + let inputs = build_inputs( + [Account( + 1_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_2, @@ -60,14 +63,17 @@ fn transition_account_id_zero() { let protocol_parameters = protocol_parameters(); let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); - let inputs = build_inputs([Account( - 1_000_000, - account_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + let inputs = build_inputs( + [Account( + 1_000_000, + account_id_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + )], None, - )]); + ); let account_id = AccountId::from(inputs[0].output_id()); let outputs = build_outputs([Account( 1_000_000, @@ -230,16 +236,19 @@ fn create_account() { let protocol_parameters = protocol_parameters(); let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_0, @@ -276,14 +285,17 @@ fn burn_account() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([Account( - 2_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + let inputs = build_inputs( + [Account( + 2_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -359,16 +371,19 @@ fn missing_input_for_account_output() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_2, @@ -398,26 +413,29 @@ fn missing_input_for_account_output_2() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Account( 1_000_000, account_id_2, @@ -446,16 +464,19 @@ fn missing_input_for_account_output_but_created() { let protocol_parameters = protocol_parameters(); let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_0, @@ -481,26 +502,29 @@ fn account_in_output_and_sender() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([ - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let account_output = AccountOutputBuilder::from(inputs[0].output.as_account()) .finish_output() .unwrap(); @@ -534,14 +558,17 @@ fn missing_ed25519_sender() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + let inputs = build_inputs( + [Account( + 1_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_2, @@ -570,16 +597,19 @@ fn missing_ed25519_issuer_created() { let protocol_parameters = protocol_parameters(); let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_0, @@ -608,14 +638,17 @@ fn missing_ed25519_issuer_transition() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + let inputs = build_inputs( + [Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_1, @@ -641,14 +674,17 @@ fn missing_account_sender() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + let inputs = build_inputs( + [Account( + 1_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_2, @@ -677,16 +713,19 @@ fn missing_account_issuer_created() { let protocol_parameters = protocol_parameters(); let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_0, @@ -715,14 +754,17 @@ fn missing_account_issuer_transition() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + let inputs = build_inputs( + [Account( + 1_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_2, @@ -748,14 +790,17 @@ fn missing_nft_sender() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + let inputs = build_inputs( + [Account( + 1_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_2, @@ -784,16 +829,19 @@ fn missing_nft_issuer_created() { let protocol_parameters = protocol_parameters(); let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_0, @@ -822,14 +870,17 @@ fn missing_nft_issuer_transition() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + let inputs = build_inputs( + [Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_1, @@ -855,26 +906,29 @@ fn increase_account_amount() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Account( 3_000_000, account_id_1, @@ -902,26 +956,29 @@ fn decrease_account_amount() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Account( 1_000_000, account_id_1, @@ -961,26 +1018,29 @@ fn prefer_basic_to_account() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([ - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1011,26 +1071,29 @@ fn take_amount_from_account_to_fund_basic() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_200_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1075,26 +1138,29 @@ fn account_burn_should_validate_account_sender() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1137,26 +1203,29 @@ fn account_burn_should_validate_account_address() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1199,14 +1268,17 @@ fn transitioned_zero_account_id_no_longer_is_zero() { let protocol_parameters = protocol_parameters(); let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); - let inputs = build_inputs([Account( - 2_000_000, - account_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + let inputs = build_inputs( + [Account( + 2_000_000, + account_id_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1252,24 +1324,27 @@ fn two_accounts_required() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Account( - 2_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Account( + 2_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 3_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1320,14 +1395,17 @@ fn state_controller_sender_required() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + let inputs = build_inputs( + [Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1358,14 +1436,17 @@ fn state_controller_sender_required_already_selected() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + let inputs = build_inputs( + [Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([ Account( 1_000_000, @@ -1406,14 +1487,17 @@ fn state_transition_and_required() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + let inputs = build_inputs( + [Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 2_000_000, account_id_1, @@ -1442,14 +1526,17 @@ fn remainder_address_in_state_controller() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + let inputs = build_inputs( + [Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Account( 1_000_000, account_id_1, diff --git a/sdk/tests/client/input_selection/basic_outputs.rs b/sdk/tests/client/input_selection/basic_outputs.rs index 7b190eeb3c..f20d862c8b 100644 --- a/sdk/tests/client/input_selection/basic_outputs.rs +++ b/sdk/tests/client/input_selection/basic_outputs.rs @@ -6,10 +6,7 @@ use std::str::FromStr; use iota_sdk::{ client::api::input_selection::{Error, InputSelection, Requirement}, types::block::{ - address::{ - Address, AddressCapabilities, ImplicitAccountCreationAddress, MultiAddress, RestrictedAddress, - WeightedAddress, - }, + address::{Address, AddressCapabilities, MultiAddress, RestrictedAddress, WeightedAddress}, output::{AccountId, NftId}, protocol::protocol_parameters, }, @@ -27,16 +24,19 @@ use crate::client::{ fn input_amount_equal_output_amount() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -65,16 +65,19 @@ fn input_amount_equal_output_amount() { fn input_amount_lower_than_output_amount() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -107,28 +110,31 @@ fn input_amount_lower_than_output_amount() { fn input_amount_lower_than_output_amount_2() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 3_500_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -161,16 +167,19 @@ fn input_amount_lower_than_output_amount_2() { fn input_amount_greater_than_output_amount() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 500_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -212,16 +221,19 @@ fn input_amount_greater_than_output_amount_with_remainder_address() { let protocol_parameters = protocol_parameters(); let remainder_address = Address::try_from_bech32(BECH32_ADDRESS_REMAINDER).unwrap(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 500_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -263,28 +275,31 @@ fn input_amount_greater_than_output_amount_with_remainder_address() { fn two_same_inputs_one_needed() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 500_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -326,28 +341,31 @@ fn two_same_inputs_one_needed() { fn two_inputs_one_needed() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -376,28 +394,31 @@ fn two_inputs_one_needed() { fn two_inputs_one_needed_reversed() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -426,28 +447,31 @@ fn two_inputs_one_needed_reversed() { fn two_inputs_both_needed() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 3_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -476,28 +500,31 @@ fn two_inputs_both_needed() { fn two_inputs_remainder() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_500_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -581,58 +608,61 @@ fn ed25519_sender() { let protocol_parameters = protocol_parameters(); let sender = Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -672,16 +702,19 @@ fn ed25519_sender() { fn missing_ed25519_sender() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 5_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 5_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -712,57 +745,59 @@ fn account_sender() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); - + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -801,26 +836,29 @@ fn account_sender_zero_id() { let protocol_parameters = protocol_parameters(); let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Account( - 1_000_000, - account_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + ], + None, + ); let account_id = AccountId::from(inputs[1].output_id()); let outputs = build_outputs([Basic( 2_000_000, @@ -856,16 +894,19 @@ fn account_sender_zero_id() { fn missing_account_sender() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 5_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 5_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -896,58 +937,61 @@ fn nft_sender() { let protocol_parameters = protocol_parameters(); let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Nft( + 1_000_000, + nft_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -987,28 +1031,31 @@ fn nft_sender_zero_id() { let protocol_parameters = protocol_parameters(); let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Nft( - 1_000_000, - nft_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Nft( + 1_000_000, + nft_id_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + ], + None, + ); let nft_id = NftId::from(inputs[1].output_id()); let outputs = build_outputs([Basic( 2_000_000, @@ -1044,16 +1091,19 @@ fn nft_sender_zero_id() { fn missing_nft_sender() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 5_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 5_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1083,16 +1133,19 @@ fn missing_nft_sender() { fn simple_remainder() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 500_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1212,16 +1265,19 @@ fn simple_remainder() { fn one_provided_one_needed() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1250,16 +1306,19 @@ fn one_provided_one_needed() { fn insufficient_amount() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_250_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1292,28 +1351,31 @@ fn insufficient_amount() { fn two_inputs_remainder_2() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 500_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1354,28 +1416,31 @@ fn two_inputs_remainder_2() { fn two_inputs_remainder_3() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_750_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1455,16 +1520,19 @@ fn two_inputs_remainder_3() { fn sender_already_selected() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1497,16 +1565,19 @@ fn sender_already_selected() { fn single_mandatory_input() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1554,8 +1625,8 @@ fn too_many_inputs() { ) }) .take(129), + None, ); - let outputs = build_outputs([Basic( 129_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1600,18 +1671,22 @@ fn more_than_max_inputs_only_one_needed() { ) }) .take(1000), + None, ); // Add the needed input - let needed_input = build_inputs([Basic( - 129_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let needed_input = build_inputs( + [Basic( + 129_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); inputs.push(needed_input[0].clone()); let outputs = build_outputs([Basic( @@ -1642,17 +1717,19 @@ fn more_than_max_inputs_only_one_needed() { fn too_many_outputs() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 2_000_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); - + ); let outputs = build_outputs( std::iter::repeat_with(|| { Basic( @@ -1687,16 +1764,19 @@ fn too_many_outputs() { fn too_many_outputs_with_remainder() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 2_000_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs( std::iter::repeat_with(|| { @@ -1735,49 +1815,52 @@ fn restricted_ed25519() { let address = Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(); let restricted = Address::from(RestrictedAddress::new(address.clone()).unwrap()); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic(1_000_000, restricted, None, None, None, None, None, None), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic(1_000_000, restricted, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1810,19 +1893,22 @@ fn restricted_nft() { let nft_address = Address::from(nft_id_1); let restricted = Address::from(RestrictedAddress::new(nft_address.clone()).unwrap()); - let inputs = build_inputs([ - Basic(2_000_000, restricted, None, None, None, None, None, None), - Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic(2_000_000, restricted, None, None, None, None, None, None), + Nft( + 2_000_000, + nft_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 3_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1855,18 +1941,20 @@ fn restricted_account() { let account_address = Address::from(account_id_1); let restricted = Address::from(RestrictedAddress::new(account_address.clone()).unwrap()); - let inputs = build_inputs([ - Basic(3_000_000, restricted, None, None, None, None, None, None), - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - ]); - + let inputs = build_inputs( + [ + Basic(3_000_000, restricted, None, None, None, None, None, None), + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 3_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1898,58 +1986,61 @@ fn restricted_ed25519_sender() { let sender = Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(); let restricted_sender = Address::from(RestrictedAddress::new(sender.clone()).unwrap()); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -2003,38 +2094,41 @@ fn multi_address_sender_already_fulfilled() { .unwrap(), ); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 3_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -2074,19 +2168,22 @@ fn ed25519_backed_available_address() { .with_allowed_capabilities(AddressCapabilities::all()), ); - let inputs = build_inputs([ - Basic( - 1_000_000, - restricted_address.clone(), - None, - None, - None, - None, - None, - None, - ), - Basic(1_000_000, ed25519.clone(), None, None, None, None, None, None), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + restricted_address.clone(), + None, + None, + None, + None, + None, + None, + ), + Basic(1_000_000, ed25519.clone(), None, None, None, None, None, None), + ], + None, + ); let outputs = build_outputs([ Basic( 1_000_000, diff --git a/sdk/tests/client/input_selection/expiration.rs b/sdk/tests/client/input_selection/expiration.rs index 08852b876f..8dc60c5696 100644 --- a/sdk/tests/client/input_selection/expiration.rs +++ b/sdk/tests/client/input_selection/expiration.rs @@ -24,16 +24,19 @@ use crate::client::{ fn one_output_expiration_not_expired() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -61,16 +64,19 @@ fn one_output_expiration_not_expired() { fn expiration_equal_timestamp() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -100,16 +106,19 @@ fn expiration_equal_timestamp() { fn one_output_expiration_expired() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -139,28 +148,31 @@ fn one_output_expiration_expired() { fn two_outputs_one_expiration_expired() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), @@ -191,28 +203,31 @@ fn two_outputs_one_expiration_expired() { fn two_outputs_one_unexpired_one_missing() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), @@ -243,38 +258,41 @@ fn two_outputs_one_unexpired_one_missing() { fn two_outputs_two_expired() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 100)), - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 100)), - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 100)), + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 100)), + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), @@ -305,28 +323,31 @@ fn two_outputs_two_expired() { fn two_outputs_two_expired_2() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 100)), - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 100)), - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 100)), + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 100)), + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 4_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), @@ -359,16 +380,19 @@ fn two_outputs_two_expired_2() { fn expiration_expired_with_sdr() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), @@ -398,16 +422,19 @@ fn expiration_expired_with_sdr() { fn expiration_expired_with_sdr_2() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -437,16 +464,19 @@ fn expiration_expired_with_sdr_2() { fn expiration_expired_with_sdr_and_timelock() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 1_000_000)), - Some(50), - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 1_000_000)), + Some(50), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), @@ -476,16 +506,19 @@ fn expiration_expired_with_sdr_and_timelock() { fn expiration_expired_with_sdr_and_timelock_2() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - Some(50), - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + Some(50), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), @@ -515,58 +548,61 @@ fn expiration_expired_with_sdr_and_timelock_2() { fn sender_in_expiration() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -600,16 +636,19 @@ fn sender_in_expiration() { fn sender_in_expiration_already_selected() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -643,16 +682,19 @@ fn sender_in_expiration_already_selected() { fn remainder_in_expiration() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -696,16 +738,19 @@ fn remainder_in_expiration() { fn expiration_expired_non_ed25519_in_address_unlock_condition() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -736,26 +781,29 @@ fn expiration_expired_only_account_addresses() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), 50)), - None, - ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), 50)), + None, + ), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, @@ -787,16 +835,19 @@ fn one_nft_output_expiration_unexpired() { let protocol_parameters = protocol_parameters(); let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); - let inputs = build_inputs([Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 150)), + let inputs = build_inputs( + [Nft( + 2_000_000, + nft_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 150)), + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 2_000_000, nft_id_1, @@ -827,16 +878,19 @@ fn one_nft_output_expiration_expired() { let protocol_parameters = protocol_parameters(); let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); - let inputs = build_inputs([Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + let inputs = build_inputs( + [Nft( + 2_000_000, + nft_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 2_000_000, nft_id_1, diff --git a/sdk/tests/client/input_selection/foundry_outputs.rs b/sdk/tests/client/input_selection/foundry_outputs.rs index 52c510b70c..bf8fe83707 100644 --- a/sdk/tests/client/input_selection/foundry_outputs.rs +++ b/sdk/tests/client/input_selection/foundry_outputs.rs @@ -31,16 +31,19 @@ fn missing_input_account_for_foundry() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Foundry( 1_000_000, account_id_2, @@ -106,26 +109,29 @@ fn minted_native_tokens_in_new_remainder() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Foundry( 1_000_000, account_id_2, @@ -162,26 +168,29 @@ fn minted_native_tokens_in_provided_output() { let foundry_id = FoundryId::build(&AccountAddress::from(account_id_2), 1, SimpleTokenScheme::KIND); let token_id = TokenId::from(foundry_id); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([ Foundry( 1_000_000, @@ -223,28 +232,31 @@ fn melt_native_tokens() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let mut inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(10, 0, 10).unwrap(), - Some(( - "0x0811111111111111111111111111111111111111111111111111111111111111110100000000", - 10, - )), - ), - ]); + let mut inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Foundry( + 1_000_000, + account_id_1, + 1, + SimpleTokenScheme::new(10, 0, 10).unwrap(), + Some(( + "0x0811111111111111111111111111111111111111111111111111111111111111110100000000", + 10, + )), + ), + ], + None, + ); let account_output = AccountOutputBuilder::new_with_amount(1_000_000, account_id_1) .add_unlock_condition(AddressUnlockCondition::new( Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -292,23 +304,26 @@ fn destroy_foundry_with_account_state_transition() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([ - Account( - 50_300, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Foundry( - 52_800, - account_id_2, - 1, - SimpleTokenScheme::new(10, 10, 10).unwrap(), - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 50_300, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Foundry( + 52_800, + account_id_2, + 1, + SimpleTokenScheme::new(10, 10, 10).unwrap(), + None, + ), + ], + None, + ); let account_output = AccountOutputBuilder::from(inputs[0].output.as_account()) .with_amount(103_100) .finish_output() @@ -336,23 +351,26 @@ fn destroy_foundry_with_account_burn() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([ - Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Foundry( - 1_000_000, - account_id_2, - 1, - SimpleTokenScheme::new(10, 10, 10).unwrap(), - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 1_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Foundry( + 1_000_000, + account_id_2, + 1, + SimpleTokenScheme::new(10, 10, 10).unwrap(), + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -398,33 +416,36 @@ fn prefer_basic_to_foundry() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([ - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(10, 10, 10).unwrap(), - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Foundry( + 1_000_000, + account_id_1, + 1, + SimpleTokenScheme::new(10, 10, 10).unwrap(), + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -455,25 +476,28 @@ fn simple_foundry_transition_basic_not_needed() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let mut inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(10, 10, 10).unwrap(), - None, - ), - ]); + let mut inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Foundry( + 1_000_000, + account_id_1, + 1, + SimpleTokenScheme::new(10, 10, 10).unwrap(), + None, + ), + ], + None, + ); let account_output = AccountOutputBuilder::new_with_amount(2_000_000, account_id_1) .add_unlock_condition(AddressUnlockCondition::new( Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -530,25 +554,28 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let mut inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Foundry( - 2_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(10, 10, 10).unwrap(), - None, - ), - ]); + let mut inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Foundry( + 2_000_000, + account_id_1, + 1, + SimpleTokenScheme::new(10, 10, 10).unwrap(), + None, + ), + ], + None, + ); let account_output = AccountOutputBuilder::new_with_amount(2_000_000, account_id_1) .add_unlock_condition(AddressUnlockCondition::new( Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -683,13 +710,16 @@ fn mint_and_burn_at_the_same_time() { let foundry_id = FoundryId::build(&AccountAddress::from(account_id_1), 1, SimpleTokenScheme::KIND); let token_id = TokenId::from(foundry_id); - let mut inputs = build_inputs([Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(100, 0, 200).unwrap(), - Some((&token_id.to_string(), 100)), - )]); + let mut inputs = build_inputs( + [Foundry( + 1_000_000, + account_id_1, + 1, + SimpleTokenScheme::new(100, 0, 200).unwrap(), + Some((&token_id.to_string(), 100)), + )], + None, + ); let account_output = AccountOutputBuilder::new_with_amount(2_000_000, account_id_1) .add_unlock_condition(AddressUnlockCondition::new( Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -733,25 +763,28 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { let foundry_id = FoundryId::build(&AccountAddress::from(account_id_1), 0, SimpleTokenScheme::KIND); let token_id = TokenId::from(foundry_id); - let mut inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(100, 0, 200).unwrap(), - Some((&token_id.to_string(), 100)), - ), - ]); + let mut inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Foundry( + 1_000_000, + account_id_1, + 1, + SimpleTokenScheme::new(100, 0, 200).unwrap(), + Some((&token_id.to_string(), 100)), + ), + ], + None, + ); let account_output = AccountOutputBuilder::new_with_amount(2_000_000, account_id_1) .add_unlock_condition(AddressUnlockCondition::new( Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -802,23 +835,26 @@ fn create_native_token_but_burn_account() { let foundry_id = FoundryId::build(&AccountAddress::from(account_id_1), 1, SimpleTokenScheme::KIND); let token_id = TokenId::from(foundry_id); - let inputs = build_inputs([ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(0, 0, 100).unwrap(), - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Foundry( + 1_000_000, + account_id_1, + 1, + SimpleTokenScheme::new(0, 0, 100).unwrap(), + None, + ), + ], + None, + ); let outputs = build_outputs([Foundry( 1_000_000, account_id_1, @@ -860,23 +896,26 @@ fn melted_tokens_not_provided() { let foundry_id = FoundryId::build(&AccountAddress::from(account_id_1), 1, SimpleTokenScheme::KIND); let token_id_1 = TokenId::from(foundry_id); - let inputs = build_inputs([ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(100, 0, 100).unwrap(), - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Foundry( + 1_000_000, + account_id_1, + 1, + SimpleTokenScheme::new(100, 0, 100).unwrap(), + None, + ), + ], + None, + ); let outputs = build_outputs([Foundry( 1_000_000, account_id_1, @@ -909,23 +948,26 @@ fn burned_tokens_not_provided() { let foundry_id = FoundryId::build(&AccountAddress::from(account_id_1), 0, SimpleTokenScheme::KIND); let token_id_1 = TokenId::from(foundry_id); - let inputs = build_inputs([ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(100, 0, 100).unwrap(), - None, - ), - ]); + let inputs = build_inputs( + [ + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Foundry( + 1_000_000, + account_id_1, + 1, + SimpleTokenScheme::new(100, 0, 100).unwrap(), + None, + ), + ], + None, + ); let outputs = build_outputs([Foundry( 1_000_000, account_id_1, @@ -957,13 +999,16 @@ fn foundry_in_outputs_and_required() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let mut inputs = build_inputs([Foundry( - 1_000_000, - account_id_2, - 1, - SimpleTokenScheme::new(0, 0, 10).unwrap(), + let mut inputs = build_inputs( + [Foundry( + 1_000_000, + account_id_2, + 1, + SimpleTokenScheme::new(0, 0, 10).unwrap(), + None, + )], None, - )]); + ); let account_output = AccountOutputBuilder::new_with_amount(1_251_500, account_id_2) .add_unlock_condition(AddressUnlockCondition::new( Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1011,25 +1056,28 @@ fn melt_and_burn_native_tokens() { let foundry_id = FoundryId::build(&AccountAddress::from(account_id), 1, SimpleTokenScheme::KIND); let token_id = TokenId::from(foundry_id); - let mut inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Foundry( - 1_000_000, - account_id, - 1, - SimpleTokenScheme::new(1000, 0, 1000).unwrap(), - Some((&token_id.to_string(), 1000)), - ), - ]); + let mut inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Foundry( + 1_000_000, + account_id, + 1, + SimpleTokenScheme::new(1000, 0, 1000).unwrap(), + Some((&token_id.to_string(), 1000)), + ), + ], + None, + ); let account_output = AccountOutputBuilder::new_with_amount(1_000_000, account_id) .add_unlock_condition(AddressUnlockCondition::new( Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), diff --git a/sdk/tests/client/input_selection/nft_outputs.rs b/sdk/tests/client/input_selection/nft_outputs.rs index 33ddf7c960..ad3d40db1e 100644 --- a/sdk/tests/client/input_selection/nft_outputs.rs +++ b/sdk/tests/client/input_selection/nft_outputs.rs @@ -29,16 +29,19 @@ fn input_nft_eq_output_nft() { let protocol_parameters = protocol_parameters(); let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); - let inputs = build_inputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + let inputs = build_inputs( + [Nft( + 1_000_000, + nft_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_2, @@ -68,16 +71,19 @@ fn transition_nft_id_zero() { let protocol_parameters = protocol_parameters(); let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); - let inputs = build_inputs([Nft( - 1_000_000, - nft_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + let inputs = build_inputs( + [Nft( + 1_000_000, + nft_id_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + )], None, - )]); + ); let nft_id = NftId::from(inputs[0].output_id()); let outputs = build_outputs([Nft( 1_000_000, @@ -196,16 +202,19 @@ fn mint_nft() { let protocol_parameters = protocol_parameters(); let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_0, @@ -244,16 +253,19 @@ fn burn_nft() { let protocol_parameters = protocol_parameters(); let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); - let inputs = build_inputs([Nft( - 2_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + let inputs = build_inputs( + [Nft( + 2_000_000, + nft_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -329,16 +341,19 @@ fn missing_input_for_nft_output() { let protocol_parameters = protocol_parameters(); let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_2, @@ -369,16 +384,19 @@ fn missing_input_for_nft_output_but_created() { let protocol_parameters = protocol_parameters(); let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_0, @@ -406,28 +424,31 @@ fn nft_in_output_and_sender() { let protocol_parameters = protocol_parameters(); let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); - let inputs = build_inputs([ - Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Nft( + 1_000_000, + nft_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([ Nft( 1_000_000, @@ -477,16 +498,19 @@ fn missing_ed25519_sender() { let protocol_parameters = protocol_parameters(); let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); - let inputs = build_inputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + let inputs = build_inputs( + [Nft( + 1_000_000, + nft_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_2, @@ -517,16 +541,19 @@ fn missing_ed25519_issuer_created() { let protocol_parameters = protocol_parameters(); let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_0, @@ -557,16 +584,19 @@ fn missing_ed25519_issuer_transition() { let protocol_parameters = protocol_parameters(); let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); - let inputs = build_inputs([Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - None, + let inputs = build_inputs( + [Nft( + 1_000_000, + nft_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_1, @@ -594,16 +624,19 @@ fn missing_account_sender() { let protocol_parameters = protocol_parameters(); let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); - let inputs = build_inputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + let inputs = build_inputs( + [Nft( + 1_000_000, + nft_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_2, @@ -634,16 +667,19 @@ fn missing_account_issuer_created() { let protocol_parameters = protocol_parameters(); let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_0, @@ -674,16 +710,19 @@ fn missing_account_issuer_transition() { let protocol_parameters = protocol_parameters(); let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); - let inputs = build_inputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - None, + let inputs = build_inputs( + [Nft( + 1_000_000, + nft_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_2, @@ -711,16 +750,19 @@ fn missing_nft_sender() { let protocol_parameters = protocol_parameters(); let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); - let inputs = build_inputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + let inputs = build_inputs( + [Nft( + 1_000_000, + nft_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_2, @@ -751,16 +793,19 @@ fn missing_nft_issuer_created() { let protocol_parameters = protocol_parameters(); let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_0, @@ -791,16 +836,19 @@ fn missing_nft_issuer_transition() { let protocol_parameters = protocol_parameters(); let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); - let inputs = build_inputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, - None, + let inputs = build_inputs( + [Nft( + 1_000_000, + nft_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_2, @@ -828,28 +876,31 @@ fn increase_nft_amount() { let protocol_parameters = protocol_parameters(); let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); - let inputs = build_inputs([ - Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Nft( + 2_000_000, + nft_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Nft( 3_000_000, nft_id_1, @@ -879,28 +930,31 @@ fn decrease_nft_amount() { let protocol_parameters = protocol_parameters(); let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); - let inputs = build_inputs([ - Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Nft( + 2_000_000, + nft_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Nft( 1_000_000, nft_id_1, @@ -942,28 +996,31 @@ fn prefer_basic_to_nft() { let protocol_parameters = protocol_parameters(); let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); - let inputs = build_inputs([ - Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Nft( + 2_000_000, + nft_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -994,28 +1051,31 @@ fn take_amount_from_nft_to_fund_basic() { let protocol_parameters = protocol_parameters(); let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); - let inputs = build_inputs([ - Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Nft( + 2_000_000, + nft_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_200_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1058,28 +1118,31 @@ fn nft_burn_should_validate_nft_sender() { let protocol_parameters = protocol_parameters(); let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Nft( + 1_000_000, + nft_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 3_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1110,28 +1173,31 @@ fn nft_burn_should_validate_nft_address() { let protocol_parameters = protocol_parameters(); let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Nft( + 1_000_000, + nft_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 3_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1162,16 +1228,19 @@ fn transitioned_zero_nft_id_no_longer_is_zero() { let protocol_parameters = protocol_parameters(); let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); - let inputs = build_inputs([Nft( - 2_000_000, - nft_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + let inputs = build_inputs( + [Nft( + 2_000_000, + nft_id_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), diff --git a/sdk/tests/client/input_selection/outputs.rs b/sdk/tests/client/input_selection/outputs.rs index 7fae73e9c5..98551690e9 100644 --- a/sdk/tests/client/input_selection/outputs.rs +++ b/sdk/tests/client/input_selection/outputs.rs @@ -46,16 +46,19 @@ fn no_inputs() { fn no_outputs() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = Vec::new(); let selected = InputSelection::new( @@ -74,14 +77,17 @@ fn no_outputs_but_burn() { let protocol_parameters = protocol_parameters(); let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); - let inputs = build_inputs([Account( - 2_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + let inputs = build_inputs( + [Account( + 2_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + )], None, - )]); + ); let outputs = Vec::new(); let selected = InputSelection::new( @@ -108,16 +114,19 @@ fn no_outputs_but_burn() { fn no_address_provided() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -138,16 +147,19 @@ fn no_address_provided() { fn no_matching_address_provided() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -174,28 +186,31 @@ fn no_matching_address_provided() { fn two_addresses_one_missing() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -228,28 +243,31 @@ fn two_addresses_one_missing() { fn two_addresses() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), diff --git a/sdk/tests/client/input_selection/storage_deposit_return.rs b/sdk/tests/client/input_selection/storage_deposit_return.rs index 5c7ba2b633..1ccec61b40 100644 --- a/sdk/tests/client/input_selection/storage_deposit_return.rs +++ b/sdk/tests/client/input_selection/storage_deposit_return.rs @@ -20,16 +20,19 @@ use crate::client::{ fn sdruc_output_not_provided_no_remainder() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -69,16 +72,19 @@ fn sdruc_output_not_provided_no_remainder() { fn sdruc_output_provided_no_remainder() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([ Basic( 1_000_000, @@ -119,16 +125,19 @@ fn sdruc_output_provided_no_remainder() { fn sdruc_output_provided_remainder() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), @@ -168,28 +177,31 @@ fn sdruc_output_provided_remainder() { fn two_sdrucs_to_the_same_address_both_needed() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -229,28 +241,31 @@ fn two_sdrucs_to_the_same_address_both_needed() { fn two_sdrucs_to_the_same_address_one_needed() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -291,28 +306,31 @@ fn two_sdrucs_to_the_same_address_one_needed() { fn two_sdrucs_to_different_addresses_both_needed() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -358,28 +376,31 @@ fn two_sdrucs_to_different_addresses_both_needed() { fn two_sdrucs_to_different_addresses_one_needed() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -420,16 +441,19 @@ fn two_sdrucs_to_different_addresses_one_needed() { fn insufficient_amount_because_of_sdruc() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + None, + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -462,28 +486,31 @@ fn insufficient_amount_because_of_sdruc() { fn useless_sdruc_required_for_sender_feature() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -527,26 +554,29 @@ fn sdruc_required_non_ed25519_in_address_unlock() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), - None, - None, - None, - ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), + None, + None, + None, + ), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), @@ -587,36 +617,39 @@ fn useless_sdruc_non_ed25519_in_address_unlock() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); - let inputs = build_inputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), - None, - None, - None, - None, - None, - None, - ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), diff --git a/sdk/tests/client/input_selection/timelock.rs b/sdk/tests/client/input_selection/timelock.rs index 7c27a9bad9..d5a100cf6d 100644 --- a/sdk/tests/client/input_selection/timelock.rs +++ b/sdk/tests/client/input_selection/timelock.rs @@ -15,16 +15,19 @@ use crate::client::{ fn one_output_timelock_not_expired() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - Some(200), - None, + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + Some(200), + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), @@ -52,16 +55,19 @@ fn one_output_timelock_not_expired() { fn timelock_equal_timestamp() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - Some(200), - None, + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + Some(200), + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), @@ -91,28 +97,31 @@ fn timelock_equal_timestamp() { fn two_outputs_one_timelock_expired() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - Some(200), - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - Some(50), - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + Some(200), + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + Some(50), + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), @@ -143,28 +152,31 @@ fn two_outputs_one_timelock_expired() { fn two_outputs_one_timelocked_one_missing() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - Some(200), - None, - None, - ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), - ]); + let inputs = build_inputs( + [ + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + Some(200), + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), @@ -195,16 +207,19 @@ fn two_outputs_one_timelocked_one_missing() { fn one_output_timelock_expired() { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - Some(50), - None, + let inputs = build_inputs( + [Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + Some(50), + None, + None, + )], None, - )]); + ); let outputs = build_outputs([Basic( 2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), diff --git a/sdk/tests/client/mod.rs b/sdk/tests/client/mod.rs index 987ef89ea8..e65ca490d2 100644 --- a/sdk/tests/client/mod.rs +++ b/sdk/tests/client/mod.rs @@ -31,7 +31,11 @@ use iota_sdk::{ AccountId, AccountOutputBuilder, BasicOutputBuilder, FoundryOutputBuilder, NativeToken, NftId, NftOutputBuilder, Output, OutputId, SimpleTokenScheme, TokenId, TokenScheme, }, - rand::{output::rand_output_metadata_with_id, transaction::rand_transaction_id}, + rand::{ + output::rand_output_metadata_with_id, + transaction::{rand_transaction_id, rand_transaction_id_with_slot_index}, + }, + slot::SlotIndex, }, }; @@ -208,15 +212,22 @@ fn build_output_inner(build: Build) -> (Output, Option) { } } -fn build_inputs<'a>(outputs: impl IntoIterator>) -> Vec { +fn build_inputs<'a>( + outputs: impl IntoIterator>, + slot_index: Option, +) -> Vec { outputs .into_iter() .map(|build| { let (output, chain) = build_output_inner(build); + let transaction_id = slot_index.map_or_else( + || rand_transaction_id(), + |index| rand_transaction_id_with_slot_index(index), + ); InputSigningData { output, - output_metadata: rand_output_metadata_with_id(OutputId::new(rand_transaction_id(), 0)), + output_metadata: rand_output_metadata_with_id(OutputId::new(transaction_id, 0)), chain, } }) diff --git a/sdk/tests/client/signing/account.rs b/sdk/tests/client/signing/account.rs index 30eafbb97c..a97ed6d29e 100644 --- a/sdk/tests/client/signing/account.rs +++ b/sdk/tests/client/signing/account.rs @@ -20,7 +20,7 @@ use iota_sdk::{ output::AccountId, payload::{signed_transaction::Transaction, SignedTransactionPayload}, protocol::protocol_parameters, - rand::mana::rand_mana_allotment, + slot::SlotIndex, unlock::{SignatureUnlock, Unlock}, }, }; @@ -48,15 +48,19 @@ async fn sign_account_state_transition() -> Result<()> { let protocol_parameters = protocol_parameters(); let account_id = AccountId::from_str(ACCOUNT_ID_1)?; + let slot_index = SlotIndex::from(10); - let inputs = build_inputs([Account( - 1_000_000, - account_id, - address.clone(), - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - )]); + let inputs = build_inputs( + [Account( + 1_000_000, + account_id, + address.clone(), + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index), + ); let outputs = build_outputs([Account(1_000_000, account_id, address.clone(), None, None, None)]); @@ -68,7 +72,7 @@ async fn sign_account_state_transition() -> Result<()> { .collect::>(), ) .with_outputs(outputs) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) + .with_creation_slot(slot_index + 1) .finish_with_params(&protocol_parameters)?; let prepared_transaction_data = PreparedTransactionData { @@ -114,19 +118,23 @@ async fn account_reference_unlocks() -> Result<()> { let protocol_parameters = protocol_parameters(); let account_id = AccountId::from_str(ACCOUNT_ID_1)?; let account_address = Address::Account(AccountAddress::new(account_id)); - - let inputs = build_inputs([ - Account( - 1_000_000, - account_id, - address.clone(), - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic(1_000_000, account_address.clone(), None, None, None, None, None, None), - Basic(1_000_000, account_address.clone(), None, None, None, None, None, None), - ]); + let slot_index = SlotIndex::from(10); + + let inputs = build_inputs( + [ + Account( + 1_000_000, + account_id, + address.clone(), + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + Basic(1_000_000, account_address.clone(), None, None, None, None, None, None), + Basic(1_000_000, account_address.clone(), None, None, None, None, None, None), + ], + Some(slot_index), + ); let outputs = build_outputs([ Account(1_000_000, account_id, address, None, None, None), @@ -141,7 +149,7 @@ async fn account_reference_unlocks() -> Result<()> { .collect::>(), ) .with_outputs(outputs) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) + .with_creation_slot(slot_index + 1) .finish_with_params(&protocol_parameters)?; let prepared_transaction_data = PreparedTransactionData { diff --git a/sdk/tests/client/signing/basic.rs b/sdk/tests/client/signing/basic.rs index ba9a2eb5b0..07b7a4144d 100644 --- a/sdk/tests/client/signing/basic.rs +++ b/sdk/tests/client/signing/basic.rs @@ -16,7 +16,7 @@ use iota_sdk::{ input::{Input, UtxoInput}, payload::{signed_transaction::Transaction, SignedTransactionPayload}, protocol::protocol_parameters, - rand::mana::rand_mana_allotment, + slot::SlotIndex, unlock::{SignatureUnlock, Unlock}, }, }; @@ -39,17 +39,21 @@ async fn single_ed25519_unlock() -> Result<()> { .into_inner(); let protocol_parameters = protocol_parameters(); + let slot_index = SlotIndex::from(10); - let inputs = build_inputs([Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - )]); + let inputs = build_inputs( + [Basic( + 1_000_000, + address_0.clone(), + None, + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index), + ); let outputs = build_outputs([Basic( 1_000_000, @@ -70,7 +74,7 @@ async fn single_ed25519_unlock() -> Result<()> { .collect::>(), ) .with_outputs(outputs) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) + .with_creation_slot(slot_index + 1) .finish_with_params(&protocol_parameters)?; let prepared_transaction_data = PreparedTransactionData { @@ -114,39 +118,43 @@ async fn ed25519_reference_unlocks() -> Result<()> { .into_inner(); let protocol_parameters = protocol_parameters(); - - let inputs = build_inputs([ - Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - ]); + let slot_index = SlotIndex::from(10); + + let inputs = build_inputs( + [ + Basic( + 1_000_000, + address_0.clone(), + None, + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + Basic( + 1_000_000, + address_0.clone(), + None, + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + Basic( + 1_000_000, + address_0.clone(), + None, + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + ], + Some(slot_index), + ); let outputs = build_outputs([Basic( 3_000_000, @@ -167,7 +175,7 @@ async fn ed25519_reference_unlocks() -> Result<()> { .collect::>(), ) .with_outputs(outputs) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) + .with_creation_slot(slot_index + 1) .finish_with_params(&protocol_parameters)?; let prepared_transaction_data = PreparedTransactionData { @@ -232,29 +240,33 @@ async fn two_signature_unlocks() -> Result<()> { .into_inner(); let protocol_parameters = protocol_parameters(); - - let inputs = build_inputs([ - Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic( - 1_000_000, - address_1, - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(1)), - ), - ]); + let slot_index = SlotIndex::from(10); + + let inputs = build_inputs( + [ + Basic( + 1_000_000, + address_0.clone(), + None, + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + Basic( + 1_000_000, + address_1, + None, + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(1)), + ), + ], + Some(slot_index), + ); let outputs = build_outputs([Basic( 2_000_000, @@ -275,7 +287,7 @@ async fn two_signature_unlocks() -> Result<()> { .collect::>(), ) .with_outputs(outputs) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) + .with_creation_slot(slot_index + 1) .finish_with_params(&protocol_parameters)?; let prepared_transaction_data = PreparedTransactionData { diff --git a/sdk/tests/client/signing/mod.rs b/sdk/tests/client/signing/mod.rs index a5149ec73a..dc38b1fd3d 100644 --- a/sdk/tests/client/signing/mod.rs +++ b/sdk/tests/client/signing/mod.rs @@ -19,13 +19,12 @@ use iota_sdk::{ Result, }, types::block::{ - address::{AccountAddress, Address, NftAddress, ToBech32Ext}, + address::{AccountAddress, Address, NftAddress}, context_input::{CommitmentContextInput, ContextInput}, input::{Input, UtxoInput}, output::{AccountId, NftId}, payload::{signed_transaction::Transaction, SignedTransactionPayload}, protocol::protocol_parameters, - rand::mana::rand_mana_allotment, slot::{SlotCommitmentId, SlotIndex}, unlock::{SignatureUnlock, Unlock}, }, @@ -72,125 +71,130 @@ async fn all_combined() -> Result<()> { let nft_3 = Address::Nft(NftAddress::new(nft_id_3)); let nft_4 = Address::Nft(NftAddress::new(nft_id_4)); - let inputs = build_inputs([ - Account(1_000_000, account_id_1, nft_1.clone(), None, None, None), - Account( - 1_000_000, - account_id_2, - ed25519_0.clone(), - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic(1_000_000, account_1.clone(), None, None, None, None, None, None), - Basic(1_000_000, account_2.clone(), None, None, None, None, None, None), - Basic(1_000_000, account_2, None, None, None, None, None, None), - Basic(1_000_000, nft_2.clone(), None, None, None, None, None, None), - Basic(1_000_000, nft_2, None, None, None, None, None, None), - Basic(1_000_000, nft_4.clone(), None, None, None, None, None, None), - Basic( - 1_000_000, - ed25519_0.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic( - 1_000_000, - ed25519_1.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(1)), - ), - Basic( - 1_000_000, - ed25519_2.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(2)), - ), - Basic( - 1_000_000, - ed25519_2.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(2)), - ), - Nft( - 1_000_000, - nft_id_1, - ed25519_0.clone(), - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Nft(1_000_000, nft_id_2, account_1.clone(), None, None, None, None, None), - // Expirations - Basic( - 2_000_000, - ed25519_0.clone(), - None, - None, - None, - None, - Some((account_1.clone(), 50)), - None, - ), - Basic( - 2_000_000, - ed25519_0.clone(), - None, - None, - None, - None, - Some((nft_3.clone(), 50)), - None, - ), - Basic( - 2_000_000, - ed25519_0.clone(), - None, - None, - None, - None, - Some((nft_3.clone(), 150)), - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Nft( - 1_000_000, - nft_id_3, - account_1.clone(), - None, - None, - None, - Some((nft_4, 50)), - None, - ), - Nft( - 1_000_000, - nft_id_4, - account_1, - None, - None, - None, - Some((nft_3, 150)), - None, - ), - ]); + let slot_index = SlotIndex::from(90); + + let inputs = build_inputs( + [ + Account(1_000_000, account_id_1, nft_1.clone(), None, None, None), + Account( + 1_000_000, + account_id_2, + ed25519_0.clone(), + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + Basic(1_000_000, account_1.clone(), None, None, None, None, None, None), + Basic(1_000_000, account_2.clone(), None, None, None, None, None, None), + Basic(1_000_000, account_2, None, None, None, None, None, None), + Basic(1_000_000, nft_2.clone(), None, None, None, None, None, None), + Basic(1_000_000, nft_2, None, None, None, None, None, None), + Basic(1_000_000, nft_4.clone(), None, None, None, None, None, None), + Basic( + 1_000_000, + ed25519_0.clone(), + None, + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + Basic( + 1_000_000, + ed25519_1.clone(), + None, + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(1)), + ), + Basic( + 1_000_000, + ed25519_2.clone(), + None, + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(2)), + ), + Basic( + 1_000_000, + ed25519_2.clone(), + None, + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(2)), + ), + Nft( + 1_000_000, + nft_id_1, + ed25519_0.clone(), + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + Nft(1_000_000, nft_id_2, account_1.clone(), None, None, None, None, None), + // Expirations + Basic( + 2_000_000, + ed25519_0.clone(), + None, + None, + None, + None, + Some((account_1.clone(), 50)), + None, + ), + Basic( + 2_000_000, + ed25519_0.clone(), + None, + None, + None, + None, + Some((nft_3.clone(), 50)), + None, + ), + Basic( + 2_000_000, + ed25519_0.clone(), + None, + None, + None, + None, + Some((nft_3.clone(), 150)), + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + Nft( + 1_000_000, + nft_id_3, + account_1.clone(), + None, + None, + None, + Some((nft_4, 50)), + None, + ), + Nft( + 1_000_000, + nft_id_4, + account_1, + None, + None, + None, + Some((nft_3, 150)), + None, + ), + ], + Some(slot_index), + ); let outputs = build_outputs([ Account(1_000_000, account_id_1, nft_1, None, None, None), @@ -202,8 +206,6 @@ async fn all_combined() -> Result<()> { Nft(1_000_000, nft_id_4, ed25519_0.clone(), None, None, None, None, None), ]); - let slot_index = SlotIndex::from(90); - let selected = InputSelection::new( inputs.clone(), outputs.clone(), @@ -227,7 +229,6 @@ async fn all_combined() -> Result<()> { ) .with_outputs(outputs) .with_creation_slot(slot_index) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) .finish_with_params(&protocol_parameters)?; let prepared_transaction_data = PreparedTransactionData { diff --git a/sdk/tests/client/signing/nft.rs b/sdk/tests/client/signing/nft.rs index 65e0470d18..72b4c4d374 100644 --- a/sdk/tests/client/signing/nft.rs +++ b/sdk/tests/client/signing/nft.rs @@ -20,7 +20,7 @@ use iota_sdk::{ output::NftId, payload::{signed_transaction::Transaction, SignedTransactionPayload}, protocol::protocol_parameters, - rand::mana::rand_mana_allotment, + slot::SlotIndex, unlock::{SignatureUnlock, Unlock}, }, }; @@ -49,21 +49,25 @@ async fn nft_reference_unlocks() -> Result<()> { let protocol_parameters = protocol_parameters(); let nft_id = NftId::from_str(NFT_ID_1)?; let nft_address = Address::Nft(NftAddress::new(nft_id)); - - let inputs = build_inputs([ - Nft( - 1_000_000, - nft_id, - address_0.clone(), - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic(1_000_000, nft_address.clone(), None, None, None, None, None, None), - Basic(1_000_000, nft_address.clone(), None, None, None, None, None, None), - ]); + let slot_index = SlotIndex::from(10); + + let inputs = build_inputs( + [ + Nft( + 1_000_000, + nft_id, + address_0.clone(), + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + Basic(1_000_000, nft_address.clone(), None, None, None, None, None, None), + Basic(1_000_000, nft_address.clone(), None, None, None, None, None, None), + ], + Some(slot_index), + ); let outputs = build_outputs([ Nft(1_000_000, nft_id, address_0, None, None, None, None, None), @@ -78,7 +82,7 @@ async fn nft_reference_unlocks() -> Result<()> { .collect::>(), ) .with_outputs(outputs) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) + .with_creation_slot(slot_index + 1) .finish_with_params(&protocol_parameters)?; let prepared_transaction_data = PreparedTransactionData {