@@ -714,6 +714,7 @@ mod test {
714714 use lightning_invoice:: { Currency , Description , Bolt11InvoiceDescriptionRef , SignOrCreationError , CreationError } ;
715715 use bitcoin:: hashes:: { Hash , sha256} ;
716716 use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
717+ use bitcoin:: network:: Network ;
717718 use crate :: sign:: PhantomKeysManager ;
718719 use crate :: events:: { MessageSendEvent , MessageSendEventsProvider } ;
719720 use crate :: types:: payment:: { PaymentHash , PaymentPreimage } ;
@@ -899,6 +900,52 @@ mod test {
899900 assert_eq ! ( invoice. payment_hash( ) , & sha256:: Hash :: from_slice( & payment_hash. 0 [ ..] ) . unwrap( ) ) ;
900901 }
901902
903+ #[ cfg( not( feature = "std" ) ) ]
904+ #[ test]
905+ fn creates_invoice_using_highest_seen_timestamp ( ) {
906+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
907+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
908+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
909+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
910+
911+ let payment_hash = PaymentHash ( [ 0 ; 32 ] ) ;
912+ let description = Bolt11InvoiceDescription :: Direct (
913+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
914+ ) ;
915+ let invoice_params = Bolt11InvoiceParameters {
916+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
917+ invoice_expiry_delta_secs : Some ( 3600 ) , min_final_cltv_expiry_delta : None ,
918+ payment_hash : Some ( payment_hash) ,
919+ } ;
920+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
921+ let best_block = bitcoin:: constants:: genesis_block ( Network :: Testnet ) ;
922+ assert_eq ! (
923+ invoice. duration_since_epoch( ) ,
924+ Duration :: from_secs( best_block. header. time. into( ) ) ,
925+ ) ;
926+ }
927+
928+ #[ test]
929+ fn creates_invoice_using_currency_inferred_from_chain_hash ( ) {
930+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
931+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
932+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
933+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
934+
935+ let payment_hash = PaymentHash ( [ 0 ; 32 ] ) ;
936+ let description = Bolt11InvoiceDescription :: Direct (
937+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
938+ ) ;
939+ let invoice_params = Bolt11InvoiceParameters {
940+ currency : None , amount_msats : Some ( 10_000 ) , description,
941+ invoice_expiry_delta_secs : Some ( 3600 ) , min_final_cltv_expiry_delta : None ,
942+ payment_hash : Some ( payment_hash) ,
943+ } ;
944+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
945+ assert_eq ! ( invoice. currency( ) , Currency :: BitcoinTestnet ) ;
946+ assert_eq ! ( invoice. network( ) , Network :: Testnet ) ;
947+ }
948+
902949 #[ test]
903950 fn test_hints_has_only_public_confd_channels ( ) {
904951 let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
0 commit comments