Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skips and comments for certain mutants #4790

Merged
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion clarity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions clarity/src/vm/ast/parser/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<PreSymbolicExpression>> {
let mut parse_stack = Vec::new();

Expand Down
4 changes: 4 additions & 0 deletions clarity/src/vm/ast/parser/v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions clarity/src/vm/ast/sugar_expander/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions clarity/src/vm/costs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 2 additions & 6 deletions clarity/src/vm/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TupleData> {
let mut type_map = BTreeMap::new();
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions libsigner/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: SignerEventTrait>(
local_addr: Option<SocketAddr>,
Expand Down
3 changes: 3 additions & 0 deletions pox-locking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
ASuciuX marked this conversation as resolved.
Show resolved Hide resolved

[features]
slog_json = ["stacks_common/slog_json", "clarity/slog_json"]
2 changes: 2 additions & 0 deletions pox-locking/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions stackslib/src/burnchains/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions stackslib/src/burnchains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions stackslib/src/chainstate/burn/db/sortdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool, db_error> {
Expand Down
4 changes: 4 additions & 0 deletions stackslib/src/chainstate/burn/operations/stack_stx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ impl StackStxOp {
}
}

// TODO: add tests from mutation testing results #4850
#[cfg_attr(test, mutants::skip)]
fn parse_data(data: &Vec<u8>) -> Option<ParsedData> {
/*
Wire format:
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions stackslib/src/chainstate/coordinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions stackslib/src/chainstate/stacks/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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.
///
Expand All @@ -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.
///
Expand All @@ -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.
///
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions stackslib/src/chainstate/stacks/db/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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<Vec<Value>, String> {
let signer_key = match op.signer_key {
Some(signer_key) => match Value::buff_from(signer_key.as_bytes().to_vec()) {
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions stackslib/src/chainstate/stacks/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions stackslib/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = env::args().collect();
if argv.len() < 2 {
Expand Down Expand Up @@ -1332,6 +1333,7 @@ simulating a miner.
}
}

#[cfg_attr(test, mutants::skip)]
fn tip_mine() {
let argv: Vec<String> = env::args().collect();
if argv.len() < 6 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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<CoordinatorChannels>,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -1242,6 +1250,7 @@ impl BitcoinRegtestController {
Some(tx)
}

#[cfg_attr(test, mutants::skip)]
#[cfg(not(test))]
fn build_stack_stx_tx(
&mut self,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading