diff --git a/sdk/src/types/block/rand/transaction.rs b/sdk/src/types/block/rand/transaction.rs index 20036d143b..d147183e61 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, + slot::SlotIndex, +}; /// Generates a random transaction id. pub fn rand_transaction_id() -> TransactionId { TransactionId::new(rand_bytes_array()) } + +/// 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()) +} diff --git a/sdk/src/types/block/semantic/mod.rs b/sdk/src/types/block/semantic/mod.rs index d7d98d4767..b45d7713c9 100644 --- a/sdk/src/types/block/semantic/mod.rs +++ b/sdk/src/types/block/semantic/mod.rs @@ -291,14 +291,13 @@ 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 { - if self.input_mana > self.output_mana - && !self.transaction.has_capability(TransactionCapabilityFlag::BurnMana) - { - return Ok(Some( - TransactionFailureReason::TransactionCapabilityManaBurningNotAllowed, - )); + 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)); } 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..9d19b42193 100644 --- a/sdk/tests/client/signing/account.rs +++ b/sdk/tests/client/signing/account.rs @@ -20,7 +20,6 @@ use iota_sdk::{ output::AccountId, payload::{signed_transaction::Transaction, SignedTransactionPayload}, protocol::protocol_parameters, - rand::mana::rand_mana_allotment, unlock::{SignatureUnlock, Unlock}, }, }; @@ -49,14 +48,17 @@ async fn sign_account_state_transition() -> Result<()> { let protocol_parameters = protocol_parameters(); let account_id = AccountId::from_str(ACCOUNT_ID_1)?; - let inputs = build_inputs([Account( - 1_000_000, - account_id, - address.clone(), - None, + let inputs = build_inputs( + [Account( + 1_000_000, + account_id, + address.clone(), + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - )]); + ); let outputs = build_outputs([Account(1_000_000, account_id, address.clone(), None, None, None)]); @@ -68,7 +70,14 @@ async fn sign_account_state_transition() -> Result<()> { .collect::>(), ) .with_outputs(outputs) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) + .with_creation_slot( + inputs + .iter() + .map(|i| i.output_id().transaction_id().slot_index()) + .max() + .unwrap() + + 1, + ) .finish_with_params(&protocol_parameters)?; let prepared_transaction_data = PreparedTransactionData { @@ -115,18 +124,21 @@ async fn account_reference_unlocks() -> Result<()> { 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 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), + ], + None, + ); let outputs = build_outputs([ Account(1_000_000, account_id, address, None, None, None), @@ -141,7 +153,14 @@ async fn account_reference_unlocks() -> Result<()> { .collect::>(), ) .with_outputs(outputs) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) + .with_creation_slot( + inputs + .iter() + .map(|i| i.output_id().transaction_id().slot_index()) + .max() + .unwrap() + + 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..2988f2bccf 100644 --- a/sdk/tests/client/signing/basic.rs +++ b/sdk/tests/client/signing/basic.rs @@ -16,7 +16,6 @@ use iota_sdk::{ input::{Input, UtxoInput}, payload::{signed_transaction::Transaction, SignedTransactionPayload}, protocol::protocol_parameters, - rand::mana::rand_mana_allotment, unlock::{SignatureUnlock, Unlock}, }, }; @@ -40,16 +39,19 @@ async fn single_ed25519_unlock() -> Result<()> { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, + let inputs = build_inputs( + [Basic( + 1_000_000, + address_0.clone(), + None, + None, + None, + None, + None, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - )]); + ); let outputs = build_outputs([Basic( 1_000_000, @@ -70,7 +72,14 @@ async fn single_ed25519_unlock() -> Result<()> { .collect::>(), ) .with_outputs(outputs) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) + .with_creation_slot( + inputs + .iter() + .map(|i| i.output_id().transaction_id().slot_index()) + .max() + .unwrap() + + 1, + ) .finish_with_params(&protocol_parameters)?; let prepared_transaction_data = PreparedTransactionData { @@ -115,38 +124,41 @@ async fn ed25519_reference_unlocks() -> Result<()> { 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 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)), + ), + ], + None, + ); let outputs = build_outputs([Basic( 3_000_000, @@ -167,7 +179,14 @@ async fn ed25519_reference_unlocks() -> Result<()> { .collect::>(), ) .with_outputs(outputs) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) + .with_creation_slot( + inputs + .iter() + .map(|i| i.output_id().transaction_id().slot_index()) + .max() + .unwrap() + + 1, + ) .finish_with_params(&protocol_parameters)?; let prepared_transaction_data = PreparedTransactionData { @@ -233,28 +252,31 @@ async fn two_signature_unlocks() -> Result<()> { 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 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)), + ), + ], + None, + ); let outputs = build_outputs([Basic( 2_000_000, @@ -275,7 +297,14 @@ async fn two_signature_unlocks() -> Result<()> { .collect::>(), ) .with_outputs(outputs) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) + .with_creation_slot( + inputs + .iter() + .map(|i| i.output_id().transaction_id().slot_index()) + .max() + .unwrap() + + 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..44e65b9de2 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,128 @@ 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 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, + ), + ], + None, + ); let outputs = build_outputs([ Account(1_000_000, account_id_1, nft_1, None, None, None), @@ -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..20494c00bf 100644 --- a/sdk/tests/client/signing/nft.rs +++ b/sdk/tests/client/signing/nft.rs @@ -20,7 +20,6 @@ use iota_sdk::{ output::NftId, payload::{signed_transaction::Transaction, SignedTransactionPayload}, protocol::protocol_parameters, - rand::mana::rand_mana_allotment, unlock::{SignatureUnlock, Unlock}, }, }; @@ -50,20 +49,23 @@ async fn nft_reference_unlocks() -> Result<()> { 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 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), + ], + None, + ); let outputs = build_outputs([ Nft(1_000_000, nft_id, address_0, None, None, None, None, None), @@ -78,7 +80,14 @@ async fn nft_reference_unlocks() -> Result<()> { .collect::>(), ) .with_outputs(outputs) - .add_mana_allotment(rand_mana_allotment(&protocol_parameters)) + .with_creation_slot( + inputs + .iter() + .map(|i| i.output_id().transaction_id().slot_index()) + .max() + .unwrap() + + 1, + ) .finish_with_params(&protocol_parameters)?; let prepared_transaction_data = PreparedTransactionData {