From 7277092af44f44f59bdb6326561b0b47416cc085 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 20 Jan 2025 15:28:06 +1100 Subject: [PATCH] Remove mutagen Back in 2022 we elected to use `mutagen` for mutation testing. Since then `cargo mutants` has progressed to a point where we would now like to use it instead. Remove all the `mutagen` stuff and update the lock files. Close: #2829 --- Cargo-minimal.lock | 47 ---------------------- Cargo-recent.lock | 62 +---------------------------- bitcoin/Cargo.toml | 3 -- bitcoin/src/pow.rs | 23 ----------- primitives/Cargo.toml | 3 -- primitives/src/locktime/absolute.rs | 4 -- primitives/src/locktime/relative.rs | 7 ---- 7 files changed, 2 insertions(+), 147 deletions(-) diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock index de123e13f..5e47891e0 100644 --- a/Cargo-minimal.lock +++ b/Cargo-minimal.lock @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "anyhow" -version = "1.0.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" - [[package]] name = "arbitrary" version = "1.4.1" @@ -68,7 +62,6 @@ dependencies = [ "bitcoinconsensus", "hex-conservative 0.3.0", "hex_lit", - "mutagen", "ordered", "secp256k1", "serde", @@ -118,7 +111,6 @@ dependencies = [ "bitcoin-units", "bitcoin_hashes 0.16.0", "hex-conservative 0.3.0", - "mutagen", "ordered", "serde", "serde_json", @@ -242,12 +234,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -[[package]] -name = "json" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" - [[package]] name = "lazy_static" version = "1.4.0" @@ -269,39 +255,6 @@ dependencies = [ "libc", ] -[[package]] -name = "mutagen" -version = "0.2.0" -source = "git+https://github.com/llogiq/mutagen#a6377c4c3f360afeb7a287c1c17e4b69456d5f53" -dependencies = [ - "mutagen-core", - "mutagen-transform", -] - -[[package]] -name = "mutagen-core" -version = "0.2.0" -source = "git+https://github.com/llogiq/mutagen#a6377c4c3f360afeb7a287c1c17e4b69456d5f53" -dependencies = [ - "anyhow", - "json", - "lazy_static", - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn", -] - -[[package]] -name = "mutagen-transform" -version = "0.2.0" -source = "git+https://github.com/llogiq/mutagen#a6377c4c3f360afeb7a287c1c17e4b69456d5f53" -dependencies = [ - "mutagen-core", - "proc-macro2", -] - [[package]] name = "ordered" version = "0.4.0" diff --git a/Cargo-recent.lock b/Cargo-recent.lock index b9ed4db00..47641c992 100644 --- a/Cargo-recent.lock +++ b/Cargo-recent.lock @@ -2,12 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "anyhow" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" - [[package]] name = "arbitrary" version = "1.4.1" @@ -67,7 +61,6 @@ dependencies = [ "bitcoinconsensus", "hex-conservative 0.3.0", "hex_lit", - "mutagen", "ordered", "secp256k1", "serde", @@ -117,7 +110,6 @@ dependencies = [ "bitcoin-units", "bitcoin_hashes 0.16.0", "hex-conservative 0.3.0", - "mutagen", "ordered", "serde", "serde_json", @@ -244,12 +236,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "json" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" - [[package]] name = "lazy_static" version = "1.5.0" @@ -277,39 +263,6 @@ dependencies = [ "libc", ] -[[package]] -name = "mutagen" -version = "0.2.0" -source = "git+https://github.com/llogiq/mutagen#a6377c4c3f360afeb7a287c1c17e4b69456d5f53" -dependencies = [ - "mutagen-core", - "mutagen-transform", -] - -[[package]] -name = "mutagen-core" -version = "0.2.0" -source = "git+https://github.com/llogiq/mutagen#a6377c4c3f360afeb7a287c1c17e4b69456d5f53" -dependencies = [ - "anyhow", - "json", - "lazy_static", - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn 1.0.109", -] - -[[package]] -name = "mutagen-transform" -version = "0.2.0" -source = "git+https://github.com/llogiq/mutagen#a6377c4c3f360afeb7a287c1c17e4b69456d5f53" -dependencies = [ - "mutagen-core", - "proc-macro2", -] - [[package]] name = "ordered" version = "0.4.0" @@ -432,7 +385,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn", ] [[package]] @@ -462,17 +415,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.79" @@ -514,5 +456,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn", ] diff --git a/bitcoin/Cargo.toml b/bitcoin/Cargo.toml index fd6e61649..cf0575029 100644 --- a/bitcoin/Cargo.toml +++ b/bitcoin/Cargo.toml @@ -49,9 +49,6 @@ serde_test = "1.0.19" bincode = "1.3.1" hex_lit = "0.1.1" -[target.'cfg(mutate)'.dev-dependencies] -mutagen = { git = "https://github.com/llogiq/mutagen" } - [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] diff --git a/bitcoin/src/pow.rs b/bitcoin/src/pow.rs index 63a5c854a..e25319273 100644 --- a/bitcoin/src/pow.rs +++ b/bitcoin/src/pow.rs @@ -10,8 +10,6 @@ use core::{cmp, fmt}; use internals::impl_to_hex_from_lower_hex; use io::{BufRead, Write}; -#[cfg(all(test, mutate))] -use mutagen::mutate; use units::parse::{self, ParseIntError, PrefixedHexError, UnprefixedHexError}; use crate::block::{BlockHash, Header}; @@ -218,7 +216,6 @@ impl Target { /// /// Proof-of-work validity for a block requires the hash of the block to be less than or equal /// to the target. - #[cfg_attr(all(test, mutate), mutate)] pub fn is_met_by(&self, hash: BlockHash) -> bool { let hash = U256::from_le_bytes(hash.to_byte_array()); hash <= self.0 @@ -255,7 +252,6 @@ impl Target { /// /// [max]: Target::max /// [target]: crate::block::HeaderExt::target - #[cfg_attr(all(test, mutate), mutate)] pub fn difficulty(&self, params: impl AsRef) -> u128 { // Panic here may be eaiser to debug than during the actual division. assert_ne!(self.0, U256::ZERO, "divide by zero"); @@ -274,7 +270,6 @@ impl Target { /// Panics if `self` is zero (divide by zero). /// /// [`difficulty`]: Target::difficulty - #[cfg_attr(all(test, mutate), mutate)] pub fn difficulty_float(&self, params: impl AsRef) -> f64 { // We want to explicitly panic to be uniform with `difficulty()` // (float division by zero does not panic). @@ -499,7 +494,6 @@ impl U256 { } /// Constructs a new `U256` from a big-endian array of `u8`s. - #[cfg_attr(all(test, mutate), mutate)] fn from_be_bytes(a: [u8; 32]) -> U256 { let (high, low) = split_in_half(a); let big = u128::from_be_bytes(high); @@ -508,7 +502,6 @@ impl U256 { } /// Constructs a new `U256` from a little-endian array of `u8`s. - #[cfg_attr(all(test, mutate), mutate)] fn from_le_bytes(a: [u8; 32]) -> U256 { let (high, low) = split_in_half(a); let little = u128::from_le_bytes(high); @@ -517,7 +510,6 @@ impl U256 { } /// Converts `U256` to a big-endian array of `u8`s. - #[cfg_attr(all(test, mutate), mutate)] fn to_be_bytes(self) -> [u8; 32] { let mut out = [0; 32]; out[..16].copy_from_slice(&self.0.to_be_bytes()); @@ -526,7 +518,6 @@ impl U256 { } /// Converts `U256` to a little-endian array of `u8`s. - #[cfg_attr(all(test, mutate), mutate)] fn to_le_bytes(self) -> [u8; 32] { let mut out = [0; 32]; out[..16].copy_from_slice(&self.1.to_le_bytes()); @@ -558,13 +549,10 @@ impl U256 { ret.wrapping_inc() } - #[cfg_attr(all(test, mutate), mutate)] fn is_zero(&self) -> bool { self.0 == 0 && self.1 == 0 } - #[cfg_attr(all(test, mutate), mutate)] fn is_one(&self) -> bool { self.0 == 0 && self.1 == 1 } - #[cfg_attr(all(test, mutate), mutate)] fn is_max(&self) -> bool { self.0 == u128::MAX && self.1 == u128::MAX } /// Returns the low 32 bits. @@ -587,7 +575,6 @@ impl U256 { } /// Returns the least number of bits needed to represent the number. - #[cfg_attr(all(test, mutate), mutate)] fn bits(&self) -> u32 { if self.0 > 0 { 256 - self.0.leading_zeros() @@ -602,9 +589,6 @@ impl U256 { /// /// The multiplication result along with a boolean indicating whether an arithmetic overflow /// occurred. If an overflow occurred then the wrapped value is returned. - // mutagen false pos mul_u64: replace `|` with `^` (XOR is same as OR when combined with <<) - // mutagen false pos mul_u64: replace `|` with `^` - #[cfg_attr(all(test, mutate), mutate)] fn mul_u64(self, rhs: u64) -> (U256, bool) { let mut carry: u128 = 0; let mut split_le = @@ -632,7 +616,6 @@ impl U256 { /// # Panics /// /// If `rhs` is zero. - #[cfg_attr(all(test, mutate), mutate)] fn div_rem(self, rhs: Self) -> (Self, Self) { let mut sub_copy = self; let mut shift_copy = rhs; @@ -672,7 +655,6 @@ impl U256 { /// Returns a tuple of the addition along with a boolean indicating whether an arithmetic /// overflow would occur. If an overflow would have occurred then the wrapped value is returned. #[must_use = "this returns the result of the operation, without modifying the original"] - #[cfg_attr(all(test, mutate), mutate)] fn overflowing_add(self, rhs: Self) -> (Self, bool) { let mut ret = U256::ZERO; let mut ret_overflow = false; @@ -697,7 +679,6 @@ impl U256 { /// Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic /// overflow would occur. If an overflow would have occurred then the wrapped value is returned. #[must_use = "this returns the result of the operation, without modifying the original"] - #[cfg_attr(all(test, mutate), mutate)] fn overflowing_sub(self, rhs: Self) -> (Self, bool) { let ret = self.wrapping_add(!rhs).wrapping_add(Self::ONE); let overflow = rhs > self; @@ -710,7 +691,6 @@ impl U256 { /// indicating whether an arithmetic overflow would occur. If an /// overflow would have occurred then the wrapped value is returned. #[must_use = "this returns the result of the operation, without modifying the original"] - #[cfg_attr(all(test, mutate), mutate)] fn overflowing_mul(self, rhs: Self) -> (Self, bool) { let mut ret = U256::ZERO; let mut ret_overflow = false; @@ -758,7 +738,6 @@ impl U256 { /// Returns `self` incremented by 1 wrapping around at the boundary of the type. #[must_use = "this returns the result of the increment, without modifying the original"] - #[cfg_attr(all(test, mutate), mutate)] fn wrapping_inc(&self) -> U256 { let mut ret = U256::ZERO; @@ -778,7 +757,6 @@ impl U256 { /// restricted to the range of the type, rather than the bits shifted out of the LHS being /// returned to the other end. We do not currently support `rotate_left`. #[must_use = "this returns the result of the operation, without modifying the original"] - #[cfg_attr(all(test, mutate), mutate)] fn wrapping_shl(self, rhs: u32) -> Self { let shift = rhs & 0x000000ff; @@ -805,7 +783,6 @@ impl U256 { /// restricted to the range of the type, rather than the bits shifted out of the LHS being /// returned to the other end. We do not currently support `rotate_right`. #[must_use = "this returns the result of the operation, without modifying the original"] - #[cfg_attr(all(test, mutate), mutate)] fn wrapping_shr(self, rhs: u32) -> Self { let shift = rhs & 0x000000ff; diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 199a9d808..a44c42c6e 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -36,9 +36,6 @@ serde = { version = "1.0.103", default-features = false, features = ["derive", " serde_json = "1.0.0" bincode = "1.3.1" -[target.'cfg(mutate)'.dev-dependencies] -mutagen = { git = "https://github.com/llogiq/mutagen" } - [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] diff --git a/primitives/src/locktime/absolute.rs b/primitives/src/locktime/absolute.rs index e54dae56d..02196da7a 100644 --- a/primitives/src/locktime/absolute.rs +++ b/primitives/src/locktime/absolute.rs @@ -10,8 +10,6 @@ use core::fmt; #[cfg(feature = "arbitrary")] use arbitrary::{Arbitrary, Unstructured}; -#[cfg(all(test, mutate))] -use mutagen::mutate; use units::parse::{self, PrefixedHexError, UnprefixedHexError}; #[cfg(all(doc, feature = "alloc"))] @@ -214,7 +212,6 @@ impl LockTime { /// } /// ```` #[inline] - #[cfg_attr(all(test, mutate), mutate)] pub fn is_satisfied_by(&self, height: Height, time: Time) -> bool { use LockTime::*; @@ -244,7 +241,6 @@ impl LockTime { /// assert!(lock_time.is_implied_by(check)); /// ``` #[inline] - #[cfg_attr(all(test, mutate), mutate)] pub fn is_implied_by(&self, other: LockTime) -> bool { use LockTime::*; diff --git a/primitives/src/locktime/relative.rs b/primitives/src/locktime/relative.rs index 98b4efe1c..7e8d968e8 100644 --- a/primitives/src/locktime/relative.rs +++ b/primitives/src/locktime/relative.rs @@ -9,9 +9,6 @@ use core::cmp::Ordering; use core::{cmp, convert, fmt}; -#[cfg(all(test, mutate))] -use mutagen::mutate; - use crate::Sequence; #[cfg(all(doc, feature = "alloc"))] use crate::{relative, TxIn}; @@ -177,7 +174,6 @@ impl LockTime { /// assert!(lock.is_satisfied_by(current_height(), current_time())); /// ``` #[inline] - #[cfg_attr(all(test, mutate), mutate)] pub fn is_satisfied_by(&self, h: Height, t: Time) -> bool { if let Ok(true) = self.is_satisfied_by_height(h) { true @@ -216,7 +212,6 @@ impl LockTime { /// assert!(satisfied); /// ``` #[inline] - #[cfg_attr(all(test, mutate), mutate)] pub fn is_implied_by(&self, other: LockTime) -> bool { use LockTime::*; @@ -258,7 +253,6 @@ impl LockTime { /// assert!(lock.is_satisfied_by_height(Height::from(required_height + 1)).expect("a height")); /// ``` #[inline] - #[cfg_attr(all(test, mutate), mutate)] pub fn is_satisfied_by_height(&self, height: Height) -> Result { use LockTime::*; @@ -285,7 +279,6 @@ impl LockTime { /// assert!(lock.is_satisfied_by_time(Time::from_512_second_intervals(intervals + 10)).expect("a time")); /// ``` #[inline] - #[cfg_attr(all(test, mutate), mutate)] pub fn is_satisfied_by_time(&self, time: Time) -> Result { use LockTime::*;