From 2d6c90cdad96e8438bc76b42cb53ccfdf626e0a2 Mon Sep 17 00:00:00 2001 From: Stefano Cunego <93382903+kukkok3@users.noreply.github.com> Date: Fri, 12 Aug 2022 10:19:36 +0200 Subject: [PATCH] making query limit parameters constant (#4071) --- .../src/jormungandr/explorer/configuration.rs | 8 +-- .../src/jormungandr/explorer/mod.rs | 4 +- .../src/jormungandr/explorer/certificates.rs | 69 +++++++------------ .../jormungandr/explorer/explorer_sanity.rs | 2 +- .../src/jormungandr/explorer/transaction.rs | 2 +- 5 files changed, 33 insertions(+), 52 deletions(-) diff --git a/testing/jormungandr-automation/src/jormungandr/explorer/configuration.rs b/testing/jormungandr-automation/src/jormungandr/explorer/configuration.rs index 8401da2cf8..142c40a1d9 100644 --- a/testing/jormungandr-automation/src/jormungandr/explorer/configuration.rs +++ b/testing/jormungandr-automation/src/jormungandr/explorer/configuration.rs @@ -1,14 +1,14 @@ #[derive(Clone)] pub struct ExplorerParams { - pub query_complexity_limit: Option, - pub query_depth_limit: Option, + pub query_complexity_limit: Option, + pub query_depth_limit: Option, pub address_bech32_prefix: Option, } impl ExplorerParams { pub fn new( - query_complexity_limit: impl Into>, - query_depth_limit: impl Into>, + query_complexity_limit: impl Into>, + query_depth_limit: impl Into>, address_bech32_prefix: impl Into>, ) -> ExplorerParams { ExplorerParams { diff --git a/testing/jormungandr-automation/src/jormungandr/explorer/mod.rs b/testing/jormungandr-automation/src/jormungandr/explorer/mod.rs index 758178deab..e207cb073b 100644 --- a/testing/jormungandr-automation/src/jormungandr/explorer/mod.rs +++ b/testing/jormungandr-automation/src/jormungandr/explorer/mod.rs @@ -82,14 +82,14 @@ impl ExplorerProcess { if params.query_depth_limit.is_some() { explorer_cmd.args([ "--query-depth-limit", - params.query_depth_limit.unwrap().as_ref(), + ¶ms.query_depth_limit.unwrap().to_string(), ]); } if params.query_complexity_limit.is_some() { explorer_cmd.args([ "--query-complexity-limit", - params.query_complexity_limit.unwrap().as_ref(), + ¶ms.query_complexity_limit.unwrap().to_string(), ]); } diff --git a/testing/jormungandr-integration-tests/src/jormungandr/explorer/certificates.rs b/testing/jormungandr-integration-tests/src/jormungandr/explorer/certificates.rs index a4cd1c7049..e0a6402594 100644 --- a/testing/jormungandr-integration-tests/src/jormungandr/explorer/certificates.rs +++ b/testing/jormungandr-integration-tests/src/jormungandr/explorer/certificates.rs @@ -30,10 +30,11 @@ use thor::{ BlockDateGenerator::Fixed, FragmentBuilder, FragmentSender, StakePool, TransactionHash, }; +const TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT: u64 = 140; +const TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT: u64 = 30; + #[test] pub fn explorer_stake_pool_registration_test() { - let query_complexity_limit = 140; - let query_depth_limit = 30; let temp_dir = TempDir::new().unwrap(); let mut first_stake_pool_owner = thor::Wallet::default(); let first_stake_pool = StakePool::new(&first_stake_pool_owner); @@ -61,8 +62,8 @@ pub fn explorer_stake_pool_registration_test() { ); let params = ExplorerParams::new( - query_complexity_limit.to_string(), - query_depth_limit.to_string(), + TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT, + TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT, None, ); let explorer_process = jormungandr.explorer(params); @@ -96,8 +97,6 @@ pub fn explorer_stake_pool_registration_test() { #[test] pub fn explorer_owner_delegation_test() { - let query_complexity_limit = 140; - let query_depth_limit = 30; let temp_dir = TempDir::new().unwrap(); let mut stake_pool_owner = thor::Wallet::default(); let stake_pool = StakePool::new(&stake_pool_owner); @@ -133,8 +132,8 @@ pub fn explorer_owner_delegation_test() { .expect("Error while sending registration certificate for stake pool owner"); let params = ExplorerParams::new( - query_complexity_limit.to_string(), - query_depth_limit.to_string(), + TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT, + TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT, None, ); let explorer_process = jormungandr.explorer(params); @@ -167,8 +166,6 @@ pub fn explorer_owner_delegation_test() { #[test] pub fn explorer_full_delegation_test() { - let query_complexity_limit = 140; - let query_depth_limit = 30; let temp_dir = TempDir::new().unwrap(); let mut stake_pool_owner = thor::Wallet::default(); let mut full_delegator = thor::Wallet::default(); @@ -209,8 +206,8 @@ pub fn explorer_full_delegation_test() { .expect("Error while sending registration certificate for stake pool owner"); let params = ExplorerParams::new( - query_complexity_limit.to_string(), - query_depth_limit.to_string(), + TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT, + TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT, None, ); let explorer_process = jormungandr.explorer(params); @@ -243,8 +240,6 @@ pub fn explorer_full_delegation_test() { #[test] pub fn explorer_split_delegation_test() { - let query_complexity_limit = 140; - let query_depth_limit = 30; let temp_dir = TempDir::new().unwrap(); let mut first_stake_pool_owner = thor::Wallet::default(); let mut split_delegator = thor::Wallet::default(); @@ -303,8 +298,8 @@ pub fn explorer_split_delegation_test() { .expect("Error while sending registration certificate for stake pool owner"); let params = ExplorerParams::new( - query_complexity_limit.to_string(), - query_depth_limit.to_string(), + TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT, + TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT, None, ); let explorer_process = jormungandr.explorer(params); @@ -340,8 +335,6 @@ pub fn explorer_split_delegation_test() { #[test] pub fn explorer_pool_update_test() { - let query_complexity_limit = 140; - let query_depth_limit = 30; let jcli: JCli = Default::default(); let temp_dir = TempDir::new().unwrap(); let mut first_stake_pool_owner = thor::Wallet::default(); @@ -372,8 +365,8 @@ pub fn explorer_pool_update_test() { ); let params = ExplorerParams::new( - query_complexity_limit.to_string(), - query_depth_limit.to_string(), + TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT, + TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT, None, ); let explorer_process = jormungandr.explorer(params); @@ -428,8 +421,6 @@ pub fn explorer_pool_update_test() { #[test] pub fn explorer_pool_retire_test() { - let query_complexity_limit = 140; - let query_depth_limit = 30; let temp_dir = TempDir::new().unwrap(); let mut first_stake_pool_owner = thor::Wallet::default(); let first_stake_pool = StakePool::new(&first_stake_pool_owner); @@ -458,8 +449,8 @@ pub fn explorer_pool_retire_test() { ); let params = ExplorerParams::new( - query_complexity_limit.to_string(), - query_depth_limit.to_string(), + TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT, + TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT, None, ); let explorer_process = jormungandr.explorer(params); @@ -507,8 +498,6 @@ pub fn explorer_pool_retire_test() { pub fn explorer_evm_mapping_certificates_test() { let temp_dir = TempDir::new().unwrap(); let mut first_stake_pool_owner = thor::Wallet::default(); - let query_complexity_limit = 70; - let query_depth_limit = 30; let config = ConfigurationBuilder::new() .with_funds(vec![first_stake_pool_owner.to_initial_fund(1_000_000)]) @@ -534,8 +523,8 @@ pub fn explorer_evm_mapping_certificates_test() { ); let params = ExplorerParams::new( - query_complexity_limit.to_string(), - query_depth_limit.to_string(), + TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT, + TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT, None, ); let explorer_process = jormungandr.explorer(params); @@ -573,8 +562,6 @@ pub fn explorer_evm_mapping_certificates_test() { #[test] pub fn explorer_vote_plan_certificates_test() { - let query_complexity_limit = 140; - let query_depth_limit = 30; let mut first_stake_pool_owner = thor::Wallet::default(); let bob = thor::Wallet::default(); let discrimination = Discrimination::Test; @@ -612,8 +599,8 @@ pub fn explorer_vote_plan_certificates_test() { ); let params = ExplorerParams::new( - query_complexity_limit.to_string(), - query_depth_limit.to_string(), + TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT, + TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT, None, ); let explorer_process = jormungandr.explorer(params); @@ -643,8 +630,6 @@ pub fn explorer_vote_plan_certificates_test() { #[test] pub fn explorer_vote_cast_certificates_test() { - let query_complexity_limit = 140; - let query_depth_limit = 30; let temp_dir = TempDir::new().unwrap(); let mut alice = thor::Wallet::default(); @@ -699,8 +684,8 @@ pub fn explorer_vote_cast_certificates_test() { ); let params = ExplorerParams::new( - query_complexity_limit.to_string(), - query_depth_limit.to_string(), + TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT, + TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT, None, ); let explorer_process = jormungandr.explorer(params); @@ -725,8 +710,6 @@ pub fn explorer_vote_cast_certificates_test() { #[test] pub fn explorer_vote_tally_certificate_test() { - let query_complexity_limit = 140; - let query_depth_limit = 30; let temp_dir = TempDir::new().unwrap(); let mut alice = thor::Wallet::default(); @@ -787,8 +770,8 @@ pub fn explorer_vote_tally_certificate_test() { ); let params = ExplorerParams::new( - query_complexity_limit.to_string(), - query_depth_limit.to_string(), + TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT, + TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT, None, ); let explorer_process = jormungandr.explorer(params); @@ -823,8 +806,6 @@ pub fn explorer_vote_tally_certificate_test() { #[should_panic] //bug NPG-2742 #[test] pub fn explorer_update_proposal_certificate_test() { - let query_complexity_limit = 140; - let query_depth_limit = 30; let temp_dir = TempDir::new().unwrap(); let mut alice = thor::Wallet::default(); let mut bob = thor::Wallet::default(); @@ -882,8 +863,8 @@ pub fn explorer_update_proposal_certificate_test() { ); let params = ExplorerParams::new( - query_complexity_limit.to_string(), - query_depth_limit.to_string(), + TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT, + TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT, None, ); let explorer_process = jormungandr.explorer(params); diff --git a/testing/jormungandr-integration-tests/src/jormungandr/explorer/explorer_sanity.rs b/testing/jormungandr-integration-tests/src/jormungandr/explorer/explorer_sanity.rs index 508e135907..f52520a095 100644 --- a/testing/jormungandr-integration-tests/src/jormungandr/explorer/explorer_sanity.rs +++ b/testing/jormungandr-integration-tests/src/jormungandr/explorer/explorer_sanity.rs @@ -63,7 +63,7 @@ pub fn explorer_sanity_test() { let (jormungandr, initial_stake_pools) = startup::start_stake_pool(&[faucet.clone()], &[], &mut config).unwrap(); - let params = ExplorerParams::new(query_complexity_limit.to_string(), None, None); + let params = ExplorerParams::new(query_complexity_limit, None, None); let explorer_process = jormungandr.explorer(params); let explorer = explorer_process.client(); diff --git a/testing/jormungandr-integration-tests/src/jormungandr/explorer/transaction.rs b/testing/jormungandr-integration-tests/src/jormungandr/explorer/transaction.rs index e14a39c3ee..c973e7ce21 100644 --- a/testing/jormungandr-integration-tests/src/jormungandr/explorer/transaction.rs +++ b/testing/jormungandr-integration-tests/src/jormungandr/explorer/transaction.rs @@ -27,7 +27,7 @@ pub fn explorer_transaction_test() { let (jormungandr, _initial_stake_pools) = startup::start_stake_pool(&[sender.clone()], &[], &mut config).unwrap(); - let params = ExplorerParams::new(query_complexity_limit.to_string(), None, None); + let params = ExplorerParams::new(query_complexity_limit, None, None); let explorer_process = jormungandr.explorer(params); let explorer = explorer_process.client();