Skip to content

Commit 2d6c90c

Browse files
authored
making query limit parameters constant (#4071)
1 parent f8cb3c3 commit 2d6c90c

File tree

5 files changed

+33
-52
lines changed

5 files changed

+33
-52
lines changed

testing/jormungandr-automation/src/jormungandr/explorer/configuration.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#[derive(Clone)]
22
pub struct ExplorerParams {
3-
pub query_complexity_limit: Option<String>,
4-
pub query_depth_limit: Option<String>,
3+
pub query_complexity_limit: Option<u64>,
4+
pub query_depth_limit: Option<u64>,
55
pub address_bech32_prefix: Option<String>,
66
}
77

88
impl ExplorerParams {
99
pub fn new(
10-
query_complexity_limit: impl Into<Option<String>>,
11-
query_depth_limit: impl Into<Option<String>>,
10+
query_complexity_limit: impl Into<Option<u64>>,
11+
query_depth_limit: impl Into<Option<u64>>,
1212
address_bech32_prefix: impl Into<Option<String>>,
1313
) -> ExplorerParams {
1414
ExplorerParams {

testing/jormungandr-automation/src/jormungandr/explorer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ impl ExplorerProcess {
8282
if params.query_depth_limit.is_some() {
8383
explorer_cmd.args([
8484
"--query-depth-limit",
85-
params.query_depth_limit.unwrap().as_ref(),
85+
&params.query_depth_limit.unwrap().to_string(),
8686
]);
8787
}
8888

8989
if params.query_complexity_limit.is_some() {
9090
explorer_cmd.args([
9191
"--query-complexity-limit",
92-
params.query_complexity_limit.unwrap().as_ref(),
92+
&params.query_complexity_limit.unwrap().to_string(),
9393
]);
9494
}
9595

testing/jormungandr-integration-tests/src/jormungandr/explorer/certificates.rs

Lines changed: 25 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ use thor::{
3030
BlockDateGenerator::Fixed, FragmentBuilder, FragmentSender, StakePool, TransactionHash,
3131
};
3232

33+
const TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT: u64 = 140;
34+
const TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT: u64 = 30;
35+
3336
#[test]
3437
pub fn explorer_stake_pool_registration_test() {
35-
let query_complexity_limit = 140;
36-
let query_depth_limit = 30;
3738
let temp_dir = TempDir::new().unwrap();
3839
let mut first_stake_pool_owner = thor::Wallet::default();
3940
let first_stake_pool = StakePool::new(&first_stake_pool_owner);
@@ -61,8 +62,8 @@ pub fn explorer_stake_pool_registration_test() {
6162
);
6263

6364
let params = ExplorerParams::new(
64-
query_complexity_limit.to_string(),
65-
query_depth_limit.to_string(),
65+
TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT,
66+
TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT,
6667
None,
6768
);
6869
let explorer_process = jormungandr.explorer(params);
@@ -96,8 +97,6 @@ pub fn explorer_stake_pool_registration_test() {
9697

9798
#[test]
9899
pub fn explorer_owner_delegation_test() {
99-
let query_complexity_limit = 140;
100-
let query_depth_limit = 30;
101100
let temp_dir = TempDir::new().unwrap();
102101
let mut stake_pool_owner = thor::Wallet::default();
103102
let stake_pool = StakePool::new(&stake_pool_owner);
@@ -133,8 +132,8 @@ pub fn explorer_owner_delegation_test() {
133132
.expect("Error while sending registration certificate for stake pool owner");
134133

135134
let params = ExplorerParams::new(
136-
query_complexity_limit.to_string(),
137-
query_depth_limit.to_string(),
135+
TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT,
136+
TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT,
138137
None,
139138
);
140139
let explorer_process = jormungandr.explorer(params);
@@ -167,8 +166,6 @@ pub fn explorer_owner_delegation_test() {
167166

168167
#[test]
169168
pub fn explorer_full_delegation_test() {
170-
let query_complexity_limit = 140;
171-
let query_depth_limit = 30;
172169
let temp_dir = TempDir::new().unwrap();
173170
let mut stake_pool_owner = thor::Wallet::default();
174171
let mut full_delegator = thor::Wallet::default();
@@ -209,8 +206,8 @@ pub fn explorer_full_delegation_test() {
209206
.expect("Error while sending registration certificate for stake pool owner");
210207

211208
let params = ExplorerParams::new(
212-
query_complexity_limit.to_string(),
213-
query_depth_limit.to_string(),
209+
TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT,
210+
TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT,
214211
None,
215212
);
216213
let explorer_process = jormungandr.explorer(params);
@@ -243,8 +240,6 @@ pub fn explorer_full_delegation_test() {
243240

244241
#[test]
245242
pub fn explorer_split_delegation_test() {
246-
let query_complexity_limit = 140;
247-
let query_depth_limit = 30;
248243
let temp_dir = TempDir::new().unwrap();
249244
let mut first_stake_pool_owner = thor::Wallet::default();
250245
let mut split_delegator = thor::Wallet::default();
@@ -303,8 +298,8 @@ pub fn explorer_split_delegation_test() {
303298
.expect("Error while sending registration certificate for stake pool owner");
304299

305300
let params = ExplorerParams::new(
306-
query_complexity_limit.to_string(),
307-
query_depth_limit.to_string(),
301+
TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT,
302+
TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT,
308303
None,
309304
);
310305
let explorer_process = jormungandr.explorer(params);
@@ -340,8 +335,6 @@ pub fn explorer_split_delegation_test() {
340335

341336
#[test]
342337
pub fn explorer_pool_update_test() {
343-
let query_complexity_limit = 140;
344-
let query_depth_limit = 30;
345338
let jcli: JCli = Default::default();
346339
let temp_dir = TempDir::new().unwrap();
347340
let mut first_stake_pool_owner = thor::Wallet::default();
@@ -372,8 +365,8 @@ pub fn explorer_pool_update_test() {
372365
);
373366

374367
let params = ExplorerParams::new(
375-
query_complexity_limit.to_string(),
376-
query_depth_limit.to_string(),
368+
TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT,
369+
TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT,
377370
None,
378371
);
379372
let explorer_process = jormungandr.explorer(params);
@@ -428,8 +421,6 @@ pub fn explorer_pool_update_test() {
428421

429422
#[test]
430423
pub fn explorer_pool_retire_test() {
431-
let query_complexity_limit = 140;
432-
let query_depth_limit = 30;
433424
let temp_dir = TempDir::new().unwrap();
434425
let mut first_stake_pool_owner = thor::Wallet::default();
435426
let first_stake_pool = StakePool::new(&first_stake_pool_owner);
@@ -458,8 +449,8 @@ pub fn explorer_pool_retire_test() {
458449
);
459450

460451
let params = ExplorerParams::new(
461-
query_complexity_limit.to_string(),
462-
query_depth_limit.to_string(),
452+
TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT,
453+
TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT,
463454
None,
464455
);
465456
let explorer_process = jormungandr.explorer(params);
@@ -507,8 +498,6 @@ pub fn explorer_pool_retire_test() {
507498
pub fn explorer_evm_mapping_certificates_test() {
508499
let temp_dir = TempDir::new().unwrap();
509500
let mut first_stake_pool_owner = thor::Wallet::default();
510-
let query_complexity_limit = 70;
511-
let query_depth_limit = 30;
512501

513502
let config = ConfigurationBuilder::new()
514503
.with_funds(vec![first_stake_pool_owner.to_initial_fund(1_000_000)])
@@ -534,8 +523,8 @@ pub fn explorer_evm_mapping_certificates_test() {
534523
);
535524

536525
let params = ExplorerParams::new(
537-
query_complexity_limit.to_string(),
538-
query_depth_limit.to_string(),
526+
TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT,
527+
TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT,
539528
None,
540529
);
541530
let explorer_process = jormungandr.explorer(params);
@@ -573,8 +562,6 @@ pub fn explorer_evm_mapping_certificates_test() {
573562

574563
#[test]
575564
pub fn explorer_vote_plan_certificates_test() {
576-
let query_complexity_limit = 140;
577-
let query_depth_limit = 30;
578565
let mut first_stake_pool_owner = thor::Wallet::default();
579566
let bob = thor::Wallet::default();
580567
let discrimination = Discrimination::Test;
@@ -612,8 +599,8 @@ pub fn explorer_vote_plan_certificates_test() {
612599
);
613600

614601
let params = ExplorerParams::new(
615-
query_complexity_limit.to_string(),
616-
query_depth_limit.to_string(),
602+
TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT,
603+
TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT,
617604
None,
618605
);
619606
let explorer_process = jormungandr.explorer(params);
@@ -643,8 +630,6 @@ pub fn explorer_vote_plan_certificates_test() {
643630

644631
#[test]
645632
pub fn explorer_vote_cast_certificates_test() {
646-
let query_complexity_limit = 140;
647-
let query_depth_limit = 30;
648633
let temp_dir = TempDir::new().unwrap();
649634
let mut alice = thor::Wallet::default();
650635

@@ -699,8 +684,8 @@ pub fn explorer_vote_cast_certificates_test() {
699684
);
700685

701686
let params = ExplorerParams::new(
702-
query_complexity_limit.to_string(),
703-
query_depth_limit.to_string(),
687+
TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT,
688+
TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT,
704689
None,
705690
);
706691
let explorer_process = jormungandr.explorer(params);
@@ -725,8 +710,6 @@ pub fn explorer_vote_cast_certificates_test() {
725710

726711
#[test]
727712
pub fn explorer_vote_tally_certificate_test() {
728-
let query_complexity_limit = 140;
729-
let query_depth_limit = 30;
730713
let temp_dir = TempDir::new().unwrap();
731714
let mut alice = thor::Wallet::default();
732715

@@ -787,8 +770,8 @@ pub fn explorer_vote_tally_certificate_test() {
787770
);
788771

789772
let params = ExplorerParams::new(
790-
query_complexity_limit.to_string(),
791-
query_depth_limit.to_string(),
773+
TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT,
774+
TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT,
792775
None,
793776
);
794777
let explorer_process = jormungandr.explorer(params);
@@ -823,8 +806,6 @@ pub fn explorer_vote_tally_certificate_test() {
823806
#[should_panic] //bug NPG-2742
824807
#[test]
825808
pub fn explorer_update_proposal_certificate_test() {
826-
let query_complexity_limit = 140;
827-
let query_depth_limit = 30;
828809
let temp_dir = TempDir::new().unwrap();
829810
let mut alice = thor::Wallet::default();
830811
let mut bob = thor::Wallet::default();
@@ -882,8 +863,8 @@ pub fn explorer_update_proposal_certificate_test() {
882863
);
883864

884865
let params = ExplorerParams::new(
885-
query_complexity_limit.to_string(),
886-
query_depth_limit.to_string(),
866+
TRANSACTION_CERTIFICATE_QUERY_COMPLEXITY_LIMIT,
867+
TRANSACTION_CERTIFICATE_QUERY_DEPTH_LIMIT,
887868
None,
888869
);
889870
let explorer_process = jormungandr.explorer(params);

testing/jormungandr-integration-tests/src/jormungandr/explorer/explorer_sanity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn explorer_sanity_test() {
6363
let (jormungandr, initial_stake_pools) =
6464
startup::start_stake_pool(&[faucet.clone()], &[], &mut config).unwrap();
6565

66-
let params = ExplorerParams::new(query_complexity_limit.to_string(), None, None);
66+
let params = ExplorerParams::new(query_complexity_limit, None, None);
6767
let explorer_process = jormungandr.explorer(params);
6868
let explorer = explorer_process.client();
6969

testing/jormungandr-integration-tests/src/jormungandr/explorer/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn explorer_transaction_test() {
2727
let (jormungandr, _initial_stake_pools) =
2828
startup::start_stake_pool(&[sender.clone()], &[], &mut config).unwrap();
2929

30-
let params = ExplorerParams::new(query_complexity_limit.to_string(), None, None);
30+
let params = ExplorerParams::new(query_complexity_limit, None, None);
3131
let explorer_process = jormungandr.explorer(params);
3232
let explorer = explorer_process.client();
3333

0 commit comments

Comments
 (0)