Skip to content

Commit

Permalink
making query limit parameters constant (#4071)
Browse files Browse the repository at this point in the history
  • Loading branch information
kukkok3 committed Aug 12, 2022
1 parent f8cb3c3 commit 2d6c90c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#[derive(Clone)]
pub struct ExplorerParams {
pub query_complexity_limit: Option<String>,
pub query_depth_limit: Option<String>,
pub query_complexity_limit: Option<u64>,
pub query_depth_limit: Option<u64>,
pub address_bech32_prefix: Option<String>,
}

impl ExplorerParams {
pub fn new(
query_complexity_limit: impl Into<Option<String>>,
query_depth_limit: impl Into<Option<String>>,
query_complexity_limit: impl Into<Option<u64>>,
query_depth_limit: impl Into<Option<u64>>,
address_bech32_prefix: impl Into<Option<String>>,
) -> ExplorerParams {
ExplorerParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
&params.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(),
&params.query_complexity_limit.unwrap().to_string(),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)])
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand All @@ -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();

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 2d6c90c

Please sign in to comment.