-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e5768d
commit 20fec99
Showing
8 changed files
with
67 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/signing/petition_types/petition_factors_types/factor_source_referencing.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
mod maybe_signed_transactions; | ||
mod petition_transaction_outcome; | ||
mod sign_with_factors_outcome; | ||
mod signatures_outcome; | ||
|
||
pub use maybe_signed_transactions::*; | ||
pub(crate) use petition_transaction_outcome::*; | ||
pub use sign_with_factors_outcome::*; | ||
pub use signatures_outcome::*; |
54 changes: 54 additions & 0 deletions
54
src/signing/signatures_outcome_types/petition_transaction_outcome.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use crate::prelude::*; | ||
|
||
/// The outcome of collecting signatures for a specific | ||
/// transasction - either valid or invalid - and a | ||
/// set of collected signatues (might be empty) and | ||
/// a set of neglected factors (might be empty). | ||
#[derive(Clone, PartialEq, Eq)] | ||
pub struct PetitionTransactionOutcome { | ||
intent_hash: IntentHash, | ||
pub transaction_valid: bool, | ||
pub signatures: IndexSet<HDSignature>, | ||
pub neglected_factors: IndexSet<NeglectedFactor>, | ||
} | ||
|
||
impl PetitionTransactionOutcome { | ||
/// # Panics | ||
/// Panics if the intent hash in any signatures does not | ||
/// match `intent_hash` | ||
pub fn new( | ||
transaction_valid: bool, | ||
intent_hash: IntentHash, | ||
signatures: IndexSet<HDSignature>, | ||
neglected_factors: IndexSet<NeglectedFactor>, | ||
) -> Self { | ||
assert!( | ||
signatures.iter().all(|s| *s.intent_hash() == intent_hash), | ||
"Discprenacy! Mismatching intent hash found in a signature." | ||
); | ||
Self { | ||
intent_hash, | ||
transaction_valid, | ||
signatures, | ||
neglected_factors, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
type Sut = PetitionTransactionOutcome; | ||
|
||
#[test] | ||
#[should_panic(expected = "Discprenacy! Mismatching intent hash found in a signature.")] | ||
fn panic() { | ||
Sut::new( | ||
true, | ||
IntentHash::sample(), | ||
IndexSet::from_iter([HDSignature::sample_other()]), | ||
IndexSet::new(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters