Skip to content

Commit

Permalink
Remove mutagen
Browse files Browse the repository at this point in the history
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: rust-bitcoin#2829
  • Loading branch information
tcharding committed Jan 20, 2025
1 parent 274205e commit 7277092
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 147 deletions.
47 changes: 0 additions & 47 deletions Cargo-minimal.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -68,7 +62,6 @@ dependencies = [
"bitcoinconsensus",
"hex-conservative 0.3.0",
"hex_lit",
"mutagen",
"ordered",
"secp256k1",
"serde",
Expand Down Expand Up @@ -118,7 +111,6 @@ dependencies = [
"bitcoin-units",
"bitcoin_hashes 0.16.0",
"hex-conservative 0.3.0",
"mutagen",
"ordered",
"serde",
"serde_json",
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
62 changes: 2 additions & 60 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -67,7 +61,6 @@ dependencies = [
"bitcoinconsensus",
"hex-conservative 0.3.0",
"hex_lit",
"mutagen",
"ordered",
"secp256k1",
"serde",
Expand Down Expand Up @@ -117,7 +110,6 @@ dependencies = [
"bitcoin-units",
"bitcoin_hashes 0.16.0",
"hex-conservative 0.3.0",
"mutagen",
"ordered",
"serde",
"serde_json",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -432,7 +385,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn",
]

[[package]]
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -514,5 +456,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.79",
"syn",
]
3 changes: 0 additions & 3 deletions bitcoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
23 changes: 0 additions & 23 deletions bitcoin/src/pow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Params>) -> u128 {
// Panic here may be eaiser to debug than during the actual division.
assert_ne!(self.0, U256::ZERO, "divide by zero");
Expand All @@ -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<Params>) -> f64 {
// We want to explicitly panic to be uniform with `difficulty()`
// (float division by zero does not panic).
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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.
Expand All @@ -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()
Expand All @@ -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 =
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand Down
3 changes: 0 additions & 3 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 0 additions & 4 deletions primitives/src/locktime/absolute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down Expand Up @@ -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::*;

Expand Down Expand Up @@ -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::*;

Expand Down
Loading

0 comments on commit 7277092

Please sign in to comment.