mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-01-31 07:42:15 +00:00
use assert_matches!
This commit is contained in:
parent
bd8eea97b7
commit
27337f1bb0
@ -3,3 +3,6 @@ name = "zcash-mmr"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["NikVolf <nikvolf@gmail.com>"]
|
authors = ["NikVolf <nikvolf@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
assert_matches = "1.3.0"
|
@ -2,6 +2,8 @@
|
|||||||
//!
|
//!
|
||||||
//! To be used in zebra and via FFI bindings in zcashd
|
//! To be used in zebra and via FFI bindings in zcashd
|
||||||
|
|
||||||
|
#[cfg(test)] #[macro_use] extern crate assert_matches;
|
||||||
|
|
||||||
mod tree;
|
mod tree;
|
||||||
|
|
||||||
pub use tree::Tree;
|
pub use tree::Tree;
|
||||||
|
23
src/tree.rs
23
src/tree.rs
@ -378,8 +378,6 @@ mod tests {
|
|||||||
assert_eq!(append_tx.appended.len(), 1);
|
assert_eq!(append_tx.appended.len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use assert_matches below
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn truncate_simple() {
|
fn truncate_simple() {
|
||||||
let (mut tree, root) = generated(9);
|
let (mut tree, root) = generated(9);
|
||||||
@ -409,10 +407,7 @@ mod tests {
|
|||||||
// so (15) is truncated
|
// so (15) is truncated
|
||||||
// and new root, (14) is a stored one now
|
// and new root, (14) is a stored one now
|
||||||
|
|
||||||
match delete_tx.new_root {
|
assert_matches!(delete_tx.new_root, NodeLink::Stored(14));
|
||||||
NodeLink::Stored(14) => { /* ok */ },
|
|
||||||
_ => panic!("Root should be stored(14)")
|
|
||||||
}
|
|
||||||
assert_eq!(tree.len(), 15);
|
assert_eq!(tree.len(), 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,10 +440,8 @@ mod tests {
|
|||||||
// (0) (1) (3) (4) (7) (8) (10) (11) (15)
|
// (0) (1) (3) (4) (7) (8) (10) (11) (15)
|
||||||
|
|
||||||
// new root is generated
|
// new root is generated
|
||||||
match delete_tx.new_root {
|
|
||||||
NodeLink::Generated(_) => { /* ok */ },
|
assert_matches!(delete_tx.new_root, NodeLink::Generated(_));
|
||||||
_ => panic!("Root now should be generated")
|
|
||||||
}
|
|
||||||
|
|
||||||
// left is 14 and right is 15
|
// left is 14 and right is 15
|
||||||
let (left_root_child, right_root_child) = {
|
let (left_root_child, right_root_child) = {
|
||||||
@ -459,10 +452,12 @@ mod tests {
|
|||||||
root.node.right.expect("there should be right child for root"),
|
root.node.right.expect("there should be right child for root"),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
match (left_root_child, right_root_child) {
|
|
||||||
(NodeLink::Stored(14), NodeLink::Stored(15)) => { /* ok */ },
|
assert_matches!(
|
||||||
_ => panic!("Root should have s(14) and s(15) children")
|
(left_root_child, right_root_child),
|
||||||
};
|
(NodeLink::Stored(14), NodeLink::Stored(15))
|
||||||
|
);
|
||||||
|
|
||||||
// two stored nodes should leave us (leaf 16 and no longer needed node 17)
|
// two stored nodes should leave us (leaf 16 and no longer needed node 17)
|
||||||
assert_eq!(delete_tx.truncated, 2);
|
assert_eq!(delete_tx.truncated, 2);
|
||||||
assert_eq!(tree.len(), 16);
|
assert_eq!(tree.len(), 16);
|
||||||
|
Loading…
Reference in New Issue
Block a user