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