@@ -359,22 +359,25 @@ impl<F: Field> Iterator for RootIter<F> {
359
359
360
360
#[ cfg( test) ]
361
361
mod tests {
362
+ use Fe32 as F ;
363
+
362
364
use super :: * ;
363
365
use crate :: { Fe1024 , Fe32 } ;
364
366
365
367
#[ test]
366
368
#[ cfg( feature = "alloc" ) ]
367
369
fn roots ( ) {
368
- let bip93_poly: Polynomial < Fe32 > = {
369
- use Fe32 as F ;
370
- [ F :: S , F :: S , F :: C , F :: M , F :: L , F :: E , F :: E , F :: E , F :: Q , F :: G , F :: _3, F :: M , F :: E , F :: P ]
371
- }
372
- . iter ( )
373
- . copied ( )
374
- . collect ( ) ;
370
+ #[ rustfmt:: skip]
371
+ let mut bip93_poly = Polynomial :: with_monic_leading_term (
372
+ & [ F :: E , F :: M , F :: _3, F :: G , F :: Q , F :: E , F :: E , F :: E , F :: L , F :: M , F :: C , F :: S , F :: S ]
373
+ ) ;
375
374
375
+ assert_eq ! ( bip93_poly. leading_term( ) , F :: P ) ;
376
+ assert ! ( !bip93_poly. zero_is_root( ) ) ;
376
377
assert_eq ! ( bip93_poly. degree( ) , 13 ) ;
377
378
379
+ bip93_poly. zero_pad_up_to ( 1000 ) ; // should have no visible effect
380
+
378
381
let ( elem, order, root_indices) = bip93_poly. bch_generator_primitive_element :: < Fe1024 > ( ) ;
379
382
// Basically, only the order and the length of the `root_indices` range are
380
383
// guaranteed to be consistent across runs. There will be two possible ranges,
@@ -422,18 +425,15 @@ mod tests {
422
425
}
423
426
424
427
#[ test]
425
- #[ cfg( not( feature = "alloc" ) ) ]
426
- fn roots ( ) {
428
+ fn roots_bech32 ( ) {
427
429
// Exactly the same test as above, but for bech32
428
- let bech32_poly: Polynomial < Fe32 > = {
429
- use Fe32 as F ;
430
- [ F :: J , F :: A , F :: _4, F :: _5, F :: K , F :: A , F :: P ]
431
- }
432
- . iter ( )
433
- . copied ( )
434
- . collect ( ) ;
430
+ let bech32_poly =
431
+ Polynomial :: with_monic_leading_term ( & [ F :: A , F :: K , F :: _5, F :: _4, F :: A , F :: J ] ) ;
435
432
436
- assert_eq ! ( bech32_poly. degree( ) , 6 ) ;
433
+ assert_eq ! (
434
+ bech32_poly. iter( ) . copied( ) . collect:: <Vec <_>>( ) ,
435
+ [ F :: J , F :: A , F :: _4, F :: _5, F :: K , F :: A , F :: P ] ,
436
+ ) ;
437
437
438
438
let ( elem, order, root_indices) = bech32_poly. bch_generator_primitive_element :: < Fe1024 > ( ) ;
439
439
// As above, only the order and the length of the `root_indices` range are
0 commit comments