@@ -25,7 +25,7 @@ use openssl::{
25
25
ssl:: { SslAcceptor , SslMethod } ,
26
26
x509:: X509 ,
27
27
} ;
28
- use rand:: { distributions :: Alphanumeric , Rng as _} ;
28
+ use rand:: distr :: { Alphanumeric , SampleString as _} ;
29
29
30
30
mod utils;
31
31
@@ -188,11 +188,7 @@ async fn body_gzip_large() {
188
188
189
189
#[ actix_rt:: test]
190
190
async fn test_body_gzip_large_random ( ) {
191
- let data = rand:: thread_rng ( )
192
- . sample_iter ( & Alphanumeric )
193
- . take ( 70_000 )
194
- . map ( char:: from)
195
- . collect :: < String > ( ) ;
191
+ let data = Alphanumeric . sample_string ( & mut rand:: rng ( ) , 70_000 ) ;
196
192
let srv_data = data. clone ( ) ;
197
193
198
194
let srv = actix_test:: start_with ( actix_test:: config ( ) . h1 ( ) , move || {
@@ -432,11 +428,7 @@ async fn test_zstd_encoding() {
432
428
433
429
#[ actix_rt:: test]
434
430
async fn test_zstd_encoding_large ( ) {
435
- let data = rand:: thread_rng ( )
436
- . sample_iter ( & Alphanumeric )
437
- . take ( 320_000 )
438
- . map ( char:: from)
439
- . collect :: < String > ( ) ;
431
+ let data = Alphanumeric . sample_string ( & mut rand:: rng ( ) , 320_000 ) ;
440
432
441
433
let srv = actix_test:: start_with ( actix_test:: config ( ) . h1 ( ) , || {
442
434
App :: new ( ) . service (
@@ -529,11 +521,7 @@ async fn test_gzip_encoding_large() {
529
521
530
522
#[ actix_rt:: test]
531
523
async fn test_reading_gzip_encoding_large_random ( ) {
532
- let data = rand:: thread_rng ( )
533
- . sample_iter ( & Alphanumeric )
534
- . take ( 60_000 )
535
- . map ( char:: from)
536
- . collect :: < String > ( ) ;
524
+ let data = Alphanumeric . sample_string ( & mut rand:: rng ( ) , 60_000 ) ;
537
525
538
526
let srv = actix_test:: start_with ( actix_test:: config ( ) . h1 ( ) , || {
539
527
App :: new ( ) . service ( web:: resource ( "/" ) . route ( web:: to ( move |body : Bytes | async {
@@ -599,11 +587,7 @@ async fn test_reading_deflate_encoding_large() {
599
587
600
588
#[ actix_rt:: test]
601
589
async fn test_reading_deflate_encoding_large_random ( ) {
602
- let data = rand:: thread_rng ( )
603
- . sample_iter ( & Alphanumeric )
604
- . take ( 160_000 )
605
- . map ( char:: from)
606
- . collect :: < String > ( ) ;
590
+ let data = Alphanumeric . sample_string ( & mut rand:: rng ( ) , 160_000 ) ;
607
591
608
592
let srv = actix_test:: start_with ( actix_test:: config ( ) . h1 ( ) , || {
609
593
App :: new ( ) . service ( web:: resource ( "/" ) . route ( web:: to ( move |body : Bytes | async {
@@ -648,11 +632,7 @@ async fn test_brotli_encoding() {
648
632
649
633
#[ actix_rt:: test]
650
634
async fn test_brotli_encoding_large ( ) {
651
- let data = rand:: thread_rng ( )
652
- . sample_iter ( & Alphanumeric )
653
- . take ( 320_000 )
654
- . map ( char:: from)
655
- . collect :: < String > ( ) ;
635
+ let data = Alphanumeric . sample_string ( & mut rand:: rng ( ) , 320_000 ) ;
656
636
657
637
let srv = actix_test:: start_with ( actix_test:: config ( ) . h1 ( ) , || {
658
638
App :: new ( ) . service (
@@ -737,11 +717,7 @@ mod plus_rustls {
737
717
738
718
#[ actix_rt:: test]
739
719
async fn test_reading_deflate_encoding_large_random_rustls ( ) {
740
- let data = rand:: thread_rng ( )
741
- . sample_iter ( & Alphanumeric )
742
- . take ( 160_000 )
743
- . map ( char:: from)
744
- . collect :: < String > ( ) ;
720
+ let data = Alphanumeric . sample_string ( & mut rand:: rng ( ) , 160_000 ) ;
745
721
746
722
let srv = actix_test:: start_with ( actix_test:: config ( ) . rustls_0_23 ( tls_config ( ) ) , || {
747
723
App :: new ( ) . service ( web:: resource ( "/" ) . route ( web:: to ( |bytes : Bytes | async {
0 commit comments