Skip to content

Commit f650d1b

Browse files
committed
test: Remove dev-dependency insta
Our (few) snapshot tests don't need the infrastructure `insta` offers. changelog: ignore
1 parent da8436e commit f650d1b

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

twenty-first/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ categories = ["cryptography", "mathematics"]
1919
blake3 = "1.5.5"
2020
bincode = "1.3.3"
2121
criterion = { version = "0.6", features = ["html_reports"] }
22-
insta = "1.42"
2322
proptest = "1.6"
2423
proptest-arbitrary-interop = "0.1"
2524
test-strategy = "0.4"

twenty-first/src/math/tip5.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,6 @@ pub(crate) mod tip5_tests {
735735
use std::hash::Hash;
736736
use std::ops::Mul;
737737

738-
use insta::assert_snapshot;
739738
use prop::sample::size_range;
740739
use proptest::prelude::*;
741740
use proptest_arbitrary_interop::arb;
@@ -1147,11 +1146,11 @@ pub(crate) mod tip5_tests {
11471146
}
11481147

11491148
#[test]
1150-
fn tip5_hasher_trait_test() {
1149+
fn tip5_hasher_trait_snapshot_test() {
11511150
let mut hasher = Tip5::init();
11521151
let data = b"hello world";
11531152
hasher.write(data);
1154-
assert_snapshot!(hasher.finish(), @"2267905471610932299");
1153+
assert_eq!(hasher.finish(), 2267905471610932299);
11551154
}
11561155

11571156
#[proptest]

twenty-first/src/util_types/mmr/mmr_accumulator.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,6 @@ impl<'a> Arbitrary<'a> for MmrAccumulator {
549549
mod accumulator_mmr_tests {
550550
use std::cmp;
551551

552-
use insta::assert_snapshot;
553552
use itertools::Itertools;
554553
use itertools::izip;
555554
use num_traits::ConstZero;
@@ -1029,19 +1028,31 @@ mod accumulator_mmr_tests {
10291028

10301029
#[test]
10311030
fn bag_peaks_snapshot() {
1031+
let snapshot = |mmr: MmrAccumulator| mmr.bag_peaks().to_hex();
10321032
let mut rng = StdRng::seed_from_u64(0x92ca758afeec6d29);
10331033

1034-
let empty_mmr = MmrAccumulator::new_from_leafs(vec![]);
1035-
assert_snapshot!(empty_mmr.bag_peaks().0[0], @"00941080798860502477");
1034+
let empty = MmrAccumulator::new_from_leafs(vec![]);
1035+
assert_eq!(
1036+
snapshot(empty),
1037+
"cd65052100640f0d27e5654f97c47e49899add2f265967ccbefee7264e9bc08f588542d9dc3d5ac5"
1038+
);
10361039

1037-
let one_leaf_mmr = MmrAccumulator::new_from_leafs(vec![rng.random()]);
1038-
assert_snapshot!(one_leaf_mmr.bag_peaks().0[0], @"16030278140236594076");
1040+
let one_leaf = MmrAccumulator::new_from_leafs(vec![rng.random()]);
1041+
assert_eq!(
1042+
snapshot(one_leaf),
1043+
"9cfb825709fd76de8c24daf437e1bd16a2ea512f2d2338ee417df51dae55905a49628d4f13a2f83e"
1044+
);
10391045

1040-
let two_leafs_mmr = MmrAccumulator::new_from_leafs(vec![rng.random()]);
1041-
assert_snapshot!(two_leafs_mmr.bag_peaks().0[0], @"09405464453414142998");
1046+
let two_leafs = MmrAccumulator::new_from_leafs(rng.random::<[_; 2]>().to_vec());
1047+
assert_eq!(
1048+
snapshot(two_leafs),
1049+
"20a22079d30e76c93215f54d986d414d657d4bd056fe8e9a38e87d432ce391cd1dab92f9b6d3442c"
1050+
);
10421051

1043-
let ten_peaks: [Digest; 10] = rng.random();
1044-
let ten_peak_mmr = MmrAccumulator::init(ten_peaks.to_vec(), 0b11_1111_1111);
1045-
assert_snapshot!(ten_peak_mmr.bag_peaks().0[0], @"03780783030734820370");
1052+
let ten_peaks = MmrAccumulator::init(rng.random::<[_; 10]>().to_vec(), 0b11_1111_1111);
1053+
assert_eq!(
1054+
snapshot(ten_peaks),
1055+
"42dbf8fcf51d4d8134f719ad9a3a9c621a141b3bc8d7941e8baf5919bceea120e6ecf6314e939b87"
1056+
);
10461057
}
10471058
}

0 commit comments

Comments
 (0)