@@ -555,6 +555,7 @@ mod test {
555
555
use lightning_invoice:: { Currency , Description , Bolt11InvoiceDescriptionRef , SignOrCreationError , CreationError } ;
556
556
use bitcoin:: hashes:: { Hash , sha256} ;
557
557
use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
558
+ use bitcoin:: network:: Network ;
558
559
use crate :: sign:: PhantomKeysManager ;
559
560
use crate :: events:: { MessageSendEvent , MessageSendEventsProvider } ;
560
561
use crate :: types:: payment:: { PaymentHash , PaymentPreimage } ;
@@ -749,6 +750,53 @@ mod test {
749
750
assert_eq ! ( invoice. payment_hash( ) , & sha256:: Hash :: from_slice( & payment_hash. 0 [ ..] ) . unwrap( ) ) ;
750
751
}
751
752
753
+ #[ cfg( not( feature = "std" ) ) ]
754
+ #[ test]
755
+ fn creates_invoice_using_highest_seen_timestamp ( ) {
756
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
757
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
758
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
759
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
760
+
761
+ let payment_hash = PaymentHash ( [ 0 ; 32 ] ) ;
762
+ let description = Bolt11InvoiceDescription :: Direct (
763
+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
764
+ ) ;
765
+ let invoice_params = Bolt11InvoiceParameters {
766
+ currency : Some ( Currency :: BitcoinTestnet ) , amount_msats : Some ( 10_000 ) , description,
767
+ duration_since_epoch : None , invoice_expiry_delta_secs : Some ( 3600 ) ,
768
+ min_final_cltv_expiry_delta : None , payment_hash : Some ( payment_hash) ,
769
+ } ;
770
+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
771
+ let best_block = bitcoin:: constants:: genesis_block ( Network :: Testnet ) ;
772
+ assert_eq ! (
773
+ invoice. duration_since_epoch( ) ,
774
+ Duration :: from_secs( best_block. header. time. into( ) ) ,
775
+ ) ;
776
+ }
777
+
778
+ #[ test]
779
+ fn creates_invoice_using_currency_inferred_from_chain_hash ( ) {
780
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
781
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
782
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
783
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
784
+
785
+ let payment_hash = PaymentHash ( [ 0 ; 32 ] ) ;
786
+ let description = Bolt11InvoiceDescription :: Direct (
787
+ Description :: new ( "test" . to_string ( ) ) . unwrap ( )
788
+ ) ;
789
+ let invoice_params = Bolt11InvoiceParameters {
790
+ currency : None , amount_msats : Some ( 10_000 ) , description,
791
+ duration_since_epoch : Some ( Duration :: from_secs ( 1234567 ) ) ,
792
+ invoice_expiry_delta_secs : Some ( 3600 ) , min_final_cltv_expiry_delta : None ,
793
+ payment_hash : Some ( payment_hash) ,
794
+ } ;
795
+ let invoice = nodes[ 1 ] . node . create_bolt11_invoice ( invoice_params) . unwrap ( ) ;
796
+ assert_eq ! ( invoice. currency( ) , Currency :: BitcoinTestnet ) ;
797
+ assert_eq ! ( invoice. network( ) , Network :: Testnet ) ;
798
+ }
799
+
752
800
#[ test]
753
801
fn test_hints_has_only_public_confd_channels ( ) {
754
802
let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
0 commit comments