From 72d08aa749e2be59f86b71ddd60d09703df6d60a Mon Sep 17 00:00:00 2001 From: hrxi Date: Mon, 29 Jan 2024 15:25:40 +0100 Subject: [PATCH] Run expensive tests regularly, but not on every pull request --- blockchain/Cargo.toml | 1 + blockchain/tests/push_with_chunks.rs | 2 +- consensus/Cargo.toml | 1 + consensus/tests/history_sync.rs | 1 - consensus/tests/request_component.rs | 2 +- primitives/account/tests/staking_contract/validator.rs | 2 +- validator/Cargo.toml | 1 + validator/tests/integration.rs | 2 +- validator/tests/mock.rs | 2 +- zkp/Cargo.toml | 1 + zkp/tests/prover/recursive_input.rs | 2 +- 11 files changed, 10 insertions(+), 7 deletions(-) diff --git a/blockchain/Cargo.toml b/blockchain/Cargo.toml index 75853fafb2..218de22ec6 100644 --- a/blockchain/Cargo.toml +++ b/blockchain/Cargo.toml @@ -63,4 +63,5 @@ nimiq-test-utils = { workspace = true } nimiq-zkp-primitives = { workspace = true } [features] +expensive-tests = [] metrics = ["prometheus-client"] diff --git a/blockchain/tests/push_with_chunks.rs b/blockchain/tests/push_with_chunks.rs index 5415f9f320..5dd9c284a6 100644 --- a/blockchain/tests/push_with_chunks.rs +++ b/blockchain/tests/push_with_chunks.rs @@ -252,7 +252,7 @@ fn can_ignore_chunks_with_invalid_start_key() { } #[test] -#[ignore] +#[cfg_attr(not(feature = "expensive-tests"), ignore)] fn can_rebranch_and_revert_chunks() { let temp_producer1 = TemporaryBlockProducer::new(); let temp_producer2 = TemporaryBlockProducer::new_incomplete(); diff --git a/consensus/Cargo.toml b/consensus/Cargo.toml index 9be9ed6076..1c6a41d91a 100644 --- a/consensus/Cargo.toml +++ b/consensus/Cargo.toml @@ -73,5 +73,6 @@ nimiq-trie = { workspace = true } nimiq-zkp-component = { workspace = true, features = ["zkp-prover", "parallel"] } [features] +expensive-tests = [] full = ["nimiq-blockchain", "nimiq-blockchain-proxy/full"] default = ["full"] diff --git a/consensus/tests/history_sync.rs b/consensus/tests/history_sync.rs index a0ee4f226b..8b08ff9e5e 100644 --- a/consensus/tests/history_sync.rs +++ b/consensus/tests/history_sync.rs @@ -96,7 +96,6 @@ async fn two_peers_can_sync_two_epochs() { } #[test(tokio::test)] -#[ignore] async fn three_peers_can_sync() { // FIXME: Add more tests // // Setup third peer (not synced yet). diff --git a/consensus/tests/request_component.rs b/consensus/tests/request_component.rs index 555802bf98..4eb2709cb2 100644 --- a/consensus/tests/request_component.rs +++ b/consensus/tests/request_component.rs @@ -15,8 +15,8 @@ use nimiq_test_utils::{ validator::seeded_rng, }; -#[ignore] #[test(tokio::test(flavor = "multi_thread", worker_threads = 4))] +#[cfg_attr(not(feature = "expensive-tests"), ignore)] async fn test_request_component() { let mut hub = Some(MockHub::default()); let env = VolatileDatabase::new(20).expect("Could not open a volatile database"); diff --git a/primitives/account/tests/staking_contract/validator.rs b/primitives/account/tests/staking_contract/validator.rs index 6e5f8f6680..c368af3de3 100644 --- a/primitives/account/tests/staking_contract/validator.rs +++ b/primitives/account/tests/staking_contract/validator.rs @@ -81,8 +81,8 @@ fn revert_penalize_inherent( } // The following code is kept as a reference on how to generate the constants. -#[ignore] #[test] +#[ignore] fn generate_contract_2() { let mut active_validators = BTreeMap::new(); active_validators.insert( diff --git a/validator/Cargo.toml b/validator/Cargo.toml index 1388686d6e..54a29f0afb 100644 --- a/validator/Cargo.toml +++ b/validator/Cargo.toml @@ -72,5 +72,6 @@ nimiq-test-log = { workspace = true } nimiq-test-utils = { workspace = true } [features] +expensive-tests = [] metrics = ["nimiq-mempool/metrics"] trusted_push = [] diff --git a/validator/tests/integration.rs b/validator/tests/integration.rs index 683d09bab9..3456dd8036 100644 --- a/validator/tests/integration.rs +++ b/validator/tests/integration.rs @@ -79,7 +79,7 @@ async fn validator_update() { } #[test(tokio::test(flavor = "multi_thread"))] -#[ignore] +#[cfg_attr(not(feature = "expensive-tests"), ignore)] async fn four_validators_can_create_an_epoch() { let env = VolatileDatabase::new(20).expect("Could not open a volatile database"); diff --git a/validator/tests/mock.rs b/validator/tests/mock.rs index aa9d6f2559..6dbcc1dbfb 100644 --- a/validator/tests/mock.rs +++ b/validator/tests/mock.rs @@ -202,8 +202,8 @@ fn create_skip_block_update( ) } -#[ignore] #[test(tokio::test)] +#[cfg_attr(not(feature = "expensive-tests"), ignore)] async fn validator_can_catch_up() { // remove first block producer in order to trigger a skip block. Never connect him again // remove the second block producer to trigger another skip block after the first one (which we want someone to catch up to). Never connect him again diff --git a/zkp/Cargo.toml b/zkp/Cargo.toml index c0bbc7c435..c54089a8a6 100644 --- a/zkp/Cargo.toml +++ b/zkp/Cargo.toml @@ -51,6 +51,7 @@ nimiq-test-utils = { workspace = true } nimiq-zkp-circuits = { workspace = true, features = ["zkp-prover"] } [features] +expensive-tests = [] parallel = ["nimiq-zkp-circuits/parallel", "nimiq-zkp-primitives/parallel", "ark-crypto-primitives/parallel", "ark-ec/parallel", "ark-ff/parallel", "ark-std/parallel", "ark-groth16/parallel"] zkp-prover = ["nimiq-zkp-circuits/zkp-prover", "nimiq-zkp-primitives/zkp-prover", "ark-crypto-primitives/r1cs", "ark-mnt4-753/r1cs", "ark-mnt6-753/r1cs", "ark-groth16/r1cs"] diff --git a/zkp/tests/prover/recursive_input.rs b/zkp/tests/prover/recursive_input.rs index dcd9241746..2ede569941 100644 --- a/zkp/tests/prover/recursive_input.rs +++ b/zkp/tests/prover/recursive_input.rs @@ -94,7 +94,7 @@ impl ConstraintSynthesizer for OuterCircuit { // This test takes a very long time to finish, so run it only when necessary. #[test] -#[ignore] +#[cfg_attr(not(feature = "expensive-tests"), ignore)] fn recursive_input_works() { // Create random number generator. let rng = &mut test_rng(false);