Add test methods for modifying orchard shielded data and joinsplits (#2580)
Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
This commit is contained in:
parent
a1cec27871
commit
8f4c3b09ea
|
@ -638,7 +638,7 @@ impl Transaction {
|
||||||
|
|
||||||
// orchard
|
// orchard
|
||||||
|
|
||||||
/// Access the [`orchard::ShieldedData`] in this transaction, if there are any,
|
/// Access the [`orchard::ShieldedData`] in this transaction,
|
||||||
/// regardless of version.
|
/// regardless of version.
|
||||||
pub fn orchard_shielded_data(&self) -> Option<&orchard::ShieldedData> {
|
pub fn orchard_shielded_data(&self) -> Option<&orchard::ShieldedData> {
|
||||||
match self {
|
match self {
|
||||||
|
@ -656,6 +656,27 @@ impl Transaction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Modify the [`orchard::ShieldedData`] in this transaction,
|
||||||
|
/// regardless of version.
|
||||||
|
#[cfg(any(test, feature = "proptest-impl"))]
|
||||||
|
pub fn orchard_shielded_data_mut(&mut self) -> Option<&mut orchard::ShieldedData> {
|
||||||
|
match self {
|
||||||
|
Transaction::V5 {
|
||||||
|
orchard_shielded_data: Some(orchard_shielded_data),
|
||||||
|
..
|
||||||
|
} => Some(orchard_shielded_data),
|
||||||
|
|
||||||
|
Transaction::V1 { .. }
|
||||||
|
| Transaction::V2 { .. }
|
||||||
|
| Transaction::V3 { .. }
|
||||||
|
| Transaction::V4 { .. }
|
||||||
|
| Transaction::V5 {
|
||||||
|
orchard_shielded_data: None,
|
||||||
|
..
|
||||||
|
} => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Iterate over the [`orchard::Action`]s in this transaction, if there are any,
|
/// Iterate over the [`orchard::Action`]s in this transaction, if there are any,
|
||||||
/// regardless of version.
|
/// regardless of version.
|
||||||
pub fn orchard_actions(&self) -> impl Iterator<Item = &orchard::Action> {
|
pub fn orchard_actions(&self) -> impl Iterator<Item = &orchard::Action> {
|
||||||
|
@ -690,7 +711,8 @@ impl Transaction {
|
||||||
.map(|orchard_shielded_data| orchard_shielded_data.flags)
|
.map(|orchard_shielded_data| orchard_shielded_data.flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return if the transaction has any Orchard shielded data.
|
/// Return if the transaction has any Orchard shielded data,
|
||||||
|
/// regardless of version.
|
||||||
pub fn has_orchard_shielded_data(&self) -> bool {
|
pub fn has_orchard_shielded_data(&self) -> bool {
|
||||||
self.orchard_shielded_data().is_some()
|
self.orchard_shielded_data().is_some()
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,13 @@ impl<P: ZkSnarkProof> JoinSplitData<P> {
|
||||||
std::iter::once(&self.first).chain(self.rest.iter())
|
std::iter::once(&self.first).chain(self.rest.iter())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Modify the [`JoinSplit`]s in `self`,
|
||||||
|
/// in the order they appear in the transaction.
|
||||||
|
#[cfg(any(test, feature = "proptest-impl"))]
|
||||||
|
pub fn joinsplits_mut(&mut self) -> impl Iterator<Item = &mut JoinSplit<P>> {
|
||||||
|
std::iter::once(&mut self.first).chain(self.rest.iter_mut())
|
||||||
|
}
|
||||||
|
|
||||||
/// Iterate over the [`Nullifier`]s in `self`.
|
/// Iterate over the [`Nullifier`]s in `self`.
|
||||||
pub fn nullifiers(&self) -> impl Iterator<Item = &Nullifier> {
|
pub fn nullifiers(&self) -> impl Iterator<Item = &Nullifier> {
|
||||||
self.joinsplits()
|
self.joinsplits()
|
||||||
|
|
Loading…
Reference in New Issue