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.

10 changes: 10 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,16 @@ fn handle_expression(
}
}

// TODO: #4587 create default for `SymbolicExpression`, then check if mutation tests are caught for these cases:
ASuciuX marked this conversation as resolved.
Show resolved Hide resolved
// 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<Vec<PreSymbolicExpression>> {
let mut parse_stack = Vec::new();

Expand Down
20 changes: 20 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,16 @@ impl<'a> Parser<'a> {
}
}

// TODO: #4587 create default for `SymbolicExpression`, then check if mutation tests are caught for these cases:
ASuciuX marked this conversation as resolved.
Show resolved Hide resolved
// 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.
///
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 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,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,
Expand Down
10 changes: 7 additions & 3 deletions clarity/src/vm/costs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,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
Expand Down Expand Up @@ -957,6 +957,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,
Expand Down
12 changes: 6 additions & 6 deletions clarity/src/vm/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1516,9 +1516,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<TupleData> {
let mut type_map = BTreeMap::new();
Expand All @@ -1536,9 +1536,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,
Expand Down
1 change: 1 addition & 0 deletions libsigner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ stackslib = { path = "../stackslib"}
thiserror = "1.0"
tiny_http = "0.12"
wsts = { workspace = true }
mutants = "0.0.3"
ASuciuX marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
mutants = "0.0.3"
Expand Down
4 changes: 4 additions & 0 deletions libsigner/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,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<T: SignerEventTrait>(
local_addr: Option<SocketAddr>,
Expand Down
1 change: 1 addition & 0 deletions pox-locking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
ASuciuX marked this conversation as resolved.
Show resolved Hide resolved

[features]
slog_json = ["stacks_common/slog_json", "clarity/slog_json"]
3 changes: 3 additions & 0 deletions pox-locking/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions stackslib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ features = ["serde"]
[dependencies.time]
version = "0.2.23"
features = ["std"]
mutants = "0.0.3"
ASuciuX marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
assert-json-diff = "1.0.0"
Expand Down
3 changes: 3 additions & 0 deletions stackslib/src/burnchains/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions stackslib/src/burnchains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions stackslib/src/chainstate/burn/db/sortdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ impl FromRow<LeaderBlockCommitOp> for LeaderBlockCommitOp {
}

impl FromRow<StackStxOp> 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<StackStxOp, db_error> {
let txid = Txid::from_column(row, "txid")?;
let vtxindex: u32 = row.get_unwrap("vtxindex");
Expand Down Expand Up @@ -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<bool, db_error> {
Expand Down
11 changes: 11 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,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<u8>) -> Option<ParsedData> {
/*
Wire format:
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions stackslib/src/chainstate/coordinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions stackslib/src/chainstate/stacks/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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.
///
Expand All @@ -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.
///
Expand All @@ -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.
///
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 16 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,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(
Expand Down Expand Up @@ -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<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 +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
Expand Down
Loading