8
8
// licenses.
9
9
10
10
use crate :: utils:: test_logger;
11
- use bech32:: { u5 , FromBase32 , ToBase32 } ;
11
+ use bech32:: Fe32 ;
12
12
use bitcoin:: secp256k1:: { Secp256k1 , SecretKey } ;
13
13
use lightning_invoice:: {
14
- Bolt11Invoice , RawBolt11Invoice , RawDataPart , RawHrp , RawTaggedField , TaggedField ,
14
+ Base32Iterable , Bolt11Invoice , FromBase32 , RawBolt11Invoice , RawDataPart , RawHrp ,
15
+ RawTaggedField , TaggedField ,
15
16
} ;
16
17
use std:: str:: FromStr ;
17
18
@@ -25,19 +26,19 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
25
26
Err ( _) => return ,
26
27
} ;
27
28
let bech32 =
28
- data. iter ( ) . skip ( hrp_len) . map ( |x| u5 :: try_from_u8 ( x % 32 ) . unwrap ( ) ) . collect :: < Vec < _ > > ( ) ;
29
+ data. iter ( ) . skip ( hrp_len) . map ( |x| Fe32 :: try_from ( x % 32 ) . unwrap ( ) ) . collect :: < Vec < _ > > ( ) ;
29
30
let invoice_data = match RawDataPart :: from_base32 ( & bech32) {
30
31
Ok ( invoice) => invoice,
31
32
Err ( _) => return ,
32
33
} ;
33
34
35
+ let invoice_data_base32 = invoice_data. fe_iter ( ) . collect :: < Vec < _ > > ( ) ;
34
36
// Our data encoding is not worse than the input
35
- assert ! ( invoice_data . to_base32 ( ) . len( ) <= bech32. len( ) ) ;
37
+ assert ! ( invoice_data_base32 . len( ) <= bech32. len( ) ) ;
36
38
37
39
// Our data serialization is loss-less
38
40
assert_eq ! (
39
- RawDataPart :: from_base32( & invoice_data. to_base32( ) )
40
- . expect( "faild parsing out own encoding" ) ,
41
+ RawDataPart :: from_base32( & invoice_data_base32) . expect( "faild parsing out own encoding" ) ,
41
42
invoice_data
42
43
) ;
43
44
0 commit comments