Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Test/mutant testing modular #5

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/actions/bitcoin-int-tests/Dockerfile.mutation-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM rust:bullseye

# Set the working directory in the container
WORKDIR /src

# Copy all the files into the container
COPY . .

# Update rustup and build the project
RUN rustup update

# Install cargo-mutants
RUN cargo install cargo-mutants

# Remove old log folders (TODO: check if to delete)
# RUN rm -rf mutants.out mutants.out.old/

# Make a directory for mutants
RUN mkdir -p mutants

# Run mutants for different packages
RUN cargo mutants --package clarity --output mutants/clarity
RUN cargo mutants --package libsigner --output mutants/libsigner
# cargo mutants --package libstackerdb --output mutants/libstackerdb && \
# cargo mutants --package pox-locking --output mutants/pox-locking && \
# cargo mutants --package stacks-common --output mutants/stacks-common && \
# cargo mutants --package stx-genesis --output mutants/stx-genesis

# Comment out the commands for 'stacks-node' and 'stackslib' following the mutants.sh script
# RUN cargo mutants --package stacks-signer --output mutants/stacks-signer
# RUN cargo mutants --package stacks-node --output mutants/stacks-node
# RUN cargo mutants --package stackslib --output mutants/stackslib
28 changes: 26 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
workflow_dispatch:
inputs:
tag:
description: "The tag to create (optional)"
description: 'The tag to create (optional)'
required: false

concurrency:
Expand All @@ -38,7 +38,7 @@ jobs:
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt
- name: Rustfmt
- name: Rustfmt
id: rustfmt
uses: actions-rust-lang/rustfmt@v1

Expand Down Expand Up @@ -75,6 +75,30 @@ jobs:
base: ${{ env.BRANCH_NAME }}
head: HEAD

## Mutants testing
incremental-mutants:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Relative diff
run: |
git branch -av
git diff origin/${{ github.base_ref }}.. | tee git.diff
- uses: Swatinem/rust-cache@v2
- run: cargo install cargo-mutants
- name: Mutants
run: |
cargo mutants --no-shuffle -j 2 -vV --in-diff git.diff || true
- name: Archive mutants.out
uses: actions/upload-artifact@v3
if: always()
with:
name: mutants-incremental.out
path: mutants.out

###############################################
## Build Tagged Release
###############################################
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pip-log.txt
.coverage
.tox
nosetests.xml
mutants.out*

# Translations
*.mo
Expand Down
32 changes: 32 additions & 0 deletions build-scripts/mutants.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# Create mutants directory
mkdir mutants

# Run mutation testing for clarity package
cargo mutants --package clarity --output mutants/clarity

# Run mutation testing for libsigner package
cargo mutants --package libsigner --output mutants/libsigner

# Run mutation testing for libstackerdb package
cargo mutants --package libstackerdb --output mutants/libstackerdb

# Run mutation testing for pox-locking package
cargo mutants --package pox-locking --output mutants/pox-locking

# Run mutation testing for stacks-common package
cargo mutants --package stacks-common --output mutants/stacks-common

# Run mutation testing for stx-genesis package
cargo mutants --package stx-genesis --output mutants/stx-genesis


# Run mutation testing for stacks-signer package - working, 10 min approx.
# cargo mutants --package stacks-signer --output mutants/stacks-signer

# Commented out mutation testing for stacks-node package due to test errors and long compile/testing time
# cargo mutants --package stacks-node --output mutants/stacks-node

# Commented out mutation testing for stackslib package due to long compile/testing time
# cargo mutants --package stackslib --output mutants/stackslib
8 changes: 8 additions & 0 deletions pox-locking/src/pox_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@
Ok(amount_locked)
}

pub fn pox_lock_extend_v3_not_tested(

Check failure on line 104 in pox-locking/src/pox_3.rs

View workflow job for this annotation

GitHub Actions / clippy

function `pox_lock_extend_v3_not_tested` is never used

error: function `pox_lock_extend_v3_not_tested` is never used --> pox-locking/src/pox_3.rs:104:8 | 104 | pub fn pox_lock_extend_v3_not_tested( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D dead-code` implied by `-D warnings`
db: &mut ClarityDatabase,

Check failure on line 105 in pox-locking/src/pox_3.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `db`

error: unused variable: `db` --> pox-locking/src/pox_3.rs:105:5 | 105 | db: &mut ClarityDatabase, | ^^ help: if this is intentional, prefix it with an underscore: `_db` | = note: `-D unused-variables` implied by `-D warnings`
principal: &PrincipalData,

Check failure on line 106 in pox-locking/src/pox_3.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `principal`

error: unused variable: `principal` --> pox-locking/src/pox_3.rs:106:5 | 106 | principal: &PrincipalData, | ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_principal`
unlock_burn_height: u64,

Check failure on line 107 in pox-locking/src/pox_3.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `unlock_burn_height`

error: unused variable: `unlock_burn_height` --> pox-locking/src/pox_3.rs:107:5 | 107 | unlock_burn_height: u64, | ^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_unlock_burn_height`
) -> Result<u128, LockingError> {
Ok(1231)
}

/// Increase a STX lock up for PoX-3. Does NOT touch the account nonce.
/// Returns Ok( account snapshot ) when successful
///
Expand Down
3 changes: 3 additions & 0 deletions stx-genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ impl Iterator for LinePairReader {
None
}
}
fn count(self) -> usize {
32332
}
}

fn read_deflated_zonefiles(
Expand Down
Loading