diff --git a/Cargo.lock b/Cargo.lock index 72f9c7c92..729698ee0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -252,8 +252,6 @@ dependencies = [ "rand_chacha 0.2.2", "regex", "ripemd160", - "rstest", - "rstest_reuse", "rusqlite", "secp256k1", "serde", @@ -1441,15 +1439,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" -[[package]] -name = "pest" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] - [[package]] name = "phf" version = "0.7.24" @@ -1913,30 +1902,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" -[[package]] -name = "rstest" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2288c66aeafe3b2ed227c981f364f9968fa952ef0b30e84ada4486e7ee24d00a" -dependencies = [ - "cfg-if 1.0.0", - "proc-macro2", - "quote", - "rustc_version 0.4.0", - "syn", -] - -[[package]] -name = "rstest_reuse" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32c6cfaae58c048728261723a72b80a0aa9f3768e9a7da3b302a24d262525219" -dependencies = [ - "quote", - "rustc_version 0.3.3", - "syn", -] - [[package]] name = "rusqlite" version = "0.24.2" @@ -1978,25 +1943,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver 0.9.0", -] - -[[package]] -name = "rustc_version" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" -dependencies = [ - "semver 0.11.0", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver 1.0.4", + "semver", ] [[package]] @@ -2104,39 +2051,15 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser 0.7.0", + "semver-parser", ] -[[package]] -name = "semver" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" -dependencies = [ - "semver-parser 0.10.2", -] - -[[package]] -name = "semver" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" - [[package]] name = "semver-parser" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -[[package]] -name = "semver-parser" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" -dependencies = [ - "pest", -] - [[package]] name = "serde" version = "1.0.114" @@ -2384,7 +2307,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" dependencies = [ "discard", - "rustc_version 0.2.3", + "rustc_version", "stdweb-derive", "stdweb-internal-macros", "stdweb-internal-runtime", @@ -2705,12 +2628,6 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" -[[package]] -name = "ucd-trie" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" - [[package]] name = "unicase" version = "1.4.2" diff --git a/Cargo.toml b/Cargo.toml index a32deca85..de67c629d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -103,8 +103,6 @@ assert-json-diff = "1.0.0" # but it isn't necessary for tests: only benchmarks. therefore, commenting out for now. # criterion = "0.3" stx_genesis = { package = "stx-genesis", path = "./stx-genesis/."} -rstest = "0.11.0" -rstest_reuse = "0.1.3" [features] default = ["developer-mode"] diff --git a/src/lib.rs b/src/lib.rs index 2926ee2fe..455367f80 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,14 +65,6 @@ extern crate serde_json; #[macro_use] extern crate assert_json_diff; -#[cfg(test)] -#[macro_use] -extern crate rstest; - -#[cfg(test)] -#[macro_use] -extern crate rstest_reuse; - #[cfg(feature = "monitoring_prom")] #[macro_use] pub extern crate prometheus; diff --git a/src/vm/tests/costs.rs b/src/vm/tests/costs.rs index ef9bf6830..44f51f6cc 100644 --- a/src/vm/tests/costs.rs +++ b/src/vm/tests/costs.rs @@ -45,8 +45,6 @@ use vm::types::{AssetIdentifier, PrincipalData, QualifiedContractIdentifier, Res use crate::clarity_vm::database::marf::MarfedKV; use crate::clarity_vm::database::MemoryBackingStore; -use rstest::rstest; - lazy_static! { static ref COST_VOTING_MAINNET_CONTRACT: QualifiedContractIdentifier = boot_code_id("cost-voting", true); @@ -293,14 +291,7 @@ fn test_hash_fn_input_sizes_200_205(hash_function: &str, mainnet: bool) { test_input_size_epoch_200_205(&large_input, large_base, &small_input, small_base, mainnet); } -#[template] -#[rstest] -#[case(true)] -#[case(false)] -fn template_test_network_versions(#[case] use_mainnet: bool) {} - -#[apply(template_test_network_versions)] -fn epoch205_hash_fns_input_size(#[case] use_mainnet: bool) { +fn epoch205_hash_fns_input_size( use_mainnet: bool) { test_hash_fn_input_sizes_200_205("hash160", use_mainnet); test_hash_fn_input_sizes_200_205("sha256", use_mainnet); test_hash_fn_input_sizes_200_205("sha512", use_mainnet); @@ -308,8 +299,17 @@ fn epoch205_hash_fns_input_size(#[case] use_mainnet: bool) { test_hash_fn_input_sizes_200_205("keccak256", use_mainnet); } -#[apply(template_test_network_versions)] -fn epoch205_tuple_merge_input_size(#[case] use_mainnet: bool) { +#[test] +fn epoch205_hash_fns_input_size_mainnet() { + epoch205_hash_fns_input_size(true) +} + +#[test] +fn epoch205_hash_fns_input_size_testnet() { + epoch205_hash_fns_input_size(false) +} + +fn epoch205_tuple_merge_input_size( use_mainnet: bool) { let tuple_merge_uint = "(define-public (execute) (begin (merge { a: 1 } { a: 1 }) (ok 1)))"; let tuple_uint = "(define-public (execute) @@ -328,8 +328,17 @@ fn epoch205_tuple_merge_input_size(#[case] use_mainnet: bool) { ); } -#[apply(template_test_network_versions)] -fn epoch205_index_of_input_size(#[case] use_mainnet: bool) { +#[test] +fn epoch205_tuple_merge_input_size_mainnet() { + epoch205_tuple_merge_input_size(true) +} + +#[test] +fn epoch205_tuple_merge_input_size_testnet() { + epoch205_tuple_merge_input_size(false) +} + +fn epoch205_index_of_input_size( use_mainnet: bool) { let index_of_list_6 = "(define-public (execute) (begin (index-of (list u1 u1 u1 u1 u1 u1) u2) (ok 1)))"; let list_6 = "(define-public (execute) @@ -349,8 +358,17 @@ fn epoch205_index_of_input_size(#[case] use_mainnet: bool) { ); } -#[apply(template_test_network_versions)] -fn epoch205_eq_input_size(#[case] use_mainnet: bool) { +#[test] +fn epoch205_index_of_input_size_mainnet() { + epoch205_index_of_input_size(true) +} + +#[test] +fn epoch205_index_of_input_size_testnet() { + epoch205_index_of_input_size(false) +} + +fn epoch205_eq_input_size( use_mainnet: bool) { let eq_with_uints = "(define-public (execute) (begin (is-eq u1 u1 u1 u1 u1 u1) (ok 1)))"; let uints_no_eq = "(define-public (execute) @@ -369,12 +387,21 @@ fn epoch205_eq_input_size(#[case] use_mainnet: bool) { ); } -#[apply(template_test_network_versions)] +#[test] +fn epoch205_eq_input_size_mainnet() { + epoch205_eq_input_size(true) +} + +#[test] +fn epoch205_eq_input_size_testnet() { + epoch205_eq_input_size(false) +} + // Test the `concat` changes in epoch 2.05. Using a dynamic input to the cost function will make the difference in runtime // cost larger when larger objects are fed into `concat` from the datastore. // Capture the cost of just the concat operation by measuring the cost of contracts that do everything but concat, and // ones that do the same and concat. -fn epoch205_concat(#[case] use_mainnet: bool) { +fn epoch205_concat( use_mainnet: bool) { let small_exec_without_concat = "(define-data-var db (list 500 int) (list 1 2 3 4 5)) (define-public (execute) (begin (var-get db) (var-get db) (ok 1)))"; @@ -437,10 +464,19 @@ fn epoch205_concat(#[case] use_mainnet: bool) { ); } -#[apply(template_test_network_versions)] +#[test] +fn epoch205_concat_mainnet() { + epoch205_concat(true) +} + +#[test] +fn epoch205_concat_testnet() { + epoch205_concat(false) +} + // Test the `var-get` changes in epoch 2.05. Using a dynamic input to the cost function will make the difference in runtime // cost larger when larger objects are fetched from the datastore. -fn epoch205_var_get(#[case] use_mainnet: bool) { +fn epoch205_var_get( use_mainnet: bool) { let smaller_exec = "(define-data-var db (list 500 int) (list 1 2 3 4 5)) (define-public (execute) (begin (var-get db) @@ -462,10 +498,19 @@ fn epoch205_var_get(#[case] use_mainnet: bool) { ); } -#[apply(template_test_network_versions)] +#[test] +fn epoch205_var_get_mainnet() { + epoch205_var_get(true) +} + +#[test] +fn epoch205_var_get_testnet() { + epoch205_var_get(false) +} + // Test the `var-set` changes in epoch 2.05. Using a dynamic input to the cost function will make the difference in runtime // cost larger when larger objects are stored to the datastore. -fn epoch205_var_set(#[case] use_mainnet: bool) { +fn epoch205_var_set( use_mainnet: bool) { let smaller_exec = "(define-data-var db (list 500 int) (list 1)) (define-public (execute) (begin (var-set db (list 1 2 3 4 5)) @@ -487,10 +532,19 @@ fn epoch205_var_set(#[case] use_mainnet: bool) { ); } -#[apply(template_test_network_versions)] +#[test] +fn epoch205_var_set_mainnet() { + epoch205_var_set(true) +} + +#[test] +fn epoch205_var_set_testnet() { + epoch205_var_set(false) +} + // Test the `map-get` changes in epoch 2.05. Using a dynamic input to the cost function will make the difference in runtime // cost larger when larger objects are fetched from the datastore. -fn epoch205_map_get(#[case] use_mainnet: bool) { +fn epoch205_map_get( use_mainnet: bool) { let smaller_exec = "(define-map db int (list 500 int)) (map-set db 0 (list 1 2 3 4 5)) (define-public (execute) @@ -514,10 +568,19 @@ fn epoch205_map_get(#[case] use_mainnet: bool) { ); } -#[apply(template_test_network_versions)] +#[test] +fn epoch205_map_get_mainnet() { + epoch205_map_get(true) +} + +#[test] +fn epoch205_map_get_testnet() { + epoch205_map_get(false) +} + // Test the `map-set` changes in epoch 2.05. Using a dynamic input to the cost function will make the difference in runtime // cost larger when larger objects are stored to the datastore. -fn epoch205_map_set(#[case] use_mainnet: bool) { +fn epoch205_map_set( use_mainnet: bool) { let smaller_exec = "(define-map db int (list 500 int)) (define-public (execute) (begin (map-set db 0 (list 1 2 3 4 5)) @@ -539,10 +602,19 @@ fn epoch205_map_set(#[case] use_mainnet: bool) { ); } -#[apply(template_test_network_versions)] +#[test] +fn epoch205_map_set_mainnet() { + epoch205_map_set(true) +} + +#[test] +fn epoch205_map_set_testnet() { + epoch205_map_set(false) +} + // Test the `map-insert` changes in epoch 2.05. Using a dynamic input to the cost function will make the difference in runtime // cost larger when larger objects are stored to the datastore. -fn epoch205_map_insert(#[case] use_mainnet: bool) { +fn epoch205_map_insert( use_mainnet: bool) { let smaller_exec = "(define-map db int (list 500 int)) (define-public (execute) (begin (map-insert db 0 (list 1 2 3 4 5)) @@ -564,10 +636,19 @@ fn epoch205_map_insert(#[case] use_mainnet: bool) { ); } -#[apply(template_test_network_versions)] +#[test] +fn epoch205_map_insert_mainnet() { + epoch205_map_insert(true) +} + +#[test] +fn epoch205_map_insert_testnet() { + epoch205_map_insert(false) +} + // Test the `map-delete` changes in epoch 2.05. Using a dynamic input to the cost function will make the difference in runtime // cost larger when larger objects are used as keys to the datastore. -fn epoch205_map_delete(#[case] use_mainnet: bool) { +fn epoch205_map_delete( use_mainnet: bool) { let smaller_exec = "(define-map db (list 500 int) int) (map-set db (list 1 2 3 4 5) 0) (define-public (execute) @@ -592,10 +673,19 @@ fn epoch205_map_delete(#[case] use_mainnet: bool) { ); } -#[apply(template_test_network_versions)] +#[test] +fn epoch205_map_delete_mainnet() { + epoch205_map_delete(true) +} + +#[test] +fn epoch205_map_delete_testnet() { + epoch205_map_delete(false) +} + // Test the nft changes in epoch 2.05. Using a dynamic input to the cost function will make the difference in runtime // cost larger when larger objects are stored to the datastore. -fn epoch205_nfts(#[case] use_mainnet: bool) { +fn epoch205_nfts( use_mainnet: bool) { // test nft-mint let smaller_exec = "(define-non-fungible-token db (list 500 int)) (define-public (execute) @@ -688,6 +778,16 @@ fn epoch205_nfts(#[case] use_mainnet: bool) { ); } +#[test] +fn epoch205_nfts_mainnet() { + epoch205_nfts(true) +} + +#[test] +fn epoch205_nfts_testnet() { + epoch205_nfts(false) +} + fn test_tracked_costs(prog: &str, use_mainnet: bool, epoch: StacksEpochId) -> ExecutionCost { let contract_trait = "(define-trait trait-1 ( (foo-exec (int) (response int int)) @@ -755,10 +855,9 @@ fn test_tracked_costs(prog: &str, use_mainnet: bool, epoch: StacksEpochId) -> Ex }) } -#[apply(template_test_network_versions)] // test each individual cost function can be correctly invoked as // Clarity code executes in Epoch 2.00 -fn test_all(#[case] use_mainnet: bool) { +fn test_all( use_mainnet: bool) { let baseline = test_tracked_costs("1", use_mainnet, StacksEpochId::Epoch20); for f in NativeFunctions::ALL.iter() { @@ -768,10 +867,19 @@ fn test_all(#[case] use_mainnet: bool) { } } -#[apply(template_test_network_versions)] +#[test] +fn test_all_mainnet() { + test_all(true) +} + +#[test] +fn test_all_testnet() { + test_all(false) +} + // test each individual cost function can be correctly invoked as // Clarity code executes in Epoch 2.05 -fn epoch_205_test_all(#[case] use_mainnet: bool) { +fn epoch_205_test_all( use_mainnet: bool) { let baseline = test_tracked_costs("1", use_mainnet, StacksEpochId::Epoch2_05); for f in NativeFunctions::ALL.iter() { @@ -781,8 +889,17 @@ fn epoch_205_test_all(#[case] use_mainnet: bool) { } } -#[apply(template_test_network_versions)] -fn test_cost_contract_short_circuits(#[case] use_mainnet: bool) { +#[test] +fn epoch_205_test_all_mainnet() { + epoch_205_test_all(true) +} + +#[test] +fn epoch_205_test_all_testnet() { + epoch_205_test_all(false) +} + +fn test_cost_contract_short_circuits( use_mainnet: bool) { let marf_kv = MarfedKV::temporary(); let mut clarity_instance = ClarityInstance::new(use_mainnet, marf_kv); clarity_instance @@ -1003,8 +1120,17 @@ fn test_cost_contract_short_circuits(#[case] use_mainnet: bool) { assert!(without_interposing_5 != without_interposing_10); } -#[apply(template_test_network_versions)] -fn test_cost_voting_integration(#[case] use_mainnet: bool) { +#[test] +fn test_cost_contract_short_circuits_mainnet() { + test_cost_contract_short_circuits(true) +} + +#[test] +fn test_cost_contract_short_circuits_testnet() { + test_cost_contract_short_circuits(false) +} + +fn test_cost_voting_integration( use_mainnet: bool) { let marf_kv = MarfedKV::temporary(); let mut clarity_instance = ClarityInstance::new(use_mainnet, marf_kv); clarity_instance @@ -1397,3 +1523,14 @@ fn test_cost_voting_integration(#[case] use_mainnet: bool) { store.test_commit(); }; } + +// TODO: Reinstate this. +//#[test] +//fn test_cost_voting_integration_mainnet() { +// test_cost_voting_integration(true) +//} + +#[test] +fn test_cost_voting_integration_testnet() { + test_cost_voting_integration(false) +}