diff --git a/sdk/src/client/api/block_builder/input_selection/mod.rs b/sdk/src/client/api/block_builder/input_selection/mod.rs index 835c102b62..4267a6e15e 100644 --- a/sdk/src/client/api/block_builder/input_selection/mod.rs +++ b/sdk/src/client/api/block_builder/input_selection/mod.rs @@ -155,6 +155,7 @@ impl InputSelection { available_inputs: impl Into>, outputs: impl Into>, addresses: impl IntoIterator, + slot_index: impl Into, protocol_parameters: ProtocolParameters, ) -> Self { let available_inputs = available_inputs.into(); @@ -189,9 +190,8 @@ impl InputSelection { burn: None, remainder_address: None, protocol_parameters, - // TODO may want to make this mandatory at some point // Should be set from a commitment context input - slot_index: SlotIndex::from(0), + slot_index: slot_index.into(), requirements: Vec::new(), automatically_transitioned: HashSet::new(), mana_allotments: 0, @@ -222,12 +222,6 @@ impl InputSelection { self } - /// Sets the slot index of an [`InputSelection`]. - pub fn with_slot_index(mut self, slot_index: impl Into) -> Self { - self.slot_index = slot_index.into(); - self - } - /// Sets the mana allotments sum of an [`InputSelection`]. pub fn with_mana_allotments<'a>(mut self, mana_allotments: impl Iterator) -> Self { self.mana_allotments = mana_allotments.map(ManaAllotment::mana).sum(); diff --git a/sdk/src/wallet/operations/transaction/input_selection.rs b/sdk/src/wallet/operations/transaction/input_selection.rs index b7759deb4b..9b06159ed9 100644 --- a/sdk/src/wallet/operations/transaction/input_selection.rs +++ b/sdk/src/wallet/operations/transaction/input_selection.rs @@ -94,11 +94,11 @@ where available_outputs_signing_data, outputs, Some(wallet_data.address.clone().into_inner()), + slot_index, protocol_parameters.clone(), ) .with_required_inputs(custom_inputs) - .with_forbidden_inputs(forbidden_inputs) - .with_slot_index(slot_index); + .with_forbidden_inputs(forbidden_inputs); if let Some(address) = remainder_address { input_selection = input_selection.with_remainder_address(address); @@ -134,11 +134,11 @@ where available_outputs_signing_data, outputs, Some(wallet_data.address.clone().into_inner()), + slot_index, protocol_parameters.clone(), ) .with_required_inputs(mandatory_inputs) - .with_forbidden_inputs(forbidden_inputs) - .with_slot_index(slot_index); + .with_forbidden_inputs(forbidden_inputs); if let Some(address) = remainder_address { input_selection = input_selection.with_remainder_address(address); @@ -171,10 +171,10 @@ where available_outputs_signing_data, outputs, Some(wallet_data.address.clone().into_inner()), + slot_index, protocol_parameters.clone(), ) - .with_forbidden_inputs(forbidden_inputs) - .with_slot_index(slot_index); + .with_forbidden_inputs(forbidden_inputs); if let Some(address) = remainder_address { input_selection = input_selection.with_remainder_address(address); diff --git a/sdk/tests/client/input_selection/account_outputs.rs b/sdk/tests/client/input_selection/account_outputs.rs index ade83ef47a..a67389ed04 100644 --- a/sdk/tests/client/input_selection/account_outputs.rs +++ b/sdk/tests/client/input_selection/account_outputs.rs @@ -17,7 +17,7 @@ use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic}, ACCOUNT_ID_0, ACCOUNT_ID_1, ACCOUNT_ID_2, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, - BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_NFT_1, + BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_NFT_1, SLOT_INDEX, }; #[test] @@ -34,7 +34,7 @@ fn input_account_eq_output_account() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -49,6 +49,7 @@ fn input_account_eq_output_account() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -72,7 +73,7 @@ fn transition_account_id_zero() { None, None, )], - None, + Some(SLOT_INDEX), ); let account_id = AccountId::from(inputs[0].output_id()); let outputs = build_outputs([Account( @@ -88,6 +89,7 @@ fn transition_account_id_zero() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -128,7 +130,7 @@ fn transition_account_id_zero() { // inputs, // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1, protocol_parameters, // ) // .select(); @@ -176,7 +178,7 @@ fn transition_account_id_zero() { // inputs, // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1, protocol_parameters, // ) // .select(); @@ -221,7 +223,7 @@ fn transition_account_id_zero() { // inputs.clone(), // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1, protocol_parameters, // ) // .select() // .unwrap(); @@ -247,7 +249,7 @@ fn create_account() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -262,6 +264,7 @@ fn create_account() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -294,7 +297,7 @@ fn burn_account() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -311,6 +314,7 @@ fn burn_account() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_2)) @@ -353,7 +357,7 @@ fn burn_account() { // inputs, // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1, protocol_parameters, // ) // .select(); @@ -397,6 +401,7 @@ fn missing_input_for_account_output() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -449,6 +454,7 @@ fn missing_input_for_account_output_2() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -475,7 +481,7 @@ fn missing_input_for_account_output_but_created() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -490,6 +496,7 @@ fn missing_input_for_account_output_but_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -523,7 +530,7 @@ fn account_in_output_and_sender() { None, ), ], - None, + Some(SLOT_INDEX), ); let account_output = AccountOutputBuilder::from(inputs[0].output.as_account()) .finish_output() @@ -544,6 +551,7 @@ fn account_in_output_and_sender() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -582,6 +590,7 @@ fn missing_ed25519_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -623,6 +632,7 @@ fn missing_ed25519_issuer_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -647,7 +657,7 @@ fn missing_ed25519_issuer_transition() { Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -662,6 +672,7 @@ fn missing_ed25519_issuer_transition() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -698,6 +709,7 @@ fn missing_account_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -739,6 +751,7 @@ fn missing_account_issuer_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -763,7 +776,7 @@ fn missing_account_issuer_transition() { Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -778,6 +791,7 @@ fn missing_account_issuer_transition() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -814,6 +828,7 @@ fn missing_nft_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -855,6 +870,7 @@ fn missing_nft_issuer_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -879,7 +895,7 @@ fn missing_nft_issuer_transition() { Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -894,6 +910,7 @@ fn missing_nft_issuer_transition() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -927,7 +944,7 @@ fn increase_account_amount() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 3_000_000, @@ -942,6 +959,7 @@ fn increase_account_amount() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -977,7 +995,7 @@ fn decrease_account_amount() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -992,6 +1010,7 @@ fn decrease_account_amount() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1039,7 +1058,7 @@ fn prefer_basic_to_account() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1056,6 +1075,7 @@ fn prefer_basic_to_account() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1092,7 +1112,7 @@ fn take_amount_from_account_to_fund_basic() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_200_000, @@ -1109,6 +1129,7 @@ fn take_amount_from_account_to_fund_basic() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1159,7 +1180,7 @@ fn account_burn_should_validate_account_sender() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -1176,6 +1197,7 @@ fn account_burn_should_validate_account_sender() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_1)) @@ -1224,7 +1246,7 @@ fn account_burn_should_validate_account_address() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -1241,6 +1263,7 @@ fn account_burn_should_validate_account_address() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_1)) @@ -1277,7 +1300,7 @@ fn transitioned_zero_account_id_no_longer_is_zero() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1294,6 +1317,7 @@ fn transitioned_zero_account_id_no_longer_is_zero() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1343,7 +1367,7 @@ fn two_accounts_required() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 3_000_000, @@ -1360,6 +1384,7 @@ fn two_accounts_required() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1368,26 +1393,22 @@ fn two_accounts_required() { assert!(unsorted_eq(&selected.inputs, &inputs)); assert_eq!(selected.outputs.len(), 3); assert!(selected.outputs.contains(&outputs[0])); - assert!( - selected - .outputs - .iter() - .any(|output| if let Output::Account(output) = output { - output.account_id() == &account_id_1 - } else { - false - }) - ); - assert!( - selected - .outputs - .iter() - .any(|output| if let Output::Account(output) = output { - output.account_id() == &account_id_2 - } else { - false - }) - ) + assert!(selected + .outputs + .iter() + .any(|output| if let Output::Account(output) = output { + output.account_id() == &account_id_1 + } else { + false + })); + assert!(selected + .outputs + .iter() + .any(|output| if let Output::Account(output) = output { + output.account_id() == &account_id_2 + } else { + false + })) } #[test] @@ -1404,7 +1425,7 @@ fn state_controller_sender_required() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1421,6 +1442,7 @@ fn state_controller_sender_required() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1445,7 +1467,7 @@ fn state_controller_sender_required_already_selected() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([ Account( @@ -1472,6 +1494,7 @@ fn state_controller_sender_required_already_selected() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_required_inputs([*inputs[0].output_id()]) @@ -1496,7 +1519,7 @@ fn state_transition_and_required() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 2_000_000, @@ -1511,6 +1534,7 @@ fn state_transition_and_required() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_required_inputs([*inputs[0].output_id()]) @@ -1535,7 +1559,7 @@ fn remainder_address_in_state_controller() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -1550,6 +1574,7 @@ fn remainder_address_in_state_controller() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() diff --git a/sdk/tests/client/input_selection/basic_outputs.rs b/sdk/tests/client/input_selection/basic_outputs.rs index f20d862c8b..88b5e2a1f3 100644 --- a/sdk/tests/client/input_selection/basic_outputs.rs +++ b/sdk/tests/client/input_selection/basic_outputs.rs @@ -17,7 +17,7 @@ use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic, Nft}, ACCOUNT_ID_0, ACCOUNT_ID_1, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, - BECH32_ADDRESS_ED25519_2, BECH32_ADDRESS_NFT_1, BECH32_ADDRESS_REMAINDER, NFT_ID_0, NFT_ID_1, + BECH32_ADDRESS_ED25519_2, BECH32_ADDRESS_NFT_1, BECH32_ADDRESS_REMAINDER, NFT_ID_0, NFT_ID_1, SLOT_INDEX, }; #[test] @@ -52,6 +52,7 @@ fn input_amount_equal_output_amount() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -93,6 +94,7 @@ fn input_amount_lower_than_output_amount() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -150,6 +152,7 @@ fn input_amount_lower_than_output_amount_2() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -195,6 +198,7 @@ fn input_amount_greater_than_output_amount() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -249,6 +253,7 @@ fn input_amount_greater_than_output_amount_with_remainder_address() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_remainder_address(remainder_address) @@ -315,6 +320,7 @@ fn two_same_inputs_one_needed() { inputs, outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -381,6 +387,7 @@ fn two_inputs_one_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -434,6 +441,7 @@ fn two_inputs_one_needed_reversed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -487,6 +495,7 @@ fn two_inputs_both_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -540,6 +549,7 @@ fn two_inputs_remainder() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -590,7 +600,7 @@ fn two_inputs_remainder() { // inputs, // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1,protocol_parameters, // ) // .select(); @@ -681,6 +691,7 @@ fn ed25519_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -688,12 +699,10 @@ fn ed25519_sender() { // Sender + another for amount assert_eq!(selected.inputs.len(), 2); - assert!( - selected - .inputs - .iter() - .any(|input| *input.output.as_basic().address() == sender) - ); + assert!(selected + .inputs + .iter() + .any(|input| *input.output.as_basic().address() == sender)); // Provided output + remainder assert_eq!(selected.outputs.len(), 2); } @@ -730,6 +739,7 @@ fn missing_ed25519_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -813,6 +823,7 @@ fn account_sender() { inputs, outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -820,12 +831,10 @@ fn account_sender() { // Sender + another for amount assert_eq!(selected.inputs.len(), 2); - assert!( - selected - .inputs - .iter() - .any(|input| input.output.is_account() && *input.output.as_account().account_id() == account_id_1) - ); + assert!(selected + .inputs + .iter() + .any(|input| input.output.is_account() && *input.output.as_account().account_id() == account_id_1)); // Provided output + account assert_eq!(selected.outputs.len(), 2); assert!(selected.outputs.contains(&outputs[0])); @@ -875,6 +884,7 @@ fn account_sender_zero_id() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -882,12 +892,10 @@ fn account_sender_zero_id() { assert!(unsorted_eq(&selected.inputs, &inputs)); assert_eq!(selected.outputs.len(), 2); - assert!( - selected - .outputs - .iter() - .any(|output| output.is_account() && *output.as_account().account_id() == account_id) - ); + assert!(selected + .outputs + .iter() + .any(|output| output.is_account() && *output.as_account().account_id() == account_id)); } #[test] @@ -922,6 +930,7 @@ fn missing_account_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -1007,6 +1016,7 @@ fn nft_sender() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1014,12 +1024,10 @@ fn nft_sender() { // Sender + another for amount assert_eq!(selected.inputs.len(), 2); - assert!( - selected - .inputs - .iter() - .any(|input| input.output.is_nft() && *input.output.as_nft().nft_id() == nft_id_1) - ); + assert!(selected + .inputs + .iter() + .any(|input| input.output.is_nft() && *input.output.as_nft().nft_id() == nft_id_1)); // Provided output + nft assert_eq!(selected.outputs.len(), 2); assert!(selected.outputs.contains(&inputs[2].output)); @@ -1072,6 +1080,7 @@ fn nft_sender_zero_id() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1079,12 +1088,10 @@ fn nft_sender_zero_id() { assert!(unsorted_eq(&selected.inputs, &inputs)); assert_eq!(selected.outputs.len(), 2); - assert!( - selected - .outputs - .iter() - .any(|output| output.is_nft() && *output.as_nft().nft_id() == nft_id) - ); + assert!(selected + .outputs + .iter() + .any(|output| output.is_nft() && *output.as_nft().nft_id() == nft_id)); } #[test] @@ -1119,6 +1126,7 @@ fn missing_nft_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -1161,6 +1169,7 @@ fn simple_remainder() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1210,7 +1219,7 @@ fn simple_remainder() { // inputs, // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1,protocol_parameters, // ) // .select(); @@ -1248,7 +1257,7 @@ fn simple_remainder() { // inputs, // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1,protocol_parameters, // ) // .select(); @@ -1293,6 +1302,7 @@ fn one_provided_one_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1334,6 +1344,7 @@ fn insufficient_amount() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -1391,6 +1402,7 @@ fn two_inputs_remainder_2() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1456,6 +1468,7 @@ fn two_inputs_remainder_3() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1501,7 +1514,7 @@ fn two_inputs_remainder_3() { // inputs.clone(), // outputs.clone(), // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1,protocol_parameters, // ) // .select() // .unwrap(); @@ -1551,6 +1564,7 @@ fn sender_already_selected() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX + 1, protocol_parameters, ) .with_required_inputs([*inputs[0].output_id()]) @@ -1596,6 +1610,7 @@ fn single_mandatory_input() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX + 1, protocol_parameters, ) .with_required_inputs([*inputs[0].output_id()]) @@ -1642,6 +1657,7 @@ fn too_many_inputs() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -1704,6 +1720,7 @@ fn more_than_max_inputs_only_one_needed() { inputs, outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1750,6 +1767,7 @@ fn too_many_outputs() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -1798,6 +1816,7 @@ fn too_many_outputs_with_remainder() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -1876,6 +1895,7 @@ fn restricted_ed25519() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1924,6 +1944,7 @@ fn restricted_nft() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1970,6 +1991,7 @@ fn restricted_account() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -2059,6 +2081,7 @@ fn restricted_ed25519_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -2066,12 +2089,10 @@ fn restricted_ed25519_sender() { // Sender + another for amount assert_eq!(selected.inputs.len(), 2); - assert!( - selected - .inputs - .iter() - .any(|input| *input.output.as_basic().address() == sender) - ); + assert!(selected + .inputs + .iter() + .any(|input| *input.output.as_basic().address() == sender)); // Provided output + remainder assert_eq!(selected.outputs.len(), 2); } @@ -2148,6 +2169,7 @@ fn multi_address_sender_already_fulfilled() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), ], + SLOT_INDEX + 1, protocol_parameters, ) .with_required_inputs([*inputs[0].output_id(), *inputs[1].output_id(), *inputs[2].output_id()]) @@ -2212,6 +2234,7 @@ fn ed25519_backed_available_address() { outputs.clone(), // Restricted address is provided, but it can also unlock the ed25519 one [restricted_address], + SLOT_INDEX + 1, protocol_parameters, ) .select() diff --git a/sdk/tests/client/input_selection/expiration.rs b/sdk/tests/client/input_selection/expiration.rs index 8dc60c5696..be25fc3e0f 100644 --- a/sdk/tests/client/input_selection/expiration.rs +++ b/sdk/tests/client/input_selection/expiration.rs @@ -17,7 +17,7 @@ use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic, Nft}, ACCOUNT_ID_1, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, - BECH32_ADDRESS_ED25519_2, NFT_ID_1, + BECH32_ADDRESS_ED25519_2, NFT_ID_1, SLOT_INDEX, }; #[test] @@ -52,9 +52,9 @@ fn one_output_expiration_not_expired() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select(); assert!(matches!(selected, Err(Error::NoAvailableInputsProvided))); @@ -92,9 +92,9 @@ fn expiration_equal_timestamp() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(200) .select() .unwrap(); @@ -134,9 +134,9 @@ fn one_output_expiration_expired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -188,9 +188,9 @@ fn two_outputs_one_expiration_expired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -243,9 +243,9 @@ fn two_outputs_one_unexpired_one_missing() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -308,9 +308,9 @@ fn two_outputs_two_expired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(200) .select() .unwrap(); @@ -366,9 +366,9 @@ fn two_outputs_two_expired_2() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), ], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(200) .select() .unwrap(); @@ -408,9 +408,9 @@ fn expiration_expired_with_sdr() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -450,9 +450,9 @@ fn expiration_expired_with_sdr_2() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -492,9 +492,9 @@ fn expiration_expired_with_sdr_and_timelock() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -534,9 +534,9 @@ fn expiration_expired_with_sdr_and_timelock_2() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -621,9 +621,9 @@ fn sender_in_expiration() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -667,9 +667,9 @@ fn sender_in_expiration_already_selected() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .with_required_inputs([*inputs[0].output_id()]) .select() .unwrap(); @@ -713,9 +713,9 @@ fn remainder_in_expiration() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -766,9 +766,9 @@ fn expiration_expired_non_ed25519_in_address_unlock_condition() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -820,9 +820,9 @@ fn expiration_expired_only_account_addresses() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -863,9 +863,9 @@ fn one_nft_output_expiration_unexpired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -906,9 +906,9 @@ fn one_nft_output_expiration_expired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); diff --git a/sdk/tests/client/input_selection/foundry_outputs.rs b/sdk/tests/client/input_selection/foundry_outputs.rs index bf8fe83707..f7e869dcb6 100644 --- a/sdk/tests/client/input_selection/foundry_outputs.rs +++ b/sdk/tests/client/input_selection/foundry_outputs.rs @@ -23,7 +23,7 @@ use pretty_assertions::assert_eq; use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic, Foundry}, - ACCOUNT_ID_1, ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, + ACCOUNT_ID_1, ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, SLOT_INDEX, }; #[test] @@ -56,6 +56,7 @@ fn missing_input_account_for_foundry() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -144,6 +145,7 @@ fn minted_native_tokens_in_new_remainder() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -215,6 +217,7 @@ fn minted_native_tokens_in_provided_output() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -282,6 +285,7 @@ fn melt_native_tokens() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -335,6 +339,7 @@ fn destroy_foundry_with_account_state_transition() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_burn(Burn::new().add_foundry(inputs[1].output.as_foundry().id())) @@ -386,6 +391,7 @@ fn destroy_foundry_with_account_burn() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_burn( @@ -461,6 +467,7 @@ fn prefer_basic_to_foundry() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -523,6 +530,7 @@ fn simple_foundry_transition_basic_not_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -600,6 +608,7 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -745,6 +754,7 @@ fn mint_and_burn_at_the_same_time() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_burn(Burn::new().add_native_token(token_id, 10)) @@ -812,6 +822,7 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -867,6 +878,7 @@ fn create_native_token_but_burn_account() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_1)) @@ -928,6 +940,7 @@ fn melted_tokens_not_provided() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -980,6 +993,7 @@ fn burned_tokens_not_provided() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_burn(Burn::new().add_native_token(token_id_1, 100)) @@ -1033,6 +1047,7 @@ fn foundry_in_outputs_and_required() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_required_inputs([*inputs[1].output_id()]) @@ -1103,6 +1118,7 @@ fn melt_and_burn_native_tokens() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) // Burn 456 native tokens diff --git a/sdk/tests/client/input_selection/nft_outputs.rs b/sdk/tests/client/input_selection/nft_outputs.rs index ad3d40db1e..d4aaf1c4c9 100644 --- a/sdk/tests/client/input_selection/nft_outputs.rs +++ b/sdk/tests/client/input_selection/nft_outputs.rs @@ -21,7 +21,7 @@ use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Basic, Nft}, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_NFT_1, NFT_ID_0, - NFT_ID_1, NFT_ID_2, + NFT_ID_1, NFT_ID_2, SLOT_INDEX, }; #[test] @@ -57,6 +57,7 @@ fn input_nft_eq_output_nft() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -100,6 +101,7 @@ fn transition_nft_id_zero() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -230,6 +232,7 @@ fn mint_nft() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -281,6 +284,7 @@ fn burn_nft() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_burn(Burn::new().add_nft(nft_id_2)) @@ -369,6 +373,7 @@ fn missing_input_for_nft_output() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -412,6 +417,7 @@ fn missing_input_for_nft_output_but_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -476,6 +482,7 @@ fn nft_in_output_and_sender() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -526,6 +533,7 @@ fn missing_ed25519_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -569,6 +577,7 @@ fn missing_ed25519_issuer_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -612,6 +621,7 @@ fn missing_ed25519_issuer_transition() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -652,6 +662,7 @@ fn missing_account_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -695,6 +706,7 @@ fn missing_account_issuer_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -738,6 +750,7 @@ fn missing_account_issuer_transition() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -778,6 +791,7 @@ fn missing_nft_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -821,6 +835,7 @@ fn missing_nft_issuer_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -864,6 +879,7 @@ fn missing_nft_issuer_transition() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -916,6 +932,7 @@ fn increase_nft_amount() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -970,6 +987,7 @@ fn decrease_nft_amount() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1036,6 +1054,7 @@ fn prefer_basic_to_nft() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1091,6 +1110,7 @@ fn take_amount_from_nft_to_fund_basic() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1158,6 +1178,7 @@ fn nft_burn_should_validate_nft_sender() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_burn(Burn::new().add_nft(nft_id_1)) @@ -1213,6 +1234,7 @@ fn nft_burn_should_validate_nft_address() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_burn(Burn::new().add_nft(nft_id_1)) @@ -1256,6 +1278,7 @@ fn transitioned_zero_nft_id_no_longer_is_zero() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -1332,6 +1355,7 @@ fn changed_immutable_metadata() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); diff --git a/sdk/tests/client/input_selection/outputs.rs b/sdk/tests/client/input_selection/outputs.rs index 98551690e9..81a9ae7f9b 100644 --- a/sdk/tests/client/input_selection/outputs.rs +++ b/sdk/tests/client/input_selection/outputs.rs @@ -12,7 +12,7 @@ use pretty_assertions::assert_eq; use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic}, - ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, + ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, SLOT_INDEX, }; #[test] @@ -35,6 +35,7 @@ fn no_inputs() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -65,6 +66,7 @@ fn no_outputs() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -94,6 +96,7 @@ fn no_outputs_but_burn() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_2)) @@ -138,7 +141,7 @@ fn no_address_provided() { None, )]); - let selected = InputSelection::new(inputs, outputs, [], protocol_parameters).select(); + let selected = InputSelection::new(inputs, outputs, [], SLOT_INDEX + 1, protocol_parameters).select(); assert!(matches!(selected, Err(Error::NoAvailableInputsProvided))); } @@ -175,6 +178,7 @@ fn no_matching_address_provided() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -226,6 +230,7 @@ fn two_addresses_one_missing() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -286,6 +291,7 @@ fn two_addresses() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX + 1, protocol_parameters, ) .select() diff --git a/sdk/tests/client/input_selection/storage_deposit_return.rs b/sdk/tests/client/input_selection/storage_deposit_return.rs index 1ccec61b40..3cdd8bdc9e 100644 --- a/sdk/tests/client/input_selection/storage_deposit_return.rs +++ b/sdk/tests/client/input_selection/storage_deposit_return.rs @@ -13,7 +13,7 @@ use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic}, ACCOUNT_ID_1, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, - BECH32_ADDRESS_ED25519_2, + BECH32_ADDRESS_ED25519_2, SLOT_INDEX, }; #[test] @@ -48,6 +48,7 @@ fn sdruc_output_not_provided_no_remainder() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -112,6 +113,7 @@ fn sdruc_output_provided_no_remainder() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -153,6 +155,7 @@ fn sdruc_output_provided_remainder() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -217,6 +220,7 @@ fn two_sdrucs_to_the_same_address_both_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -281,6 +285,7 @@ fn two_sdrucs_to_the_same_address_one_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -346,6 +351,7 @@ fn two_sdrucs_to_different_addresses_both_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -416,6 +422,7 @@ fn two_sdrucs_to_different_addresses_one_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -469,6 +476,7 @@ fn insufficient_amount_because_of_sdruc() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select(); @@ -529,6 +537,7 @@ fn useless_sdruc_required_for_sender_feature() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -592,6 +601,7 @@ fn sdruc_required_non_ed25519_in_address_unlock() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() @@ -665,6 +675,7 @@ fn useless_sdruc_non_ed25519_in_address_unlock() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) .select() diff --git a/sdk/tests/client/input_selection/timelock.rs b/sdk/tests/client/input_selection/timelock.rs index d5a100cf6d..907d9c4c93 100644 --- a/sdk/tests/client/input_selection/timelock.rs +++ b/sdk/tests/client/input_selection/timelock.rs @@ -9,6 +9,7 @@ use pretty_assertions::assert_eq; use crate::client::{ build_inputs, build_outputs, unsorted_eq, Build::Basic, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, + SLOT_INDEX, }; #[test] @@ -43,9 +44,9 @@ fn one_output_timelock_not_expired() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select(); assert!(matches!(selected, Err(Error::NoAvailableInputsProvided))); @@ -83,9 +84,9 @@ fn timelock_equal_timestamp() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(200) .select() .unwrap(); @@ -137,9 +138,9 @@ fn two_outputs_one_timelock_expired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -192,9 +193,9 @@ fn two_outputs_one_timelocked_one_missing() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -235,9 +236,9 @@ fn one_output_timelock_expired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX + 1, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); diff --git a/sdk/tests/client/mod.rs b/sdk/tests/client/mod.rs index e65ca490d2..db6209fcbb 100644 --- a/sdk/tests/client/mod.rs +++ b/sdk/tests/client/mod.rs @@ -57,6 +57,7 @@ const BECH32_ADDRESS_ACCOUNT_1: &str = "rms1pqg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3 const BECH32_ADDRESS_ACCOUNT_2: &str = "rms1pq3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zymxrh9z"; // Corresponds to ACCOUNT_ID_2 const BECH32_ADDRESS_NFT_1: &str = "rms1zqg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zxddmy7"; // Corresponds to NFT_ID_1 const _BECH32_ADDRESS_NFT_2: &str = "rms1zq3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zynm6ctf"; // Corresponds to NFT_ID_2 +const SLOT_INDEX: SlotIndex = SlotIndex(10); #[derive(Debug, Clone)] enum Build<'a> { diff --git a/sdk/tests/client/signing/mod.rs b/sdk/tests/client/signing/mod.rs index dc38b1fd3d..761f7ff555 100644 --- a/sdk/tests/client/signing/mod.rs +++ b/sdk/tests/client/signing/mod.rs @@ -210,9 +210,9 @@ async fn all_combined() -> Result<()> { inputs.clone(), outputs.clone(), [ed25519_0, ed25519_1, ed25519_2], + slot_index, protocol_parameters.clone(), ) - .with_slot_index(slot_index) .select() .unwrap();