diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/crates/chain-config/src/config/contract.rs b/crates/chain-config/src/config/contract.rs index ac6173d330..1405eb1a35 100644 --- a/crates/chain-config/src/config/contract.rs +++ b/crates/chain-config/src/config/contract.rs @@ -42,7 +42,7 @@ pub struct ContractConfig { } #[serde_as] -#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)] +#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq, PartialOrd, Ord)] pub struct ContractStateConfig { pub key: Bytes32, #[serde_as(as = "HexIfHumanReadable")] diff --git a/crates/fuel-core/src/database/state.rs b/crates/fuel-core/src/database/state.rs index e042e1657e..a30b697d19 100644 --- a/crates/fuel-core/src/database/state.rs +++ b/crates/fuel-core/src/database/state.rs @@ -196,8 +196,12 @@ mod tests { mod update_contract_state { use core::iter::repeat_with; - use fuel_core_chain_config::Randomize; + use fuel_core_chain_config::{ + ContractStateConfig, + Randomize, + }; + use fuel_core_storage::iter::IteratorOverTable; use fuel_core_types::fuel_merkle::sparse::{ self, MerkleTreeKey, @@ -209,7 +213,7 @@ mod tests { use std::collections::HashSet; use super::*; - #[cfg(all(test, feature = "random", feature = "std"))] + #[test] fn states_inserted_into_db() { // given @@ -231,29 +235,29 @@ mod tests { } // then - let states_in_db: Vec<_> = database + let mut states_in_db: Vec<_> = database .iter_all::(None) .collect::, _>>() .unwrap() .into_iter() - .map(|(key, value)| { - let contract_id = *key.contract_id(); - let key = *key.state_key(); - - ContractStateConfig { - contract_id, - key, - value: value.0, - } + .map(|(key, value)| ContractStateConfig { + key: *key.state_key(), + value: value.0, }) .collect(); - let original_state = state_groups + let mut original_state = state_groups .into_iter() .flatten() - .sorted() + .map(|entry| ContractStateConfig { + key: *entry.key.state_key(), + value: entry.value.into(), + }) .collect::>(); + states_in_db.sort(); + original_state.sort(); + assert_eq!(states_in_db, original_state); } diff --git a/crates/services/upgradable-executor/build.rs b/crates/services/upgradable-executor/build.rs index b1cd667dae..13cfd3f13f 100644 --- a/crates/services/upgradable-executor/build.rs +++ b/crates/services/upgradable-executor/build.rs @@ -73,6 +73,10 @@ fn build_wasm() { cargo.env("CARGO_PROFILE_RELEASE_OPT_LEVEL", "3"); cargo.env("CARGO_PROFILE_RELEASE_STRIP", "symbols"); cargo.env("CARGO_PROFILE_RELEASE_DEBUG", "false"); + if env::var("CARGO_CFG_COVERAGE").is_ok() { + // wasm doesn't support coverage + cargo.env("CARGO_ENCODED_RUSTFLAGS", ""); + } cargo.current_dir(project_root()).args(args); let output = cargo.output(); diff --git a/crates/services/upgradable-executor/src/executor.rs b/crates/services/upgradable-executor/src/executor.rs index f1ed8ce12d..93820d9be7 100644 --- a/crates/services/upgradable-executor/src/executor.rs +++ b/crates/services/upgradable-executor/src/executor.rs @@ -608,8 +608,12 @@ where } #[allow(clippy::cast_possible_truncation)] +#[allow(unexpected_cfgs)] // for cfg(coverage) #[cfg(test)] mod test { + #[cfg(coverage)] + use ntest as _; // Only used outside cdg(coverage) + use super::*; use fuel_core_storage::{ kv_store::Value, @@ -980,6 +984,7 @@ mod test { // The test verifies that `Executor::get_module` method caches the compiled WASM module. // If it doesn't cache the modules, the test will fail with a timeout. #[test] + #[cfg(not(coverage))] // Too slow for coverage #[ntest::timeout(60_000)] fn reuse_cached_compiled_module__native_strategy() { // Given @@ -1000,6 +1005,7 @@ mod test { // The test verifies that `Executor::get_module` method caches the compiled WASM module. // If it doesn't cache the modules, the test will fail with a timeout. #[test] + #[cfg(not(coverage))] // Too slow for coverage #[ntest::timeout(60_000)] fn reuse_cached_compiled_module__wasm_strategy() { // Given diff --git a/tests/tests/blocks.rs b/tests/tests/blocks.rs index b05d52178b..c9978cdac0 100644 --- a/tests/tests/blocks.rs +++ b/tests/tests/blocks.rs @@ -356,6 +356,7 @@ mod full_block { schema_path = "../crates/client/assets/schema.sdl", graphql_type = "Block" )] + #[allow(dead_code)] pub struct FullBlock { pub id: BlockId, pub header: Header, diff --git a/tests/tests/poa.rs b/tests/tests/poa.rs index bc6d93bd55..72c1975cc7 100644 --- a/tests/tests/poa.rs +++ b/tests/tests/poa.rs @@ -1,3 +1,5 @@ +#![allow(unexpected_cfgs)] // for cfg(coverage) + use fuel_core::{ combined_database::CombinedDatabase, service::{ @@ -83,6 +85,7 @@ async fn can_get_sealed_block_from_poa_produced_block() { } #[cfg(feature = "p2p")] +#[cfg(not(coverage))] // too slow for coverage mod p2p { use super::*; use fuel_core::{ diff --git a/tests/tests/sync.rs b/tests/tests/sync.rs index d07a402c21..54b709d78f 100644 --- a/tests/tests/sync.rs +++ b/tests/tests/sync.rs @@ -1,3 +1,5 @@ +#![allow(unexpected_cfgs)] // for cfg(coverage) + use fuel_core::p2p_test_helpers::*; use fuel_core_types::{ fuel_crypto::SecretKey, @@ -12,7 +14,6 @@ use std::{ collections::{ hash_map::DefaultHasher, HashMap, - VecDeque, }, hash::{ Hash, @@ -127,11 +128,14 @@ async fn test_partition_single(num_txs: usize) { #[test_case(10, 8, 4; "partition with 10 txs 8 validators 4 partitions")] #[test_case(100, 8, 4; "partition with 100 txs 8 validators 4 partitions")] #[tokio::test(flavor = "multi_thread")] +#[cfg(not(coverage))] // This test is too slow for coverage async fn test_partitions_larger_groups( num_txs: usize, num_validators: usize, num_partitions: usize, ) { + use std::collections::VecDeque; + // Create a random seed based on the test parameters. let mut hasher = DefaultHasher::new(); (num_txs, num_validators, num_partitions, line!()).hash(&mut hasher);