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/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/clarity/src/vm/ast/parser/v1.rs b/clarity/src/vm/ast/parser/v1.rs index 75c5ea2df9..5c2715e9f7 100644 --- a/clarity/src/vm/ast/parser/v1.rs +++ b/clarity/src/vm/ast/parser/v1.rs @@ -508,6 +508,8 @@ fn handle_expression( } } +// 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 a7ba4eb3c8..4c46e76a4d 100644 --- a/clarity/src/vm/ast/parser/v2/mod.rs +++ b/clarity/src/vm/ast/parser/v2/mod.rs @@ -206,6 +206,8 @@ impl<'a> Parser<'a> { } } + // 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. /// @@ -275,6 +277,8 @@ impl<'a> Parser<'a> { } } + // TODO: add tests from mutation testing results #4848 + #[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..670796cf4c 100644 --- a/clarity/src/vm/ast/sugar_expander/mod.rs +++ b/clarity/src/vm/ast/sugar_expander/mod.rs @@ -58,6 +58,8 @@ impl SugarExpander { Ok(()) } + // TODO: add tests from mutation testing results #4830 + #[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 3424610b35..0751822ed0 100644 --- a/clarity/src/vm/costs/mod.rs +++ b/clarity/src/vm/costs/mod.rs @@ -782,12 +782,11 @@ impl LimitedCostTracker { } impl TrackerData { + // 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 /// 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 @@ -957,6 +956,8 @@ fn parse_cost( } } +// TODO: add tests from mutation testing results #4832 +#[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 5662f2bb8a..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 4de6b80513..c9927b577e 100644 --- a/libsigner/src/events.rs +++ b/libsigner/src/events.rs @@ -378,6 +378,8 @@ fn ack_dispatcher(request: HttpRequest) { }; } +// TODO: add tests from mutation testing results #4835 +#[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..4fbc9885dc 100644 --- a/pox-locking/Cargo.toml +++ b/pox-locking/Cargo.toml @@ -23,5 +23,8 @@ 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] 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..0a1dc9d3c4 100644 --- a/pox-locking/src/events.rs +++ b/pox-locking/src/events.rs @@ -105,6 +105,8 @@ fn create_event_info_aggregation_code(function_name: &str) -> String { ) } +// 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( function_name: &str, diff --git a/stackslib/src/burnchains/db.rs b/stackslib/src/burnchains/db.rs index 3171ec3c98..79e34b3539 100644 --- a/stackslib/src/burnchains/db.rs +++ b/stackslib/src/burnchains/db.rs @@ -946,6 +946,8 @@ impl<'a> BurnchainDBTransaction<'a> { BurnchainDB::inner_get_canonical_chain_tip(&self.sql_tx) } + // 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. pub fn set_override_affirmation_map( diff --git a/stackslib/src/burnchains/mod.rs b/stackslib/src/burnchains/mod.rs index 23dc50f62c..228f7895ee 100644 --- a/stackslib/src/burnchains/mod.rs +++ b/stackslib/src/burnchains/mod.rs @@ -468,6 +468,8 @@ impl PoxConstants { ) // total liquid supply is 40000000000000000 µSTX } + // TODO: add tests from mutation testing results #4838 + #[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 a2a3c75c62..fb17e918b7 100644 --- a/stackslib/src/chainstate/burn/db/sortdb.rs +++ b/stackslib/src/chainstate/burn/db/sortdb.rs @@ -5264,6 +5264,8 @@ impl SortitionDB { query_row(conn, sql, args) } + // 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`? 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..c4c54b9737 100644 --- a/stackslib/src/chainstate/burn/operations/stack_stx.rs +++ b/stackslib/src/chainstate/burn/operations/stack_stx.rs @@ -181,6 +181,8 @@ impl StackStxOp { } } + // TODO: add tests from mutation testing results #4850 + #[cfg_attr(test, mutants::skip)] fn parse_data(data: &Vec) -> Option { /* Wire format: @@ -271,6 +273,8 @@ impl StackStxOp { ) } + // 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* pub fn parse_from_tx( diff --git a/stackslib/src/chainstate/coordinator/mod.rs b/stackslib/src/chainstate/coordinator/mod.rs index b3e170987e..b2a1c8679f 100644 --- a/stackslib/src/chainstate/coordinator/mod.rs +++ b/stackslib/src/chainstate/coordinator/mod.rs @@ -2436,6 +2436,8 @@ impl< return false; } + // 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 /// 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 cc693afa29..1be4fa9385 100644 --- a/stackslib/src/chainstate/stacks/boot/mod.rs +++ b/stackslib/src/chainstate/stacks/boot/mod.rs @@ -442,6 +442,8 @@ impl StacksChainState { result } + // 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. /// @@ -454,6 +456,8 @@ impl StacksChainState { Self::handle_pox_cycle_missed_unlocks(clarity, cycle_number, cycle_info, &PoxVersions::Pox2) } + // 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. /// @@ -466,6 +470,8 @@ impl StacksChainState { Self::handle_pox_cycle_missed_unlocks(clarity, cycle_number, cycle_info, &PoxVersions::Pox3) } + // 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. /// @@ -479,6 +485,8 @@ impl StacksChainState { Ok(vec![]) } + // 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. /// @@ -775,6 +783,8 @@ impl StacksChainState { Some(signer_set) } + // 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 /// 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 dfff8c52a1..971351b1d5 100644 --- a/stackslib/src/chainstate/stacks/db/blocks.rs +++ b/stackslib/src/chainstate/stacks/db/blocks.rs @@ -4132,6 +4132,9 @@ impl StacksChainState { Ok((applied, receipts)) } + // 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 /// that haven't been processed in this Stacks fork yet. pub fn process_stacking_ops( @@ -4237,6 +4240,8 @@ impl StacksChainState { all_receipts } + // 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 { Some(signer_key) => match Value::buff_from(signer_key.as_bytes().to_vec()) { @@ -6021,6 +6026,8 @@ impl StacksChainState { Ok(next_microblocks) } + // 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. /// 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 c2ba5eee4d..a0e52c8e39 100644 --- a/stackslib/src/chainstate/stacks/miner.rs +++ b/stackslib/src/chainstate/stacks/miner.rs @@ -172,6 +172,8 @@ pub struct BlockBuilderSettings { } impl BlockBuilderSettings { + // TODO: add tests from mutation testing results #4873 + #[cfg_attr(test, mutants::skip)] pub fn limited() -> BlockBuilderSettings { BlockBuilderSettings { max_miner_time_ms: u64::MAX, @@ -181,6 +183,8 @@ impl BlockBuilderSettings { } } + // TODO: add tests from mutation testing results #4873 + #[cfg_attr(test, mutants::skip)] pub fn max_value() -> BlockBuilderSettings { BlockBuilderSettings { max_miner_time_ms: u64::MAX, @@ -1796,6 +1800,8 @@ impl StacksBlockBuilder { } } + // 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 /// data necessary for `epoch_begin`. @@ -2050,6 +2056,8 @@ impl StacksBlockBuilder { Ok((block, size, cost, mblock_opt)) } + // TODO: add tests from mutation testing results #4860 + #[cfg_attr(test, mutants::skip)] /// Create a block builder for mining pub fn make_block_builder( burnchain: &Burnchain, @@ -2104,6 +2112,8 @@ impl StacksBlockBuilder { Ok(builder) } + // 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( burnchain: &Burnchain, @@ -2384,6 +2394,9 @@ impl StacksBlockBuilder { Ok((blocked, tx_events)) } + // 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. /// 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 a10353ced3..2bb78a6282 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/src/burnchains/bitcoin_regtest_controller.rs b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs index 8cf9ac82be..30f088a96f 100644 --- a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs +++ b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs @@ -125,6 +125,8 @@ pub fn addr2str(btc_addr: &BitcoinAddress) -> String { format!("{}", &btc_addr) } +// 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(); let mut params = BurnchainParameters::from_params(&config.chain, &network) @@ -135,6 +137,8 @@ pub fn burnchain_params_from_config(config: &BurnchainConfig) -> BurnchainParame params } +// TODO: add tests from mutation testing results #4863 +#[cfg_attr(test, mutants::skip)] /// Helper method to create a BitcoinIndexer pub fn make_bitcoin_indexer( config: &Config, @@ -272,6 +276,8 @@ impl BitcoinRegtestController { BitcoinRegtestController::with_burnchain(config, coordinator_channel, None, None) } + // TODO: add tests from mutation testing results #4864 + #[cfg_attr(test, mutants::skip)] pub fn with_burnchain( config: Config, coordinator_channel: Option, @@ -341,6 +347,8 @@ impl BitcoinRegtestController { } } + // 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. pub fn new_dummy(config: Config) -> Self { @@ -1242,6 +1250,7 @@ impl BitcoinRegtestController { Some(tx) } + #[cfg_attr(test, mutants::skip)] #[cfg(not(test))] fn build_stack_stx_tx( &mut self, @@ -1617,6 +1626,8 @@ impl BitcoinRegtestController { } } + // TODO: add tests from mutation testing results #4865 + #[cfg_attr(test, mutants::skip)] fn prepare_tx( &mut self, epoch_id: StacksEpochId, @@ -1984,6 +1995,8 @@ impl BitcoinRegtestController { self.config.miner.segwit = segwit; } + // TODO: add tests from mutation testing results #4866 + #[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 c101da090d..c3ea96810f 100644 --- a/testnet/stacks-node/src/config.rs +++ b/testnet/stacks-node/src/config.rs @@ -827,6 +827,8 @@ impl Config { } } + // TODO: add tests from mutation testing results #4866 + #[cfg_attr(test, mutants::skip)] fn make_epochs( conf_epochs: &[StacksEpochConfigFile], burn_mode: &str, @@ -1274,6 +1276,8 @@ impl Config { } } + // TODO: add tests from mutation testing results #4867 + #[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 a810a4fbf0..9d20faaead 100644 --- a/testnet/stacks-node/src/nakamoto_node/miner.rs +++ b/testnet/stacks-node/src/nakamoto_node/miner.rs @@ -730,6 +730,8 @@ impl BlockMinerThread { tx_signer.get_tx().unwrap() } + // 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. /// If we can't find the parent in the DB but we expect one, return None. @@ -833,6 +835,8 @@ impl BlockMinerThread { Some(vrf_proof) } + // 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. fn mine_block(&mut self, stackerdbs: &StackerDBs) -> Result { @@ -1026,6 +1030,8 @@ impl BlockMinerThread { } impl ParentStacksBlockInfo { + // 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. /// `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 41ac96b50f..ed003a682d 100644 --- a/testnet/stacks-node/src/neon_node.rs +++ b/testnet/stacks-node/src/neon_node.rs @@ -1510,6 +1510,8 @@ impl BlockMinerThread { Some((*best_tip).clone()) } + // 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. /// If we can't find the parent in the DB but we expect one, return None. @@ -2225,6 +2227,8 @@ impl BlockMinerThread { return false; } + // 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 /// well as the microblock private key to use to produce microblocks. @@ -3100,6 +3104,8 @@ impl RelayerThread { (true, miner_tip) } + // 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. /// Update the miner tip if we won the highest tenure (or clear it if we didn't). @@ -3573,6 +3579,8 @@ impl RelayerThread { true } + // 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 fn can_run_microblock_tenure(&mut self) -> bool {