@@ -261,21 +261,10 @@ async fn create_verifier(
261
261
#[ cfg( test) ]
262
262
mod tests {
263
263
use super :: * ;
264
- use lazy_static:: lazy_static;
265
264
use tempfile:: TempDir ;
266
- use tokio:: { runtime:: Runtime , sync:: Mutex } ;
267
-
268
- lazy_static ! {
269
- // Allocate the DOWNLOADER once, this is needed to reduce the execution time
270
- // of the unit tests
271
- static ref DOWNLOADER : Mutex <Downloader > = Mutex :: new( {
272
- let rt = Runtime :: new( ) . unwrap( ) ;
273
- rt. block_on( async { Downloader :: new( None , true , None ) . await . unwrap( ) } )
274
- } ) ;
275
- }
276
265
277
- #[ test]
278
- fn verify_success ( ) {
266
+ #[ tokio :: test]
267
+ async fn verify_success ( ) {
279
268
let verification_cfg_yml = r#"---
280
269
allOf:
281
270
- kind: pubKey
@@ -314,24 +303,15 @@ mod tests {
314
303
315
304
let policy_download_dir = TempDir :: new ( ) . expect ( "Cannot create temp dir" ) ;
316
305
317
- // This is required to have lazy_static create the object right now,
318
- // outside of the tokio runtime. Creating the object inside of the tokio
319
- // rutime causes a panic because sigstore-rs' code invokes a `block_on` too
320
- let downloader = DOWNLOADER . lock ( ) ;
321
- drop ( downloader) ;
322
-
323
- let rt = Runtime :: new ( ) . unwrap ( ) ;
324
- let fetched_policies = rt. block_on ( async {
325
- DOWNLOADER
326
- . lock ( )
327
- . await
328
- . download_policies (
329
- & policies,
330
- policy_download_dir. path ( ) . to_str ( ) . unwrap ( ) ,
331
- Some ( & verification_config) ,
332
- )
333
- . await
334
- } ) ;
306
+ let mut downloader = Downloader :: new ( None , true , None ) . await . unwrap ( ) ;
307
+
308
+ let fetched_policies = downloader
309
+ . download_policies (
310
+ & policies,
311
+ policy_download_dir. path ( ) . to_str ( ) . unwrap ( ) ,
312
+ Some ( & verification_config) ,
313
+ )
314
+ . await ;
335
315
336
316
// There are 2 policies defined, but they both reference the same
337
317
// WebAssembly module. Hence, just one `.wasm` file is going to be
@@ -344,8 +324,8 @@ mod tests {
344
324
. is_ok( ) ) ;
345
325
}
346
326
347
- #[ test]
348
- fn verify_error ( ) {
327
+ #[ tokio :: test]
328
+ async fn verify_error ( ) {
349
329
let verification_cfg_yml = r#"---
350
330
allOf:
351
331
- kind: githubAction
@@ -365,24 +345,15 @@ mod tests {
365
345
366
346
let policy_download_dir = TempDir :: new ( ) . expect ( "Cannot create temp dir" ) ;
367
347
368
- // This is required to have lazy_static create the object right now,
369
- // outside of the tokio runtime. Creating the object inside of the tokio
370
- // rutime causes a panic because sigstore-rs' code invokes a `block_on` too
371
- let downloader = DOWNLOADER . lock ( ) ;
372
- drop ( downloader) ;
373
-
374
- let rt = Runtime :: new ( ) . unwrap ( ) ;
375
- let fetched_policies = rt. block_on ( async {
376
- DOWNLOADER
377
- . lock ( )
378
- . await
379
- . download_policies (
380
- & policies,
381
- policy_download_dir. path ( ) . to_str ( ) . unwrap ( ) ,
382
- Some ( & verification_config) ,
383
- )
384
- . await
385
- } ) ;
348
+ let mut downloader = Downloader :: new ( None , true , None ) . await . unwrap ( ) ;
349
+
350
+ let fetched_policies = downloader
351
+ . download_policies (
352
+ & policies,
353
+ policy_download_dir. path ( ) . to_str ( ) . unwrap ( ) ,
354
+ Some ( & verification_config) ,
355
+ )
356
+ . await ;
386
357
387
358
// There are 2 policies defined, but they both reference the same
388
359
// WebAssembly module. Hence, just one `.wasm` file is going to be
0 commit comments