From ba091656ab61c04d4617e541152be569711173aa Mon Sep 17 00:00:00 2001 From: ASuciuX Date: Tue, 14 May 2024 18:54:47 +0300 Subject: [PATCH 1/5] add comments to functions for highlighting missing mutants --- Cargo.lock | 1 + clarity/src/vm/ast/parser/v1.rs | 10 ++++++++ clarity/src/vm/ast/parser/v2/mod.rs | 20 +++++++++++++++ clarity/src/vm/ast/sugar_expander/mod.rs | 10 ++++++++ clarity/src/vm/costs/mod.rs | 10 +++++--- clarity/src/vm/types/mod.rs | 12 ++++----- libsigner/Cargo.toml | 1 + libsigner/src/events.rs | 4 +++ pox-locking/Cargo.toml | 1 + pox-locking/src/events.rs | 3 +++ stackslib/Cargo.toml | 1 + stackslib/src/burnchains/db.rs | 3 +++ stackslib/src/burnchains/mod.rs | 3 +++ stackslib/src/chainstate/burn/db/sortdb.rs | 7 ++++++ .../chainstate/burn/operations/stack_stx.rs | 11 ++++++++ stackslib/src/chainstate/coordinator/mod.rs | 3 +++ stackslib/src/chainstate/stacks/boot/mod.rs | 15 +++++++++++ stackslib/src/chainstate/stacks/db/blocks.rs | 16 ++++++++++++ stackslib/src/chainstate/stacks/miner.rs | 25 +++++++++++++++++++ stackslib/src/main.rs | 2 ++ testnet/stacks-node/Cargo.toml | 1 + .../burnchains/bitcoin_regtest_controller.rs | 25 +++++++++++++++++++ testnet/stacks-node/src/config.rs | 7 ++++++ .../stacks-node/src/nakamoto_node/miner.rs | 12 +++++++++ testnet/stacks-node/src/neon_node.rs | 13 ++++++++++ testnet/stacks-node/src/tenure.rs | 4 +++ 26 files changed, 211 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa89992f8e..86c318f3b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2449,6 +2449,7 @@ name = "pox-locking" version = "2.4.0" dependencies = [ "clarity", + "mutants", "slog", "stacks-common", ] diff --git a/clarity/src/vm/ast/parser/v1.rs b/clarity/src/vm/ast/parser/v1.rs index 75c5ea2df9..65f9b66b11 100644 --- a/clarity/src/vm/ast/parser/v1.rs +++ b/clarity/src/vm/ast/parser/v1.rs @@ -508,6 +508,16 @@ fn handle_expression( } } +// TODO: #4587 create default for `SymbolicExpression`, then check if mutation tests are caught for these cases: +// ParseResult::from(vec![Default::default()]) +// ParseResult::from(vec![]) +// ParseResult::new() +// ParseResult::from_iter([vec![Default::default()]]) +// ParseResult::new(vec![Default::default()]) +// ParseResult::new(vec![]) +// ParseResult::from_iter([vec![]]) +// Or keep the skip and remove the comment +#[cfg_attr(test, mutants::skip)] pub fn parse_lexed(input: Vec<(LexItem, u32, u32)>) -> ParseResult> { let mut parse_stack = Vec::new(); diff --git a/clarity/src/vm/ast/parser/v2/mod.rs b/clarity/src/vm/ast/parser/v2/mod.rs index a7ba4eb3c8..8f039eedb1 100644 --- a/clarity/src/vm/ast/parser/v2/mod.rs +++ b/clarity/src/vm/ast/parser/v2/mod.rs @@ -206,6 +206,16 @@ impl<'a> Parser<'a> { } } + // TODO: #4587 create default for `SymbolicExpression`, then check if mutation tests are caught for these cases: + // ParseResult::from_iter([Some(Default::default())]) + // ParseResult::new(None) + // ParseResult::from_iter([None]) + // ParseResult::new(Some(Default::default())) + // ParseResult::from(None) + // ParseResult::from(Some(Default::default())) + // ParseResult::new() + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// Process a new child node for an AST expression that is open and waiting for children nodes. For example, /// a list or tuple expression that is waiting for child expressions. /// @@ -275,6 +285,16 @@ impl<'a> Parser<'a> { } } + // TODO: #4587 create default for `SymbolicExpression`, then check if mutation tests are caught for these cases: + // ParseResult::from_iter([Some(Default::default())]) + // ParseResult::new(None) + // ParseResult::from_iter([None]) + // ParseResult::new(Some(Default::default())) + // ParseResult::from(None) + // ParseResult::from(Some(Default::default())) + // ParseResult::new() + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] fn handle_open_tuple( &mut self, open_tuple: &mut OpenTuple, diff --git a/clarity/src/vm/ast/sugar_expander/mod.rs b/clarity/src/vm/ast/sugar_expander/mod.rs index 0f28093932..01528700fa 100644 --- a/clarity/src/vm/ast/sugar_expander/mod.rs +++ b/clarity/src/vm/ast/sugar_expander/mod.rs @@ -58,6 +58,16 @@ impl SugarExpander { Ok(()) } + // TODO: #4587 create default for `SymbolicExpression`, then check if mutation tests are caught for these cases: + // ParseResult::from(vec![Default::default()]) + // ParseResult::from(vec![]) + // ParseResult::new() + // ParseResult::from_iter([vec![Default::default()]]) + // ParseResult::new(vec![Default::default()]) + // ParseResult::new(vec![]) + // ParseResult::from_iter([vec![]]) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] pub fn transform( &self, pre_exprs_iter: PreExpressionsDrain, diff --git a/clarity/src/vm/costs/mod.rs b/clarity/src/vm/costs/mod.rs index 744b605691..cca71cb55c 100644 --- a/clarity/src/vm/costs/mod.rs +++ b/clarity/src/vm/costs/mod.rs @@ -783,12 +783,12 @@ impl LimitedCostTracker { } impl TrackerData { + // TODO: #4587 add test for Err cases + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// `apply_updates` - tells this function to look for any changes in the cost voting contract /// which would need to be applied. if `false`, just load the last computed cost state in this /// fork. - /// TODO: #4587 add test for Err cases - /// Or keep the skip and remove the comment - #[cfg_attr(test, mutants::skip)] fn load_costs(&mut self, clarity_db: &mut ClarityDatabase, apply_updates: bool) -> Result<()> { clarity_db.begin(); let epoch_id = clarity_db @@ -958,6 +958,10 @@ fn parse_cost( } } +// TODO: #4587 create default for `ExecutionCost`, then check if mutation tests are caught for these case: +// Ok(Default::default()) +// Or keep the skip and remove the comment +#[cfg_attr(test, mutants::skip)] fn compute_cost( cost_tracker: &mut TrackerData, cost_function_reference: ClarityCostFunctionReference, diff --git a/clarity/src/vm/types/mod.rs b/clarity/src/vm/types/mod.rs index 46734dcc51..e8f3be42b4 100644 --- a/clarity/src/vm/types/mod.rs +++ b/clarity/src/vm/types/mod.rs @@ -1529,9 +1529,9 @@ impl TupleData { self.data_map.is_empty() } - ///TODO: #4587 create default for TupleData, then check if the mutation tests are caught for the case: - /// Ok((Default::default())) - /// Or keep the skip and remove the comment + // TODO: #4587 create default for TupleData, then check if the mutation tests are caught for the case: + // Ok((Default::default())) + // Or keep the skip and remove the comment #[cfg_attr(test, mutants::skip)] pub fn from_data(data: Vec<(ClarityName, Value)>) -> Result { let mut type_map = BTreeMap::new(); @@ -1549,9 +1549,9 @@ impl TupleData { Self::new(TupleTypeSignature::try_from(type_map)?, data_map) } - ///TODO: #4587 create default for TupleData, then check if the mutation tests are caught for the case: - /// Ok((Default::default())) - /// Or keep the skip and remove the comment + // TODO: #4587 create default for TupleData, then check if the mutation tests are caught for the case: + // Ok((Default::default())) + // Or keep the skip and remove the comment #[cfg_attr(test, mutants::skip)] pub fn from_data_typed( epoch: &StacksEpochId, diff --git a/libsigner/Cargo.toml b/libsigner/Cargo.toml index 7da9801674..2f86d48cf8 100644 --- a/libsigner/Cargo.toml +++ b/libsigner/Cargo.toml @@ -33,6 +33,7 @@ stackslib = { path = "../stackslib"} thiserror = "1.0" tiny_http = "0.12" wsts = { workspace = true } +mutants = "0.0.3" [dev-dependencies] mutants = "0.0.3" diff --git a/libsigner/src/events.rs b/libsigner/src/events.rs index 67eb970574..5de1c98f52 100644 --- a/libsigner/src/events.rs +++ b/libsigner/src/events.rs @@ -366,6 +366,10 @@ fn ack_dispatcher(request: HttpRequest) { }; } +// TODO: #4587 create default for `SignerEvent` and `EventError`, then check if mutation tests are caught for these case: +// Ok(Default::default()) +// Or keep the skip and remove the comment +#[cfg_attr(test, mutants::skip)] /// Process a stackerdb event from the node fn process_stackerdb_event( local_addr: Option, diff --git a/pox-locking/Cargo.toml b/pox-locking/Cargo.toml index fd2729048d..199a58d18e 100644 --- a/pox-locking/Cargo.toml +++ b/pox-locking/Cargo.toml @@ -22,6 +22,7 @@ path = "src/lib.rs" clarity = { package = "clarity", path = "../clarity" } stacks_common = { package = "stacks-common", path = "../stacks-common" } slog = { version = "2.5.2", features = [ "max_level_trace" ] } +mutants = "0.0.3" [features] slog_json = ["stacks_common/slog_json", "clarity/slog_json"] diff --git a/pox-locking/src/events.rs b/pox-locking/src/events.rs index 49d1ba90b2..2146a15688 100644 --- a/pox-locking/src/events.rs +++ b/pox-locking/src/events.rs @@ -105,6 +105,9 @@ fn create_event_info_aggregation_code(function_name: &str) -> String { ) } +// TODO: #4587 add tests for `String::new()` and `"xyzzy".into()` returning case. +// Or keep the skip and remove the comment +#[cfg_attr(test, mutants::skip)] /// Craft the code snippet to generate the method-specific `data` payload fn create_event_info_data_code( function_name: &str, diff --git a/stackslib/Cargo.toml b/stackslib/Cargo.toml index be75337115..7c254f0384 100644 --- a/stackslib/Cargo.toml +++ b/stackslib/Cargo.toml @@ -93,6 +93,7 @@ features = ["serde"] [dependencies.time] version = "0.2.23" features = ["std"] +mutants = "0.0.3" [dev-dependencies] assert-json-diff = "1.0.0" diff --git a/stackslib/src/burnchains/db.rs b/stackslib/src/burnchains/db.rs index 3171ec3c98..1c6d0d2c61 100644 --- a/stackslib/src/burnchains/db.rs +++ b/stackslib/src/burnchains/db.rs @@ -946,6 +946,9 @@ impl<'a> BurnchainDBTransaction<'a> { BurnchainDB::inner_get_canonical_chain_tip(&self.sql_tx) } + // TODO: #4587 add tests for `Ok(())` returning case + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// You'd only do this in network emergencies, where node operators are expected to declare an /// anchor block missing (or present). Ideally there'd be a smart contract somewhere for this. pub fn set_override_affirmation_map( diff --git a/stackslib/src/burnchains/mod.rs b/stackslib/src/burnchains/mod.rs index 23dc50f62c..5f47ddb5ed 100644 --- a/stackslib/src/burnchains/mod.rs +++ b/stackslib/src/burnchains/mod.rs @@ -468,6 +468,9 @@ impl PoxConstants { ) // total liquid supply is 40000000000000000 µSTX } + // TODO: #4587 create default for PoxConstants, then check if the mutation tests are caught: + // Default::default() + #[cfg_attr(test, mutants::skip)] pub fn regtest_default() -> PoxConstants { PoxConstants::new( 5, diff --git a/stackslib/src/chainstate/burn/db/sortdb.rs b/stackslib/src/chainstate/burn/db/sortdb.rs index e3802d6ec1..64ed6b9772 100644 --- a/stackslib/src/chainstate/burn/db/sortdb.rs +++ b/stackslib/src/chainstate/burn/db/sortdb.rs @@ -307,6 +307,10 @@ impl FromRow for LeaderBlockCommitOp { } impl FromRow for StackStxOp { + // TODO: #4587 create default for `StackStxOp`, then check if mutation tests are caught for these case: + // Ok(Default::default()) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] fn from_row<'a>(row: &'a Row) -> Result { let txid = Txid::from_column(row, "txid")?; let vtxindex: u32 = row.get_unwrap("vtxindex"); @@ -5128,6 +5132,9 @@ impl SortitionDB { query_row(conn, sql, args) } + // TODO: #4587 add test for the `None` case returning Ok(false) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// Are microblocks disabled by Epoch 2.5 at the height specified /// in `at_burn_height`? pub fn are_microblocks_disabled(conn: &DBConn, at_burn_height: u64) -> Result { diff --git a/stackslib/src/chainstate/burn/operations/stack_stx.rs b/stackslib/src/chainstate/burn/operations/stack_stx.rs index 20dca3187a..3e213e8811 100644 --- a/stackslib/src/chainstate/burn/operations/stack_stx.rs +++ b/stackslib/src/chainstate/burn/operations/stack_stx.rs @@ -181,6 +181,10 @@ impl StackStxOp { } } + // TODO: #4587 create default for `ParsedData`, then check if mutation tests are caught for these case: + // Some(Default::default()) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] fn parse_data(data: &Vec) -> Option { /* Wire format: @@ -271,6 +275,10 @@ impl StackStxOp { ) } + // TODO: #4587 create default for `StackStxOp` and `op_error`, then check if mutation tests are caught for these case: + // Ok(Default::default()) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// parse a StackStxOp /// `pox_sunset_ht` is the height at which PoX *disables* pub fn parse_from_tx( @@ -395,6 +403,9 @@ impl StacksMessageCodec for StackStxOp { } impl StackStxOp { + // TODO: #4587 add tests for `Ok(())` returning case. + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] pub fn check(&self) -> Result<(), op_error> { if self.stacked_ustx == 0 { warn!("Invalid StackStxOp, must have positive ustx"); diff --git a/stackslib/src/chainstate/coordinator/mod.rs b/stackslib/src/chainstate/coordinator/mod.rs index 96eae44641..c34eaaafab 100644 --- a/stackslib/src/chainstate/coordinator/mod.rs +++ b/stackslib/src/chainstate/coordinator/mod.rs @@ -2414,6 +2414,9 @@ impl< return false; } + // TODO: #4587,create default for BlockHeaderHash, then check if mutation tests are caught for these cases: + // Ok(Some(Default::default)) + #[cfg_attr(test, mutants::skip)] /// Handle a new burnchain block, optionally rolling back the canonical PoX sortition history /// and setting it up to be replayed in the event the network affirms a different history. If /// this happens, *and* if re-processing the new affirmed history is *blocked on* the diff --git a/stackslib/src/chainstate/stacks/boot/mod.rs b/stackslib/src/chainstate/stacks/boot/mod.rs index 06b448cd21..a5a3da7899 100644 --- a/stackslib/src/chainstate/stacks/boot/mod.rs +++ b/stackslib/src/chainstate/stacks/boot/mod.rs @@ -423,6 +423,9 @@ impl StacksChainState { result } + // TODO: #4587 create default for StacksTransactionEvent , then check if mutation tests are caught for these cases: + // Ok(vec![Default::default()]) + #[cfg_attr(test, mutants::skip)] /// Do all the necessary Clarity operations at the start of a PoX reward cycle. /// Currently, this just means applying any auto-unlocks to Stackers who qualified. /// @@ -435,6 +438,9 @@ impl StacksChainState { Self::handle_pox_cycle_missed_unlocks(clarity, cycle_number, cycle_info, &PoxVersions::Pox2) } + // TODO: #4587 create default for StacksTransactionEvent , then check if mutation tests are caught for these cases: + // Ok(vec![Default::default()]) + #[cfg_attr(test, mutants::skip)] /// Do all the necessary Clarity operations at the start of a PoX reward cycle. /// Currently, this just means applying any auto-unlocks to Stackers who qualified. /// @@ -447,6 +453,9 @@ impl StacksChainState { Self::handle_pox_cycle_missed_unlocks(clarity, cycle_number, cycle_info, &PoxVersions::Pox3) } + // TODO: #4587 create default for StacksTransactionEvent , then check if mutation tests are caught for these cases: + // Ok(vec![Default::default()]) + #[cfg_attr(test, mutants::skip)] /// Do all the necessary Clarity operations at the start of a PoX reward cycle. /// Currently, this just means applying any auto-unlocks to Stackers who qualified. /// @@ -460,6 +469,9 @@ impl StacksChainState { Ok(vec![]) } + // TODO: #4587 create default for StacksTransactionEvent , then check if mutation tests are caught for these cases: + // Ok(vec![Default::default()]) + #[cfg_attr(test, mutants::skip)] /// Do all the necessary Clarity operations at the start of a PoX reward cycle. /// Currently, this just means applying any auto-unlocks to Stackers who qualified. /// @@ -752,6 +764,9 @@ impl StacksChainState { Some(signer_set) } + // TODO: #4587 create default for RewardSet , then check if mutation tests are caught for these cases: + // Default::default() + #[cfg_attr(test, mutants::skip)] /// Given a threshold and set of registered addresses, return a reward set where /// every entry address has stacked more than the threshold, and addresses /// are repeated floor(stacked_amt / threshold) times. diff --git a/stackslib/src/chainstate/stacks/db/blocks.rs b/stackslib/src/chainstate/stacks/db/blocks.rs index dd70fcfb01..160fdcd74b 100644 --- a/stackslib/src/chainstate/stacks/db/blocks.rs +++ b/stackslib/src/chainstate/stacks/db/blocks.rs @@ -4132,6 +4132,10 @@ impl StacksChainState { Ok((applied, receipts)) } + // TODO: #4587 create default for `StacksTransactionReceipt`, then check if mutation tests are caught for these case: + // vec![Default::default()] + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// Process any Stacking-related bitcoin operations /// that haven't been processed in this Stacks fork yet. pub fn process_stacking_ops( @@ -4237,6 +4241,11 @@ impl StacksChainState { all_receipts } + // TODO: #4587 add test for `Ok(vec![])` returning case. + // TODO: #4587 create default for `Value`, then check if mutation tests are caught for these case: + // Ok(vec![Default::default()]) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] pub fn collect_pox_4_stacking_args(op: &StackStxOp) -> Result, String> { let signer_key = match op.signer_key { Some(signer_key) => match Value::buff_from(signer_key.as_bytes().to_vec()) { @@ -6021,6 +6030,13 @@ impl StacksChainState { Ok(next_microblocks) } + // TODO: #4587 add default for `StacksEpochReceipt` and `TransactionPayload`, then check if mutation tests are caught for these cases: + // Ok((None, Some(Default::default()))) + // Ok((Some(Default::default()), None)) + // Ok((Some(Default::default()), Some(Default::default()))) + // This is caught: Ok(None, None) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// Find and process the next staging block. /// Return the next chain tip if we processed this block, or None if we couldn't. /// Return a poison microblock transaction payload if the microblock stream contains a diff --git a/stackslib/src/chainstate/stacks/miner.rs b/stackslib/src/chainstate/stacks/miner.rs index f718a9fb36..516ceb8f34 100644 --- a/stackslib/src/chainstate/stacks/miner.rs +++ b/stackslib/src/chainstate/stacks/miner.rs @@ -170,6 +170,10 @@ pub struct BlockBuilderSettings { } impl BlockBuilderSettings { + // TODO: #4587 create default for BlockBuilderSettings, then check if mutation tests are caught for these case: + // Default::default() + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] pub fn limited() -> BlockBuilderSettings { BlockBuilderSettings { max_miner_time_ms: u64::MAX, @@ -179,6 +183,10 @@ impl BlockBuilderSettings { } } + // TODO: #4587 create default for BlockBuilderSettings, then check if mutation tests are caught for these case: + // Default::default() + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] pub fn max_value() -> BlockBuilderSettings { BlockBuilderSettings { max_miner_time_ms: u64::MAX, @@ -1793,6 +1801,10 @@ impl StacksBlockBuilder { } } + // TODO: #4587 create default for MinerEpochInfo, then check if mutation tests are caught for these case: + // Ok(Default::default()) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// This function should be called before `epoch_begin`. /// It loads the parent microblock stream, sets the parent microblock, and returns /// data necessary for `epoch_begin`. @@ -2047,6 +2059,10 @@ impl StacksBlockBuilder { Ok((block, size, cost, mblock_opt)) } + // TODO: #4587 create default for `StacksBlockBuilder`, then check if mutation tests are caught for these case: + // Ok(Default::default()) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// Create a block builder for mining pub fn make_block_builder( burnchain: &Burnchain, @@ -2101,6 +2117,10 @@ impl StacksBlockBuilder { Ok(builder) } + // TODO: #4587 create default for `StacksBlockBuilder`, then check if mutation tests are caught for these case: + // Ok(Default::default()) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// Create a block builder for regtest mining pub fn make_regtest_block_builder( burnchain: &Burnchain, @@ -2381,6 +2401,11 @@ impl StacksBlockBuilder { Ok((blocked, tx_events)) } + // TODO: #4587 create default for `StacksBlock` and `ExecutionCost`, then check if mutation tests are caught for these cases: + // Ok((Default::default(), Default::default(), 1)) + // Ok((Default::default(), Default::default(), 0)) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// Given access to the mempool, mine an anchored block with no more than the given execution cost. /// returns the assembled block, and the consumed execution budget. pub fn build_anchored_block( diff --git a/stackslib/src/main.rs b/stackslib/src/main.rs index bd441cc023..243f91e7c6 100644 --- a/stackslib/src/main.rs +++ b/stackslib/src/main.rs @@ -91,6 +91,7 @@ use stacks_common::util::secp256k1::{Secp256k1PrivateKey, Secp256k1PublicKey}; use stacks_common::util::vrf::VRFProof; use stacks_common::util::{get_epoch_time_ms, log, sleep_ms}; +#[cfg_attr(test, mutants::skip)] fn main() { let mut argv: Vec = env::args().collect(); if argv.len() < 2 { @@ -1332,6 +1333,7 @@ simulating a miner. } } +#[cfg_attr(test, mutants::skip)] fn tip_mine() { let argv: Vec = env::args().collect(); if argv.len() < 6 { diff --git a/testnet/stacks-node/Cargo.toml b/testnet/stacks-node/Cargo.toml index bceb484cd7..6c20f79dcd 100644 --- a/testnet/stacks-node/Cargo.toml +++ b/testnet/stacks-node/Cargo.toml @@ -31,6 +31,7 @@ wsts = { workspace = true } rand = { workspace = true } rand_core = { workspace = true } hashbrown = { workspace = true } +mutants = "0.0.3" [target.'cfg(not(any(target_os = "macos", target_os="windows", target_arch = "arm")))'.dependencies] tikv-jemallocator = {workspace = true} diff --git a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs index 8cf9ac82be..bb6a319651 100644 --- a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs +++ b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs @@ -125,6 +125,10 @@ pub fn addr2str(btc_addr: &BitcoinAddress) -> String { format!("{}", &btc_addr) } +// TODO: #4587 create default for `BurnchainParameters`, then check if mutation tests are caught for these case: +// Default::default() +// Or keep the skip and remove the comment +#[cfg_attr(test, mutants::skip)] pub fn burnchain_params_from_config(config: &BurnchainConfig) -> BurnchainParameters { let (network, _) = config.get_bitcoin_network(); let mut params = BurnchainParameters::from_params(&config.chain, &network) @@ -135,6 +139,10 @@ pub fn burnchain_params_from_config(config: &BurnchainConfig) -> BurnchainParame params } +// TODO: #4587 create default for `BitcoinIndexer`, then check if mutation tests are caught for these case: +// Default::default() +// Or keep the skip and remove the comment +#[cfg_attr(test, mutants::skip)] /// Helper method to create a BitcoinIndexer pub fn make_bitcoin_indexer( config: &Config, @@ -272,6 +280,10 @@ impl BitcoinRegtestController { BitcoinRegtestController::with_burnchain(config, coordinator_channel, None, None) } + // TODO: #4587 create default for `BitcoinRegtestController`, then check if mutation tests are caught for these case: + // Default::default() + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] pub fn with_burnchain( config: Config, coordinator_channel: Option, @@ -341,6 +353,10 @@ impl BitcoinRegtestController { } } + // TODO: #4587 create default for `BitcoinRegtestController`, then check if mutation tests are caught for these case: + // Default::default() + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// create a dummy bitcoin regtest controller. /// used just for submitting bitcoin ops. pub fn new_dummy(config: Config) -> Self { @@ -1242,6 +1258,7 @@ impl BitcoinRegtestController { Some(tx) } + #[cfg_attr(test, mutants::skip)] #[cfg(not(test))] fn build_stack_stx_tx( &mut self, @@ -1617,6 +1634,10 @@ impl BitcoinRegtestController { } } + // TODO: #4587 create default for `Transaction` and `UTXOSet`, then check if mutation tests are caught for these case: + // Some((Default::default(), Default::default())) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] fn prepare_tx( &mut self, epoch_id: StacksEpochId, @@ -1984,6 +2005,10 @@ impl BitcoinRegtestController { self.config.miner.segwit = segwit; } + // TODO: #4587 create default for `SerializedTx`, then check if mutation tests are caught for these case: + // Some(Default::default()) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] pub fn make_operation_tx( &mut self, epoch_id: StacksEpochId, diff --git a/testnet/stacks-node/src/config.rs b/testnet/stacks-node/src/config.rs index 60b60cf9f7..3a33a11083 100644 --- a/testnet/stacks-node/src/config.rs +++ b/testnet/stacks-node/src/config.rs @@ -827,6 +827,10 @@ impl Config { } } + // TODO: #4587 create default for `StacksEpoch`, then check if mutation tests are caught for these case: + // Ok(vec![Default::default()]) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] fn make_epochs( conf_epochs: &[StacksEpochConfigFile], burn_mode: &str, @@ -1274,6 +1278,9 @@ impl Config { } } + // TODO: #4587 create default for BlockBuilderSettings, then check if mutation tests are caught for these case: + // Default::default() + #[cfg_attr(test, mutants::skip)] pub fn make_block_builder_settings( &self, attempt: u64, diff --git a/testnet/stacks-node/src/nakamoto_node/miner.rs b/testnet/stacks-node/src/nakamoto_node/miner.rs index 4b793d0106..1d9a2415d2 100644 --- a/testnet/stacks-node/src/nakamoto_node/miner.rs +++ b/testnet/stacks-node/src/nakamoto_node/miner.rs @@ -576,6 +576,10 @@ impl BlockMinerThread { tx_signer.get_tx().unwrap() } + // TODO: #4587 create default for `NakamotoNodeError` and `ParentStacksBlockInfo`, then check if mutation tests are caught for these case: + // Ok(Default::default()) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// Load up the parent block info for mining. /// If there's no parent because this is the first block, then return the genesis block's info. /// If we can't find the parent in the DB but we expect one, return None. @@ -679,6 +683,10 @@ impl BlockMinerThread { Some(vrf_proof) } + // TODO: #4587 create default for `NakamotoBlock` and `NakamotoNodeError`, then check if mutation tests are caught for these case: + // Ok(Default::default()) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// Try to mine a Stacks block by assembling one from mempool transactions and sending a /// burnchain block-commit transaction. If we succeed, then return the assembled block. fn mine_block(&mut self, stackerdbs: &StackerDBs) -> Result { @@ -832,6 +840,10 @@ impl BlockMinerThread { } impl ParentStacksBlockInfo { + // TODO: #4587 craete default for `NakamotoBlock` and `NakamotoNodeError`, then check if mutation tests are caught for these case: + // Ok(Default::default()) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// Determine where in the set of forks to attempt to mine the next anchored block. /// `mine_tip_ch` and `mine_tip_bhh` identify the parent block on top of which to mine. /// `check_burn_block` identifies what we believe to be the burn chain's sortition history tip. diff --git a/testnet/stacks-node/src/neon_node.rs b/testnet/stacks-node/src/neon_node.rs index 28e6552771..749fc9e1fc 100644 --- a/testnet/stacks-node/src/neon_node.rs +++ b/testnet/stacks-node/src/neon_node.rs @@ -1507,6 +1507,11 @@ impl BlockMinerThread { Some((*best_tip).clone()) } + // TODO: #4587 create default for `ParentStacksBlockInfo`, then check if mutation tests are caught for these cases: + // (Some(Default::default()), true) + // (Some(Default::default()), false) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// Load up the parent block info for mining. /// If there's no parent because this is the first block, then return the genesis block's info. /// If we can't find the parent in the DB but we expect one, return None. @@ -2222,6 +2227,10 @@ impl BlockMinerThread { return false; } + // TODO: #4587 create default for `MinerThreadResult`, then check if mutation tests are caught for these case: + // Some(Default::default()) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] /// Try to mine a Stacks block by assembling one from mempool transactions and sending a /// burnchain block-commit transaction. If we succeed, then return the assembled block data as /// well as the microblock private key to use to produce microblocks. @@ -3096,6 +3105,8 @@ impl RelayerThread { (true, miner_tip) } + // TODO: #4587 add tests for `true` and `false` returning cases + #[cfg_attr(test, mutants::skip)] /// Process all new tenures that we're aware of. /// Clear out stale tenure artifacts as well. /// Update the miner tip if we won the highest tenure (or clear it if we didn't). @@ -3550,6 +3561,8 @@ impl RelayerThread { true } + // TODO: #4587 add tests for `true` and `false` returning cases + #[cfg_attr(test, mutants::skip)] /// See if we should run a microblock tenure now. /// Return true if so; false if not fn can_run_microblock_tenure(&mut self) -> bool { diff --git a/testnet/stacks-node/src/tenure.rs b/testnet/stacks-node/src/tenure.rs index fd7683f569..30f49e1773 100644 --- a/testnet/stacks-node/src/tenure.rs +++ b/testnet/stacks-node/src/tenure.rs @@ -72,6 +72,10 @@ impl<'a> Tenure { } } + // TODO: #4587 create default for `TenureArtifacts` , then check if mutation tests are caught for these case: + // Some(Default::default()) + // Or keep the skip and remove the comment + #[cfg_attr(test, mutants::skip)] pub fn run(&mut self, burn_dbconn: &SortitionDBConn) -> Option { info!("Node starting new tenure with VRF {:?}", self.vrf_seed); From bdd2f186cd9e7b9d0597d42b63b90692523def00 Mon Sep 17 00:00:00 2001 From: ASuciuX Date: Mon, 3 Jun 2024 17:38:01 +0300 Subject: [PATCH 2/5] removed mutants-dependency --- clarity/Cargo.toml | 2 +- libsigner/Cargo.toml | 1 - pox-locking/Cargo.toml | 2 ++ stackslib/Cargo.toml | 1 - testnet/stacks-node/Cargo.toml | 1 - 5 files changed, 3 insertions(+), 4 deletions(-) diff --git a/clarity/Cargo.toml b/clarity/Cargo.toml index 8420934af1..e10a36806e 100644 --- a/clarity/Cargo.toml +++ b/clarity/Cargo.toml @@ -31,7 +31,6 @@ stacks_common = { package = "stacks-common", path = "../stacks-common", optional rstest = "0.17.0" rstest_reuse = "0.5.0" hashbrown = { workspace = true } -mutants = "0.0.3" [dependencies.serde_json] version = "1.0" @@ -48,6 +47,7 @@ features = ["std"] [dev-dependencies] assert-json-diff = "1.0.0" +mutants = "0.0.3" # a nightly rustc regression (35dbef235 2021-03-02) prevents criterion from compiling # but it isn't necessary for tests: only benchmarks. therefore, commenting out for now. # criterion = "0.3" diff --git a/libsigner/Cargo.toml b/libsigner/Cargo.toml index 2f86d48cf8..7da9801674 100644 --- a/libsigner/Cargo.toml +++ b/libsigner/Cargo.toml @@ -33,7 +33,6 @@ stackslib = { path = "../stackslib"} thiserror = "1.0" tiny_http = "0.12" wsts = { workspace = true } -mutants = "0.0.3" [dev-dependencies] mutants = "0.0.3" diff --git a/pox-locking/Cargo.toml b/pox-locking/Cargo.toml index 199a58d18e..4fbc9885dc 100644 --- a/pox-locking/Cargo.toml +++ b/pox-locking/Cargo.toml @@ -22,6 +22,8 @@ path = "src/lib.rs" clarity = { package = "clarity", path = "../clarity" } stacks_common = { package = "stacks-common", path = "../stacks-common" } slog = { version = "2.5.2", features = [ "max_level_trace" ] } + +[dev-dependencies] mutants = "0.0.3" [features] diff --git a/stackslib/Cargo.toml b/stackslib/Cargo.toml index 7c254f0384..be75337115 100644 --- a/stackslib/Cargo.toml +++ b/stackslib/Cargo.toml @@ -93,7 +93,6 @@ features = ["serde"] [dependencies.time] version = "0.2.23" features = ["std"] -mutants = "0.0.3" [dev-dependencies] assert-json-diff = "1.0.0" diff --git a/testnet/stacks-node/Cargo.toml b/testnet/stacks-node/Cargo.toml index 6c20f79dcd..bceb484cd7 100644 --- a/testnet/stacks-node/Cargo.toml +++ b/testnet/stacks-node/Cargo.toml @@ -31,7 +31,6 @@ wsts = { workspace = true } rand = { workspace = true } rand_core = { workspace = true } hashbrown = { workspace = true } -mutants = "0.0.3" [target.'cfg(not(any(target_os = "macos", target_os="windows", target_arch = "arm")))'.dependencies] tikv-jemallocator = {workspace = true} From 99b49afc55542de44ae9bf7d594607950af0fc98 Mon Sep 17 00:00:00 2001 From: ASuciuX Date: Mon, 3 Jun 2024 17:39:16 +0300 Subject: [PATCH 3/5] migrate some mutants todos to issues --- clarity/src/vm/ast/parser/v1.rs | 10 +--------- clarity/src/vm/ast/parser/v2/mod.rs | 10 +--------- clarity/src/vm/ast/sugar_expander/mod.rs | 10 +--------- clarity/src/vm/costs/mod.rs | 7 ++----- clarity/src/vm/types/mod.rs | 8 ++------ libsigner/src/events.rs | 4 +--- pox-locking/src/events.rs | 3 +-- stackslib/src/burnchains/db.rs | 3 +-- stackslib/src/burnchains/mod.rs | 3 +-- 9 files changed, 11 insertions(+), 47 deletions(-) diff --git a/clarity/src/vm/ast/parser/v1.rs b/clarity/src/vm/ast/parser/v1.rs index 65f9b66b11..5c2715e9f7 100644 --- a/clarity/src/vm/ast/parser/v1.rs +++ b/clarity/src/vm/ast/parser/v1.rs @@ -508,15 +508,7 @@ fn handle_expression( } } -// TODO: #4587 create default for `SymbolicExpression`, then check if mutation tests are caught for these cases: -// ParseResult::from(vec![Default::default()]) -// ParseResult::from(vec![]) -// ParseResult::new() -// ParseResult::from_iter([vec![Default::default()]]) -// ParseResult::new(vec![Default::default()]) -// ParseResult::new(vec![]) -// ParseResult::from_iter([vec![]]) -// Or keep the skip and remove the comment +// TODO: add tests from mutation testing results #4828 #[cfg_attr(test, mutants::skip)] pub fn parse_lexed(input: Vec<(LexItem, u32, u32)>) -> ParseResult> { let mut parse_stack = Vec::new(); diff --git a/clarity/src/vm/ast/parser/v2/mod.rs b/clarity/src/vm/ast/parser/v2/mod.rs index 8f039eedb1..f97aeb6b72 100644 --- a/clarity/src/vm/ast/parser/v2/mod.rs +++ b/clarity/src/vm/ast/parser/v2/mod.rs @@ -206,15 +206,7 @@ impl<'a> Parser<'a> { } } - // TODO: #4587 create default for `SymbolicExpression`, then check if mutation tests are caught for these cases: - // ParseResult::from_iter([Some(Default::default())]) - // ParseResult::new(None) - // ParseResult::from_iter([None]) - // ParseResult::new(Some(Default::default())) - // ParseResult::from(None) - // ParseResult::from(Some(Default::default())) - // ParseResult::new() - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4829 #[cfg_attr(test, mutants::skip)] /// Process a new child node for an AST expression that is open and waiting for children nodes. For example, /// a list or tuple expression that is waiting for child expressions. diff --git a/clarity/src/vm/ast/sugar_expander/mod.rs b/clarity/src/vm/ast/sugar_expander/mod.rs index 01528700fa..670796cf4c 100644 --- a/clarity/src/vm/ast/sugar_expander/mod.rs +++ b/clarity/src/vm/ast/sugar_expander/mod.rs @@ -58,15 +58,7 @@ impl SugarExpander { Ok(()) } - // TODO: #4587 create default for `SymbolicExpression`, then check if mutation tests are caught for these cases: - // ParseResult::from(vec![Default::default()]) - // ParseResult::from(vec![]) - // ParseResult::new() - // ParseResult::from_iter([vec![Default::default()]]) - // ParseResult::new(vec![Default::default()]) - // ParseResult::new(vec![]) - // ParseResult::from_iter([vec![]]) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4830 #[cfg_attr(test, mutants::skip)] pub fn transform( &self, diff --git a/clarity/src/vm/costs/mod.rs b/clarity/src/vm/costs/mod.rs index 17e052d97e..0751822ed0 100644 --- a/clarity/src/vm/costs/mod.rs +++ b/clarity/src/vm/costs/mod.rs @@ -782,8 +782,7 @@ impl LimitedCostTracker { } impl TrackerData { - // TODO: #4587 add test for Err cases - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4831 #[cfg_attr(test, mutants::skip)] /// `apply_updates` - tells this function to look for any changes in the cost voting contract /// which would need to be applied. if `false`, just load the last computed cost state in this @@ -957,9 +956,7 @@ fn parse_cost( } } -// TODO: #4587 create default for `ExecutionCost`, then check if mutation tests are caught for these case: -// Ok(Default::default()) -// Or keep the skip and remove the comment +// TODO: add tests from mutation testing results #4832 #[cfg_attr(test, mutants::skip)] fn compute_cost( cost_tracker: &mut TrackerData, diff --git a/clarity/src/vm/types/mod.rs b/clarity/src/vm/types/mod.rs index 98ed421828..d04586504f 100644 --- a/clarity/src/vm/types/mod.rs +++ b/clarity/src/vm/types/mod.rs @@ -1516,9 +1516,7 @@ impl TupleData { self.data_map.is_empty() } - // TODO: #4587 create default for TupleData, then check if the mutation tests are caught for the case: - // Ok((Default::default())) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4833 #[cfg_attr(test, mutants::skip)] pub fn from_data(data: Vec<(ClarityName, Value)>) -> Result { let mut type_map = BTreeMap::new(); @@ -1536,9 +1534,7 @@ impl TupleData { Self::new(TupleTypeSignature::try_from(type_map)?, data_map) } - // TODO: #4587 create default for TupleData, then check if the mutation tests are caught for the case: - // Ok((Default::default())) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4834 #[cfg_attr(test, mutants::skip)] pub fn from_data_typed( epoch: &StacksEpochId, diff --git a/libsigner/src/events.rs b/libsigner/src/events.rs index a24219b1ce..aadfd81e64 100644 --- a/libsigner/src/events.rs +++ b/libsigner/src/events.rs @@ -375,9 +375,7 @@ fn ack_dispatcher(request: HttpRequest) { }; } -// TODO: #4587 create default for `SignerEvent` and `EventError`, then check if mutation tests are caught for these case: -// Ok(Default::default()) -// Or keep the skip and remove the comment +// TODO: add tests from mutation testing results #4835 #[cfg_attr(test, mutants::skip)] /// Process a stackerdb event from the node fn process_stackerdb_event( diff --git a/pox-locking/src/events.rs b/pox-locking/src/events.rs index 2146a15688..0a1dc9d3c4 100644 --- a/pox-locking/src/events.rs +++ b/pox-locking/src/events.rs @@ -105,8 +105,7 @@ fn create_event_info_aggregation_code(function_name: &str) -> String { ) } -// TODO: #4587 add tests for `String::new()` and `"xyzzy".into()` returning case. -// Or keep the skip and remove the comment +// TODO: add tests from mutation testing results #4836 #[cfg_attr(test, mutants::skip)] /// Craft the code snippet to generate the method-specific `data` payload fn create_event_info_data_code( diff --git a/stackslib/src/burnchains/db.rs b/stackslib/src/burnchains/db.rs index 1c6d0d2c61..79e34b3539 100644 --- a/stackslib/src/burnchains/db.rs +++ b/stackslib/src/burnchains/db.rs @@ -946,8 +946,7 @@ impl<'a> BurnchainDBTransaction<'a> { BurnchainDB::inner_get_canonical_chain_tip(&self.sql_tx) } - // TODO: #4587 add tests for `Ok(())` returning case - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4837 #[cfg_attr(test, mutants::skip)] /// You'd only do this in network emergencies, where node operators are expected to declare an /// anchor block missing (or present). Ideally there'd be a smart contract somewhere for this. diff --git a/stackslib/src/burnchains/mod.rs b/stackslib/src/burnchains/mod.rs index 5f47ddb5ed..228f7895ee 100644 --- a/stackslib/src/burnchains/mod.rs +++ b/stackslib/src/burnchains/mod.rs @@ -468,8 +468,7 @@ impl PoxConstants { ) // total liquid supply is 40000000000000000 µSTX } - // TODO: #4587 create default for PoxConstants, then check if the mutation tests are caught: - // Default::default() + // TODO: add tests from mutation testing results #4838 #[cfg_attr(test, mutants::skip)] pub fn regtest_default() -> PoxConstants { PoxConstants::new( From 386d24380167c45b9338384a09d13b30142423de Mon Sep 17 00:00:00 2001 From: ASuciuX Date: Tue, 4 Jun 2024 21:55:47 +0300 Subject: [PATCH 4/5] migrate the rest of the mutants todos to issues --- clarity/src/vm/ast/parser/v2/mod.rs | 10 +------- stackslib/src/chainstate/burn/db/sortdb.rs | 7 +----- .../chainstate/burn/operations/stack_stx.rs | 11 ++------- stackslib/src/chainstate/coordinator/mod.rs | 3 +-- stackslib/src/chainstate/stacks/boot/mod.rs | 15 ++++-------- stackslib/src/chainstate/stacks/db/blocks.rs | 15 +++--------- stackslib/src/chainstate/stacks/miner.rs | 16 ++++--------- .../burnchains/bitcoin_regtest_controller.rs | 24 +++++-------------- testnet/stacks-node/src/config.rs | 7 ++---- .../stacks-node/src/nakamoto_node/miner.rs | 12 +++------- testnet/stacks-node/src/neon_node.rs | 13 ++++------ testnet/stacks-node/src/tenure.rs | 4 ---- 12 files changed, 32 insertions(+), 105 deletions(-) diff --git a/clarity/src/vm/ast/parser/v2/mod.rs b/clarity/src/vm/ast/parser/v2/mod.rs index f97aeb6b72..4c46e76a4d 100644 --- a/clarity/src/vm/ast/parser/v2/mod.rs +++ b/clarity/src/vm/ast/parser/v2/mod.rs @@ -277,15 +277,7 @@ impl<'a> Parser<'a> { } } - // TODO: #4587 create default for `SymbolicExpression`, then check if mutation tests are caught for these cases: - // ParseResult::from_iter([Some(Default::default())]) - // ParseResult::new(None) - // ParseResult::from_iter([None]) - // ParseResult::new(Some(Default::default())) - // ParseResult::from(None) - // ParseResult::from(Some(Default::default())) - // ParseResult::new() - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4848 #[cfg_attr(test, mutants::skip)] fn handle_open_tuple( &mut self, diff --git a/stackslib/src/chainstate/burn/db/sortdb.rs b/stackslib/src/chainstate/burn/db/sortdb.rs index 64ed6b9772..b494e58a7f 100644 --- a/stackslib/src/chainstate/burn/db/sortdb.rs +++ b/stackslib/src/chainstate/burn/db/sortdb.rs @@ -307,10 +307,6 @@ impl FromRow for LeaderBlockCommitOp { } impl FromRow for StackStxOp { - // TODO: #4587 create default for `StackStxOp`, then check if mutation tests are caught for these case: - // Ok(Default::default()) - // Or keep the skip and remove the comment - #[cfg_attr(test, mutants::skip)] fn from_row<'a>(row: &'a Row) -> Result { let txid = Txid::from_column(row, "txid")?; let vtxindex: u32 = row.get_unwrap("vtxindex"); @@ -5132,8 +5128,7 @@ impl SortitionDB { query_row(conn, sql, args) } - // TODO: #4587 add test for the `None` case returning Ok(false) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4849 #[cfg_attr(test, mutants::skip)] /// Are microblocks disabled by Epoch 2.5 at the height specified /// in `at_burn_height`? diff --git a/stackslib/src/chainstate/burn/operations/stack_stx.rs b/stackslib/src/chainstate/burn/operations/stack_stx.rs index 3e213e8811..c4c54b9737 100644 --- a/stackslib/src/chainstate/burn/operations/stack_stx.rs +++ b/stackslib/src/chainstate/burn/operations/stack_stx.rs @@ -181,9 +181,7 @@ impl StackStxOp { } } - // TODO: #4587 create default for `ParsedData`, then check if mutation tests are caught for these case: - // Some(Default::default()) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4850 #[cfg_attr(test, mutants::skip)] fn parse_data(data: &Vec) -> Option { /* @@ -275,9 +273,7 @@ impl StackStxOp { ) } - // TODO: #4587 create default for `StackStxOp` and `op_error`, then check if mutation tests are caught for these case: - // Ok(Default::default()) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4851 #[cfg_attr(test, mutants::skip)] /// parse a StackStxOp /// `pox_sunset_ht` is the height at which PoX *disables* @@ -403,9 +399,6 @@ impl StacksMessageCodec for StackStxOp { } impl StackStxOp { - // TODO: #4587 add tests for `Ok(())` returning case. - // Or keep the skip and remove the comment - #[cfg_attr(test, mutants::skip)] pub fn check(&self) -> Result<(), op_error> { if self.stacked_ustx == 0 { warn!("Invalid StackStxOp, must have positive ustx"); diff --git a/stackslib/src/chainstate/coordinator/mod.rs b/stackslib/src/chainstate/coordinator/mod.rs index c34eaaafab..ac47d9d92b 100644 --- a/stackslib/src/chainstate/coordinator/mod.rs +++ b/stackslib/src/chainstate/coordinator/mod.rs @@ -2414,8 +2414,7 @@ impl< return false; } - // TODO: #4587,create default for BlockHeaderHash, then check if mutation tests are caught for these cases: - // Ok(Some(Default::default)) + // TODO: add tests from mutation testing results #4852 #[cfg_attr(test, mutants::skip)] /// Handle a new burnchain block, optionally rolling back the canonical PoX sortition history /// and setting it up to be replayed in the event the network affirms a different history. If diff --git a/stackslib/src/chainstate/stacks/boot/mod.rs b/stackslib/src/chainstate/stacks/boot/mod.rs index 96ab7a6639..c79e28cb8b 100644 --- a/stackslib/src/chainstate/stacks/boot/mod.rs +++ b/stackslib/src/chainstate/stacks/boot/mod.rs @@ -423,8 +423,7 @@ impl StacksChainState { result } - // TODO: #4587 create default for StacksTransactionEvent , then check if mutation tests are caught for these cases: - // Ok(vec![Default::default()]) + // TODO: add tests from mutation testing results #4854 #[cfg_attr(test, mutants::skip)] /// Do all the necessary Clarity operations at the start of a PoX reward cycle. /// Currently, this just means applying any auto-unlocks to Stackers who qualified. @@ -438,8 +437,7 @@ impl StacksChainState { Self::handle_pox_cycle_missed_unlocks(clarity, cycle_number, cycle_info, &PoxVersions::Pox2) } - // TODO: #4587 create default for StacksTransactionEvent , then check if mutation tests are caught for these cases: - // Ok(vec![Default::default()]) + // TODO: add tests from mutation testing results #4854 #[cfg_attr(test, mutants::skip)] /// Do all the necessary Clarity operations at the start of a PoX reward cycle. /// Currently, this just means applying any auto-unlocks to Stackers who qualified. @@ -453,8 +451,7 @@ impl StacksChainState { Self::handle_pox_cycle_missed_unlocks(clarity, cycle_number, cycle_info, &PoxVersions::Pox3) } - // TODO: #4587 create default for StacksTransactionEvent , then check if mutation tests are caught for these cases: - // Ok(vec![Default::default()]) + // TODO: add tests from mutation testing results #4854 #[cfg_attr(test, mutants::skip)] /// Do all the necessary Clarity operations at the start of a PoX reward cycle. /// Currently, this just means applying any auto-unlocks to Stackers who qualified. @@ -469,8 +466,7 @@ impl StacksChainState { Ok(vec![]) } - // TODO: #4587 create default for StacksTransactionEvent , then check if mutation tests are caught for these cases: - // Ok(vec![Default::default()]) + // TODO: add tests from mutation testing results #4854 #[cfg_attr(test, mutants::skip)] /// Do all the necessary Clarity operations at the start of a PoX reward cycle. /// Currently, this just means applying any auto-unlocks to Stackers who qualified. @@ -764,8 +760,7 @@ impl StacksChainState { Some(signer_set) } - // TODO: #4587 create default for RewardSet , then check if mutation tests are caught for these cases: - // Default::default() + // TODO: add tests from mutation testing results #4855 #[cfg_attr(test, mutants::skip)] /// Given a threshold and set of registered addresses, return a reward set where /// every entry address has stacked more than the threshold, and addresses diff --git a/stackslib/src/chainstate/stacks/db/blocks.rs b/stackslib/src/chainstate/stacks/db/blocks.rs index e18421632d..de093d2234 100644 --- a/stackslib/src/chainstate/stacks/db/blocks.rs +++ b/stackslib/src/chainstate/stacks/db/blocks.rs @@ -4132,8 +4132,7 @@ impl StacksChainState { Ok((applied, receipts)) } - // TODO: #4587 create default for `StacksTransactionReceipt`, then check if mutation tests are caught for these case: - // vec![Default::default()] + // TODO: add tests from mutation testing results #4856 // Or keep the skip and remove the comment #[cfg_attr(test, mutants::skip)] /// Process any Stacking-related bitcoin operations @@ -4241,10 +4240,7 @@ impl StacksChainState { all_receipts } - // TODO: #4587 add test for `Ok(vec![])` returning case. - // TODO: #4587 create default for `Value`, then check if mutation tests are caught for these case: - // Ok(vec![Default::default()]) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4857 #[cfg_attr(test, mutants::skip)] pub fn collect_pox_4_stacking_args(op: &StackStxOp) -> Result, String> { let signer_key = match op.signer_key { @@ -6030,12 +6026,7 @@ impl StacksChainState { Ok(next_microblocks) } - // TODO: #4587 add default for `StacksEpochReceipt` and `TransactionPayload`, then check if mutation tests are caught for these cases: - // Ok((None, Some(Default::default()))) - // Ok((Some(Default::default()), None)) - // Ok((Some(Default::default()), Some(Default::default()))) - // This is caught: Ok(None, None) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4858 #[cfg_attr(test, mutants::skip)] /// Find and process the next staging block. /// Return the next chain tip if we processed this block, or None if we couldn't. diff --git a/stackslib/src/chainstate/stacks/miner.rs b/stackslib/src/chainstate/stacks/miner.rs index 6fb2bc4be3..3db5ca89c0 100644 --- a/stackslib/src/chainstate/stacks/miner.rs +++ b/stackslib/src/chainstate/stacks/miner.rs @@ -1801,9 +1801,7 @@ impl StacksBlockBuilder { } } - // TODO: #4587 create default for MinerEpochInfo, then check if mutation tests are caught for these case: - // Ok(Default::default()) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4859 #[cfg_attr(test, mutants::skip)] /// This function should be called before `epoch_begin`. /// It loads the parent microblock stream, sets the parent microblock, and returns @@ -2059,9 +2057,7 @@ impl StacksBlockBuilder { Ok((block, size, cost, mblock_opt)) } - // TODO: #4587 create default for `StacksBlockBuilder`, then check if mutation tests are caught for these case: - // Ok(Default::default()) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4860 #[cfg_attr(test, mutants::skip)] /// Create a block builder for mining pub fn make_block_builder( @@ -2117,9 +2113,7 @@ impl StacksBlockBuilder { Ok(builder) } - // TODO: #4587 create default for `StacksBlockBuilder`, then check if mutation tests are caught for these case: - // Ok(Default::default()) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4860 #[cfg_attr(test, mutants::skip)] /// Create a block builder for regtest mining pub fn make_regtest_block_builder( @@ -2401,9 +2395,7 @@ impl StacksBlockBuilder { Ok((blocked, tx_events)) } - // TODO: #4587 create default for `StacksBlock` and `ExecutionCost`, then check if mutation tests are caught for these cases: - // Ok((Default::default(), Default::default(), 1)) - // Ok((Default::default(), Default::default(), 0)) + // TODO: add tests from mutation testing results #4861 // Or keep the skip and remove the comment #[cfg_attr(test, mutants::skip)] /// Given access to the mempool, mine an anchored block with no more than the given execution cost. diff --git a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs index bb6a319651..30f088a96f 100644 --- a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs +++ b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs @@ -125,9 +125,7 @@ pub fn addr2str(btc_addr: &BitcoinAddress) -> String { format!("{}", &btc_addr) } -// TODO: #4587 create default for `BurnchainParameters`, then check if mutation tests are caught for these case: -// Default::default() -// Or keep the skip and remove the comment +// TODO: add tests from mutation testing results #4862 #[cfg_attr(test, mutants::skip)] pub fn burnchain_params_from_config(config: &BurnchainConfig) -> BurnchainParameters { let (network, _) = config.get_bitcoin_network(); @@ -139,9 +137,7 @@ pub fn burnchain_params_from_config(config: &BurnchainConfig) -> BurnchainParame params } -// TODO: #4587 create default for `BitcoinIndexer`, then check if mutation tests are caught for these case: -// Default::default() -// Or keep the skip and remove the comment +// TODO: add tests from mutation testing results #4863 #[cfg_attr(test, mutants::skip)] /// Helper method to create a BitcoinIndexer pub fn make_bitcoin_indexer( @@ -280,9 +276,7 @@ impl BitcoinRegtestController { BitcoinRegtestController::with_burnchain(config, coordinator_channel, None, None) } - // TODO: #4587 create default for `BitcoinRegtestController`, then check if mutation tests are caught for these case: - // Default::default() - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4864 #[cfg_attr(test, mutants::skip)] pub fn with_burnchain( config: Config, @@ -353,9 +347,7 @@ impl BitcoinRegtestController { } } - // TODO: #4587 create default for `BitcoinRegtestController`, then check if mutation tests are caught for these case: - // Default::default() - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4864 #[cfg_attr(test, mutants::skip)] /// create a dummy bitcoin regtest controller. /// used just for submitting bitcoin ops. @@ -1634,9 +1626,7 @@ impl BitcoinRegtestController { } } - // TODO: #4587 create default for `Transaction` and `UTXOSet`, then check if mutation tests are caught for these case: - // Some((Default::default(), Default::default())) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4865 #[cfg_attr(test, mutants::skip)] fn prepare_tx( &mut self, @@ -2005,9 +1995,7 @@ impl BitcoinRegtestController { self.config.miner.segwit = segwit; } - // TODO: #4587 create default for `SerializedTx`, then check if mutation tests are caught for these case: - // Some(Default::default()) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4866 #[cfg_attr(test, mutants::skip)] pub fn make_operation_tx( &mut self, diff --git a/testnet/stacks-node/src/config.rs b/testnet/stacks-node/src/config.rs index c2e6193685..b028169729 100644 --- a/testnet/stacks-node/src/config.rs +++ b/testnet/stacks-node/src/config.rs @@ -827,9 +827,7 @@ impl Config { } } - // TODO: #4587 create default for `StacksEpoch`, then check if mutation tests are caught for these case: - // Ok(vec![Default::default()]) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4866 #[cfg_attr(test, mutants::skip)] fn make_epochs( conf_epochs: &[StacksEpochConfigFile], @@ -1278,8 +1276,7 @@ impl Config { } } - // TODO: #4587 create default for BlockBuilderSettings, then check if mutation tests are caught for these case: - // Default::default() + // TODO: add tests from mutation testing results #4867 #[cfg_attr(test, mutants::skip)] pub fn make_block_builder_settings( &self, diff --git a/testnet/stacks-node/src/nakamoto_node/miner.rs b/testnet/stacks-node/src/nakamoto_node/miner.rs index 1e17a19cdc..1bbdd25512 100644 --- a/testnet/stacks-node/src/nakamoto_node/miner.rs +++ b/testnet/stacks-node/src/nakamoto_node/miner.rs @@ -576,9 +576,7 @@ impl BlockMinerThread { tx_signer.get_tx().unwrap() } - // TODO: #4587 create default for `NakamotoNodeError` and `ParentStacksBlockInfo`, then check if mutation tests are caught for these case: - // Ok(Default::default()) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4869 #[cfg_attr(test, mutants::skip)] /// Load up the parent block info for mining. /// If there's no parent because this is the first block, then return the genesis block's info. @@ -683,9 +681,7 @@ impl BlockMinerThread { Some(vrf_proof) } - // TODO: #4587 create default for `NakamotoBlock` and `NakamotoNodeError`, then check if mutation tests are caught for these case: - // Ok(Default::default()) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4869 #[cfg_attr(test, mutants::skip)] /// Try to mine a Stacks block by assembling one from mempool transactions and sending a /// burnchain block-commit transaction. If we succeed, then return the assembled block. @@ -840,9 +836,7 @@ impl BlockMinerThread { } impl ParentStacksBlockInfo { - // TODO: #4587 craete default for `NakamotoBlock` and `NakamotoNodeError`, then check if mutation tests are caught for these case: - // Ok(Default::default()) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4869 #[cfg_attr(test, mutants::skip)] /// Determine where in the set of forks to attempt to mine the next anchored block. /// `mine_tip_ch` and `mine_tip_bhh` identify the parent block on top of which to mine. diff --git a/testnet/stacks-node/src/neon_node.rs b/testnet/stacks-node/src/neon_node.rs index 7c8295f9aa..8b149f0b1a 100644 --- a/testnet/stacks-node/src/neon_node.rs +++ b/testnet/stacks-node/src/neon_node.rs @@ -1507,10 +1507,7 @@ impl BlockMinerThread { Some((*best_tip).clone()) } - // TODO: #4587 create default for `ParentStacksBlockInfo`, then check if mutation tests are caught for these cases: - // (Some(Default::default()), true) - // (Some(Default::default()), false) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4870 #[cfg_attr(test, mutants::skip)] /// Load up the parent block info for mining. /// If there's no parent because this is the first block, then return the genesis block's info. @@ -2227,9 +2224,7 @@ impl BlockMinerThread { return false; } - // TODO: #4587 create default for `MinerThreadResult`, then check if mutation tests are caught for these case: - // Some(Default::default()) - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4871 #[cfg_attr(test, mutants::skip)] /// Try to mine a Stacks block by assembling one from mempool transactions and sending a /// burnchain block-commit transaction. If we succeed, then return the assembled block data as @@ -3105,7 +3100,7 @@ impl RelayerThread { (true, miner_tip) } - // TODO: #4587 add tests for `true` and `false` returning cases + // TODO: add tests from mutation testing results #4872 #[cfg_attr(test, mutants::skip)] /// Process all new tenures that we're aware of. /// Clear out stale tenure artifacts as well. @@ -3580,7 +3575,7 @@ impl RelayerThread { true } - // TODO: #4587 add tests for `true` and `false` returning cases + // TODO: add tests from mutation testing results #4872 #[cfg_attr(test, mutants::skip)] /// See if we should run a microblock tenure now. /// Return true if so; false if not diff --git a/testnet/stacks-node/src/tenure.rs b/testnet/stacks-node/src/tenure.rs index 30f49e1773..fd7683f569 100644 --- a/testnet/stacks-node/src/tenure.rs +++ b/testnet/stacks-node/src/tenure.rs @@ -72,10 +72,6 @@ impl<'a> Tenure { } } - // TODO: #4587 create default for `TenureArtifacts` , then check if mutation tests are caught for these case: - // Some(Default::default()) - // Or keep the skip and remove the comment - #[cfg_attr(test, mutants::skip)] pub fn run(&mut self, burn_dbconn: &SortitionDBConn) -> Option { info!("Node starting new tenure with VRF {:?}", self.vrf_seed); From 64598a221d581cbb0800cbb7510a84df6d4734fa Mon Sep 17 00:00:00 2001 From: ASuciuX Date: Tue, 4 Jun 2024 22:04:09 +0300 Subject: [PATCH 5/5] migrate missed mutant todo to issue --- stackslib/src/chainstate/stacks/miner.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/stackslib/src/chainstate/stacks/miner.rs b/stackslib/src/chainstate/stacks/miner.rs index 3db5ca89c0..008de4afe1 100644 --- a/stackslib/src/chainstate/stacks/miner.rs +++ b/stackslib/src/chainstate/stacks/miner.rs @@ -170,9 +170,7 @@ pub struct BlockBuilderSettings { } impl BlockBuilderSettings { - // TODO: #4587 create default for BlockBuilderSettings, then check if mutation tests are caught for these case: - // Default::default() - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4873 #[cfg_attr(test, mutants::skip)] pub fn limited() -> BlockBuilderSettings { BlockBuilderSettings { @@ -183,9 +181,7 @@ impl BlockBuilderSettings { } } - // TODO: #4587 create default for BlockBuilderSettings, then check if mutation tests are caught for these case: - // Default::default() - // Or keep the skip and remove the comment + // TODO: add tests from mutation testing results #4873 #[cfg_attr(test, mutants::skip)] pub fn max_value() -> BlockBuilderSettings { BlockBuilderSettings {