Skip to content

Commit

Permalink
test(JSON-RPC): add option to ignore functions in converage report
Browse files Browse the repository at this point in the history
  • Loading branch information
nagmo-starkware committed Aug 13, 2023
1 parent 82a0848 commit 6178a18
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: npm install -g [email protected]
- name: Coverage
run: cargo llvm-cov --codecov --output-path codecov.json
run: cargo +nightly llvm-cov --codecov --output-path codecov.json
env:
SEED: 0
- name: Codecov
Expand Down
3 changes: 3 additions & 0 deletions crates/papyrus_config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// config compiler to support no_coverage feature when running coverage in nightly mode within this
// crate
#![cfg_attr(coverage_nightly, feature(no_coverage))]
#![warn(missing_docs)]
//! Configuration utilities for a Starknet node.
//!
Expand Down
5 changes: 5 additions & 0 deletions crates/papyrus_gateway/src/gateway_metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,16 @@ impl Logger for MetricLogger {
}
}

#[cfg_attr(coverage_nightly, no_coverage)]
fn on_request(&self, _transport: TransportProtocol) -> Self::Instant {
Instant::now()
}

// Required methods.
#[cfg_attr(coverage_nightly, no_coverage)]
fn on_connect(&self, _remote_addr: SocketAddr, _request: &HttpRequest, _t: TransportProtocol) {}

#[cfg_attr(coverage_nightly, no_coverage)]
fn on_call(
&self,
_method_name: &str,
Expand All @@ -88,6 +91,7 @@ impl Logger for MetricLogger {
) {
}

#[cfg_attr(coverage_nightly, no_coverage)]
fn on_response(
&self,
_result: &str,
Expand All @@ -96,6 +100,7 @@ impl Logger for MetricLogger {
) {
}

#[cfg_attr(coverage_nightly, no_coverage)]
fn on_disconnect(&self, _remote_addr: SocketAddr, _transport: TransportProtocol) {}
}

Expand Down
4 changes: 4 additions & 0 deletions crates/papyrus_gateway/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// config compiler to support no_coverage feature when running coverage in nightly mode within this
// crate
#![cfg_attr(coverage_nightly, feature(no_coverage))]

mod api;
mod gateway_metrics;
#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions crates/papyrus_gateway/src/v0_3_0/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ impl TransactionOutput {
}

impl From<starknet_api::transaction::TransactionOutput> for TransactionOutput {
#[cfg_attr(coverage_nightly, no_coverage)]
fn from(tx_output: starknet_api::transaction::TransactionOutput) -> Self {
match tx_output {
starknet_api::transaction::TransactionOutput::Declare(declare_tx_output) => {
Expand Down
1 change: 1 addition & 0 deletions crates/papyrus_gateway/src/v0_4_0/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ impl TransactionOutput {
}

impl From<starknet_api::transaction::TransactionOutput> for TransactionOutput {
#[cfg_attr(coverage_nightly, no_coverage)]
fn from(tx_output: starknet_api::transaction::TransactionOutput) -> Self {
match tx_output {
starknet_api::transaction::TransactionOutput::Declare(declare_tx_output) => {
Expand Down
4 changes: 4 additions & 0 deletions crates/papyrus_load_test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// config compiler to support no_coverage feature when running coverage in nightly mode within this
// crate
#![cfg_attr(coverage_nightly, feature(no_coverage))]

pub mod create_files;
pub mod create_request;
pub mod scenarios;
Expand Down
4 changes: 4 additions & 0 deletions crates/papyrus_monitoring_gateway/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// config compiler to support no_coverage feature when running coverage in nightly mode within this
// crate
#![cfg_attr(coverage_nightly, feature(no_coverage))]
#[cfg(test)]
mod gateway_test;

Expand Down Expand Up @@ -49,6 +52,7 @@ impl SerializeConfig for MonitoringGatewayConfig {
}

impl Display for MonitoringGatewayConfig {
#[cfg_attr(coverage_nightly, no_coverage)]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{self:?}")
}
Expand Down
5 changes: 5 additions & 0 deletions crates/papyrus_node/src/bin/dump_config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// config compiler to support no_coverage feature when running coverage in nightly mode within this
// crate
#![cfg_attr(coverage_nightly, feature(no_coverage))]

use lazy_static::lazy_static;
use papyrus_config::dumping::{ser_param, SerializeConfig};
use papyrus_config::{ParamPath, SerializedParam};
Expand Down Expand Up @@ -29,6 +33,7 @@ lazy_static! {

/// Updates the default config file by:
/// cargo run --bin dump_config -q
#[cfg_attr(coverage_nightly, no_coverage)]
fn main() {
NodeConfig::default()
.dump_to_file(&CONFIG_POINTERS, DEFAULT_CONFIG_PATH)
Expand Down
3 changes: 3 additions & 0 deletions crates/papyrus_node/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// config compiler to support no_coverage feature when running coverage in nightly mode within this
// crate
#![cfg_attr(coverage_nightly, feature(no_coverage))]
#[allow(unused_imports)]
pub mod config;
pub mod version;
2 changes: 2 additions & 0 deletions crates/papyrus_node/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ enum Metadata {
Stable,
}

#[cfg_attr(coverage_nightly, no_coverage)]
const fn version_str() -> &'static str {
const_format::concatcp!(VERSION_MAJOR, ".", VERSION_MINOR, ".", VERSION_PATCH)
}

#[cfg_attr(coverage_nightly, no_coverage)]
const fn full_version_str() -> &'static str {
match VERSION_META {
Metadata::Dev => const_format::concatcp!(VERSION, "-", DEV_VERSION_META),
Expand Down
3 changes: 3 additions & 0 deletions crates/papyrus_storage/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// config compiler to support no_coverage feature when running coverage in nightly mode within this
// crate
#![cfg_attr(coverage_nightly, feature(no_coverage))]
#![warn(missing_docs)]
//! A storage implementation for a [`Starknet`] node.
//!
Expand Down
4 changes: 4 additions & 0 deletions crates/papyrus_sync/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// config compiler to support no_coverage feature when running coverage in nightly mode within this
// crate
#![cfg_attr(coverage_nightly, feature(no_coverage))]

#[cfg(test)]
#[path = "sync_test.rs"]
mod sync_test;
Expand Down
4 changes: 4 additions & 0 deletions crates/starknet_client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// config compiler to support no_coverage feature when running coverage in nightly mode within this
// crate
#![cfg_attr(coverage_nightly, feature(no_coverage))]

//! This crate contains clients that can communicate with [`Starknet`] through the various
//! endpoints [`Starknet`] has.
//!
Expand Down

0 comments on commit 6178a18

Please sign in to comment.