Skip to content

Commit

Permalink
Allow passing an index for test inputs IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Jan 10, 2024
1 parent 9540ac5 commit 4ff8ed7
Show file tree
Hide file tree
Showing 15 changed files with 2,938 additions and 2,440 deletions.
11 changes: 10 additions & 1 deletion sdk/src/types/block/rand/transaction.rs
Original file line number Diff line number Diff line change
@@ -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<SlotIndex>) -> TransactionId {
TransactionHash::new(rand_bytes_array()).into_transaction_id(slot_index.into())
}
13 changes: 6 additions & 7 deletions sdk/src/types/block/semantic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Loading

0 comments on commit 4ff8ed7

Please sign in to comment.