Skip to content
Merged
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
17 changes: 5 additions & 12 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ jobs:
Codecov:
name: Code Coverage
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-Cinstrument-coverage"
RUSTDOCFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "./target/coverage/%p-%m.profraw"

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -23,20 +18,18 @@ jobs:
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: nightly
override: true
profile: minimal
components: llvm-tools-preview
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.8
- name: Install grcov
run: if [[ ! -e ~/.cargo/bin/grcov ]]; then cargo install grcov; fi
- name: Test
run: cargo test --all-features
- name: Install cargo-llvm-cov
run: if [[ ! -e ~/.cargo/bin/cargo-llvm-cov ]]; then cargo install cargo-llvm-cov; fi
- name: Make coverage directory
run: mkdir coverage
- name: Run grcov
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --keep-only '**/crates/**' --ignore '**/tests/**' --ignore '**/examples/**' -o ./coverage/lcov.info
- name: Test and report coverage
run: cargo +nightly llvm-cov -q --doctests --branch --all --ignore-filename-regex "(example*|crates/testenv/*)" --all-features --lcov --output-path ./coverage/lcov.info
- name: Generate HTML coverage report
run: genhtml -o coverage-report.html --ignore-errors unmapped ./coverage/lcov.info
- name: Coveralls upload
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ authors = ["Bitcoin Dev Kit Developers"]
[workspace.lints.clippy]
print_stdout = "deny"
print_stderr = "deny"

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage,coverage_nightly)'] }
2 changes: 2 additions & 0 deletions crates/bitcoind_rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//! To only get block updates (exclude mempool transactions), the caller can use
//! [`Emitter::next_block`] until it returns `Ok(None)` (which means the chain tip is reached). A
//! separate method, [`Emitter::mempool`] can be used to emit the whole mempool.
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
#![warn(missing_docs)]

use bdk_core::{BlockId, CheckPoint};
Expand Down Expand Up @@ -444,6 +445,7 @@ impl BitcoindRpcErrorExt for bitcoincore_rpc::Error {
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod test {
use crate::{bitcoincore_rpc::RpcApi, Emitter, NO_EXPECTED_MEMPOOL_TXIDS};
use bdk_chain::local_chain::LocalChain;
Expand Down
1 change: 1 addition & 0 deletions crates/chain/src/chain_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ impl<A: Anchor> FullTxOut<A> {
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod test {
use bdk_core::ConfirmationBlockTime;

Expand Down
1 change: 1 addition & 0 deletions crates/chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
)]
#![no_std]
#![warn(missing_docs)]
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]

pub use bitcoin;
mod balance;
Expand Down
1 change: 1 addition & 0 deletions crates/chain/src/rusqlite_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ impl keychain_txout::ChangeSet {
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod test {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions crates/chain/src/spk_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ where
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod test {
use crate::{
bitcoin::secp256k1::Secp256k1,
Expand Down
1 change: 1 addition & 0 deletions crates/electrum/src/bdk_electrum_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ fn chain_update(
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod test {
use crate::{bdk_electrum_client::TxUpdate, BdkElectrumClient};
use bdk_chain::bitcoin::{OutPoint, Transaction, TxIn};
Expand Down
2 changes: 1 addition & 1 deletion crates/electrum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//! [`example_electrum`]: https://github.com/bitcoindevkit/bdk/tree/master/examples/example_electrum
//! [`SyncResponse`]: bdk_core::spk_client::SyncResponse
//! [`FullScanResponse`]: bdk_core::spk_client::FullScanResponse

#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
#![warn(missing_docs)]

mod bdk_electrum_client;
Expand Down
1 change: 1 addition & 0 deletions crates/esplora/src/async_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ where
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod test {
use std::{collections::BTreeSet, time::Duration};

Expand Down
1 change: 1 addition & 0 deletions crates/esplora/src/blocking_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ fn fetch_txs_with_outpoints<I: IntoIterator<Item = OutPoint>>(
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod test {
use crate::blocking_ext::{chain_update, fetch_latest_blocks};
use bdk_chain::bitcoin;
Expand Down
1 change: 1 addition & 0 deletions crates/esplora/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
//! Just like how [`EsploraExt`] extends the functionality of an
//! [`esplora_client::BlockingClient`], [`EsploraAsyncExt`] is the async version which extends
//! [`esplora_client::AsyncClient`].
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]

use bdk_core::bitcoin::{Amount, OutPoint, TxOut, Txid};
use bdk_core::{BlockId, ConfirmationBlockTime, TxUpdate};
Expand Down
1 change: 1 addition & 0 deletions crates/file_store/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![doc = include_str!("../README.md")]
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
mod entry_iter;
mod store;
use std::io;
Expand Down
1 change: 1 addition & 0 deletions crates/file_store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ impl<C> std::fmt::Display for StoreErrorWithDump<C> {
impl<C: fmt::Debug> std::error::Error for StoreErrorWithDump<C> {}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod test {
use super::*;

Expand Down
2 changes: 1 addition & 1 deletion crates/testenv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ std = ["bdk_chain/std"]
serde = ["bdk_chain/serde"]

[package.metadata.docs.rs]
no-default-features = true
no-default-features = true
3 changes: 3 additions & 0 deletions crates/testenv/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]

pub mod utils;

use bdk_chain::{
Expand Down Expand Up @@ -311,6 +313,7 @@ impl TestEnv {
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod test {
use crate::TestEnv;
use core::time::Duration;
Expand Down
Loading