Skip to content

Commit

Permalink
Remove impls of {PartialEq, Eq} for `zcash_primitives::transaction:…
Browse files Browse the repository at this point in the history
…:builder::Error`

Co-authored-by: Jack Grigg <jack@electriccoin.co>
  • Loading branch information
2 people authored and nuttycom committed Jun 23, 2023
1 parent 06a7849 commit dce8676
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
8 changes: 6 additions & 2 deletions zcash_primitives/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this library adheres to Rust's notion of

## [Unreleased]

### Removed
- Removed `impl {PartialEq, Eq} for transaction::builder::Error` in favor
of using `assert_matches!` where error comparisons are required.

## [0.12.0] - 2023-06-06
### Added
- `zcash_primitives::transaction`:
Expand All @@ -27,7 +31,7 @@ and this library adheres to Rust's notion of
`incrementalmerkletree::Hashable` and `merkle_tree::HashSer`.
- The `Hashable` bound on the `Node` parameter to the `IncrementalWitness`
type has been removed.
- `sapling::SAPLING_COMMITMENT_TREE_DEPTH_U8` and `sapling::SAPLING_COMMITMENT_TREE_DEPTH`
- `sapling::SAPLING_COMMITMENT_TREE_DEPTH_U8` and `sapling::SAPLING_COMMITMENT_TREE_DEPTH`
have been removed; use `sapling::NOTE_COMMITMENT_TREE_DEPTH` instead.
- `merkle_tree::{CommitmentTree, IncrementalWitness, MerklePath}` have been removed in
favor of versions of these types that are now provided by the
Expand Down Expand Up @@ -89,7 +93,7 @@ and this library adheres to Rust's notion of
- The bounds on the `H` parameter to the following methods have changed:
- `merkle_tree::incremental::read_frontier_v0`
- `merkle_tree::incremental::read_auth_fragment_v1`
- The depth of the `merkle_tree::{CommitmentTree, IncrementalWitness, and MerklePath}`
- The depth of the `merkle_tree::{CommitmentTree, IncrementalWitness, and MerklePath}`
data types are now statically constrained using const generic type parameters.
- `transaction::fees::fixed::FeeRule::standard()` now uses the ZIP 317 minimum fee
(10000 zatoshis rather than 1000 zatoshis) as the fixed fee. To be compliant with
Expand Down
25 changes: 12 additions & 13 deletions zcash_primitives/src/transaction/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use crate::{
const DEFAULT_TX_EXPIRY_DELTA: u32 = 40;

/// Errors that can occur during transaction construction.
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug)]
pub enum Error<FeeError> {
/// Insufficient funds were provided to the transaction builder; the given
/// additional amount is required in order to construct the transaction.
Expand Down Expand Up @@ -543,6 +543,7 @@ mod testing {

#[cfg(test)]
mod tests {
use assert_matches::assert_matches;
use ff::Field;
use incrementalmerkletree::{frontier::CommitmentTree, witness::IncrementalWitness};
use rand_core::OsRng;
Expand Down Expand Up @@ -691,7 +692,7 @@ mod tests {

// Expect a binding signature error, because our inputs aren't valid, but this shows
// that a binding signature was attempted
assert_eq!(
assert_matches!(
builder.mock_build(),
Err(Error::SaplingBuild(sapling_builder::Error::BindingSig))
);
Expand Down Expand Up @@ -728,7 +729,7 @@ mod tests {
// 0.0001 t-ZEC fee
{
let builder = Builder::new(TEST_NETWORK, tx_height);
assert_eq!(
assert_matches!(
builder.mock_build(),
Err(Error::InsufficientFunds(MINIMUM_FEE))
);
Expand All @@ -750,11 +751,10 @@ mod tests {
MemoBytes::empty(),
)
.unwrap();
assert_eq!(
assert_matches!(
builder.mock_build(),
Err(Error::InsufficientFunds(
(Amount::from_i64(50000).unwrap() + MINIMUM_FEE).unwrap()
))
Err(Error::InsufficientFunds(expected)) if
expected == (Amount::from_i64(50000).unwrap() + MINIMUM_FEE).unwrap()
);
}

Expand All @@ -768,11 +768,10 @@ mod tests {
Amount::from_u64(50000).unwrap(),
)
.unwrap();
assert_eq!(
assert_matches!(
builder.mock_build(),
Err(Error::InsufficientFunds(
Err(Error::InsufficientFunds(expected)) if expected ==
(Amount::from_i64(50000).unwrap() + MINIMUM_FEE).unwrap()
))
);
}

Expand Down Expand Up @@ -808,9 +807,9 @@ mod tests {
Amount::from_u64(20000).unwrap(),
)
.unwrap();
assert_eq!(
assert_matches!(
builder.mock_build(),
Err(Error::InsufficientFunds(Amount::from_i64(1).unwrap()))
Err(Error::InsufficientFunds(expected)) if expected == Amount::from_i64(1).unwrap()
);
}

Expand Down Expand Up @@ -852,7 +851,7 @@ mod tests {
Amount::from_u64(20000).unwrap(),
)
.unwrap();
assert_eq!(
assert_matches!(
builder.mock_build(),
Err(Error::SaplingBuild(sapling_builder::Error::BindingSig))
)
Expand Down

0 comments on commit dce8676

Please sign in to comment.