Skip to content

Commit aebf02a

Browse files
committed
pass string by reference to tests
1 parent 24a875a commit aebf02a

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

crates/cli/src/commands/test/beacon.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ fn supported_beacon_test_cases() -> Vec<TestCaseName> {
237237
async fn run_test_case(
238238
cancel: tokio_util::sync::CancellationToken,
239239
cfg: TestBeaconArgs,
240-
target: String,
240+
target: &str,
241241
name: &str,
242242
) -> TestResult {
243243
match name {
@@ -372,7 +372,7 @@ async fn test_single_beacon(
372372
break;
373373
}
374374

375-
let result = run_test_case(cancel.clone(), cfg.clone(), target.to_string(), &tc.name).await;
375+
let result = run_test_case(cancel.clone(), cfg.clone(), target, &tc.name).await;
376376
results.push(result);
377377
}
378378

@@ -382,7 +382,7 @@ async fn test_single_beacon(
382382
async fn beacon_ping_test(
383383
_cancel: tokio_util::sync::CancellationToken,
384384
_cfg: TestBeaconArgs,
385-
target: String,
385+
target: &str,
386386
) -> TestResult {
387387
let mut res = TestResult::new("Ping");
388388
let url = format!("{target}/eth/v1/node/health");
@@ -399,11 +399,11 @@ async fn beacon_ping_test(
399399
async fn beacon_ping_measure_test(
400400
_cancel: tokio_util::sync::CancellationToken,
401401
_cfg: TestBeaconArgs,
402-
target: String,
402+
target: &str,
403403
) -> TestResult {
404404
let res = TestResult::new("PingMeasure");
405405

406-
match beacon_ping_once(&target).await {
406+
match beacon_ping_once(target).await {
407407
Ok(rtt) => evaluate_rtt(
408408
rtt,
409409
res,
@@ -417,7 +417,7 @@ async fn beacon_ping_measure_test(
417417
async fn beacon_version_test(
418418
_cancel: tokio_util::sync::CancellationToken,
419419
_cfg: TestBeaconArgs,
420-
target: String,
420+
target: &str,
421421
) -> TestResult {
422422
let mut res = TestResult::new("Version");
423423
let url = format!("{target}/eth/v1/node/version");
@@ -472,7 +472,7 @@ async fn beacon_version_test(
472472
async fn beacon_is_synced_test(
473473
_cancel: tokio_util::sync::CancellationToken,
474474
_cfg: TestBeaconArgs,
475-
target: String,
475+
target: &str,
476476
) -> TestResult {
477477
let mut res = TestResult::new("Synced");
478478
let url = format!("{target}/eth/v1/node/syncing");
@@ -522,7 +522,7 @@ async fn beacon_is_synced_test(
522522
async fn beacon_peer_count_test(
523523
_cancel: tokio_util::sync::CancellationToken,
524524
_cfg: TestBeaconArgs,
525-
target: String,
525+
target: &str,
526526
) -> TestResult {
527527
let mut res = TestResult::new("PeerCount");
528528
let url = format!("{target}/eth/v1/node/peers?state=connected");
@@ -605,7 +605,7 @@ async fn ping_beacon_continuously(
605605
async fn beacon_ping_load_test(
606606
cancel: tokio_util::sync::CancellationToken,
607607
cfg: TestBeaconArgs,
608-
target: String,
608+
target: &str,
609609
) -> TestResult {
610610
if !cfg.load_test {
611611
return skip_result("PingLoad");
@@ -631,7 +631,7 @@ async fn beacon_ping_load_test(
631631
_ = load_cancel.cancelled() => break,
632632
_ = interval.tick() => {
633633
let c = load_cancel.clone();
634-
let t = target.clone();
634+
let t = target.to_string();
635635
let tx = tx.clone();
636636
handles.push(tokio::spawn(async move {
637637
ping_beacon_continuously(c, t, tx).await;
@@ -674,7 +674,7 @@ fn default_intensity() -> RequestsIntensity {
674674
async fn beacon_simulation_1_test(
675675
cancel: tokio_util::sync::CancellationToken,
676676
cfg: TestBeaconArgs,
677-
target: String,
677+
target: &str,
678678
) -> TestResult {
679679
if !cfg.load_test {
680680
return skip_result("Simulate1");
@@ -687,13 +687,13 @@ async fn beacon_simulation_1_test(
687687
sync_committee_validators_count: 1,
688688
request_intensity: default_intensity(),
689689
};
690-
beacon_simulation_test(cancel, &cfg, &target, res, params).await
690+
beacon_simulation_test(cancel, &cfg, target, res, params).await
691691
}
692692

693693
async fn beacon_simulation_10_test(
694694
cancel: tokio_util::sync::CancellationToken,
695695
cfg: TestBeaconArgs,
696-
target: String,
696+
target: &str,
697697
) -> TestResult {
698698
if !cfg.load_test {
699699
return skip_result("Simulate10");
@@ -706,13 +706,13 @@ async fn beacon_simulation_10_test(
706706
sync_committee_validators_count: 1,
707707
request_intensity: default_intensity(),
708708
};
709-
beacon_simulation_test(cancel, &cfg, &target, res, params).await
709+
beacon_simulation_test(cancel, &cfg, target, res, params).await
710710
}
711711

712712
async fn beacon_simulation_100_test(
713713
cancel: tokio_util::sync::CancellationToken,
714714
cfg: TestBeaconArgs,
715-
target: String,
715+
target: &str,
716716
) -> TestResult {
717717
if !cfg.load_test {
718718
return skip_result("Simulate100");
@@ -725,13 +725,13 @@ async fn beacon_simulation_100_test(
725725
sync_committee_validators_count: 2,
726726
request_intensity: default_intensity(),
727727
};
728-
beacon_simulation_test(cancel, &cfg, &target, res, params).await
728+
beacon_simulation_test(cancel, &cfg, target, res, params).await
729729
}
730730

731731
async fn beacon_simulation_500_test(
732732
cancel: tokio_util::sync::CancellationToken,
733733
cfg: TestBeaconArgs,
734-
target: String,
734+
target: &str,
735735
) -> TestResult {
736736
if !cfg.load_test {
737737
return skip_result("Simulate500");
@@ -744,13 +744,13 @@ async fn beacon_simulation_500_test(
744744
sync_committee_validators_count: 5,
745745
request_intensity: default_intensity(),
746746
};
747-
beacon_simulation_test(cancel, &cfg, &target, res, params).await
747+
beacon_simulation_test(cancel, &cfg, target, res, params).await
748748
}
749749

750750
async fn beacon_simulation_1000_test(
751751
cancel: tokio_util::sync::CancellationToken,
752752
cfg: TestBeaconArgs,
753-
target: String,
753+
target: &str,
754754
) -> TestResult {
755755
if !cfg.load_test {
756756
return skip_result("Simulate1000");
@@ -763,13 +763,13 @@ async fn beacon_simulation_1000_test(
763763
sync_committee_validators_count: 5,
764764
request_intensity: default_intensity(),
765765
};
766-
beacon_simulation_test(cancel, &cfg, &target, res, params).await
766+
beacon_simulation_test(cancel, &cfg, target, res, params).await
767767
}
768768

769769
async fn beacon_simulation_custom_test(
770770
cancel: tokio_util::sync::CancellationToken,
771771
cfg: TestBeaconArgs,
772-
target: String,
772+
target: &str,
773773
) -> TestResult {
774774
if cfg.simulation_custom < 1 {
775775
return TestResult {
@@ -799,7 +799,7 @@ async fn beacon_simulation_custom_test(
799799
sync_committee_validators_count: sync_committees,
800800
request_intensity: default_intensity(),
801801
};
802-
beacon_simulation_test(cancel, &cfg, &target, res, params).await
802+
beacon_simulation_test(cancel, &cfg, target, res, params).await
803803
}
804804

805805
async fn beacon_simulation_test(

0 commit comments

Comments
 (0)