@@ -777,68 +777,27 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
777777
778778#[ cfg( test) ]
779779mod tests {
780- use super :: { DEFAULT_RELATIVE_EXPIRY , BlindedPayInfo , FallbackAddress , FullInvoiceTlvStreamRef , Invoice , InvoiceTlvStreamRef , SIGNATURE_TAG } ;
780+ use super :: { DEFAULT_RELATIVE_EXPIRY , FallbackAddress , FullInvoiceTlvStreamRef , Invoice , InvoiceTlvStreamRef , SIGNATURE_TAG } ;
781781
782782 use bitcoin:: blockdata:: script:: Script ;
783783 use bitcoin:: hashes:: Hash ;
784784 use bitcoin:: network:: constants:: Network ;
785- use bitcoin:: secp256k1:: { KeyPair , Message , PublicKey , Secp256k1 , SecretKey , XOnlyPublicKey , self } ;
786- use bitcoin:: secp256k1:: schnorr:: Signature ;
785+ use bitcoin:: secp256k1:: { Message , Secp256k1 , XOnlyPublicKey , self } ;
787786 use bitcoin:: util:: address:: { Address , Payload , WitnessVersion } ;
788787 use bitcoin:: util:: schnorr:: TweakedPublicKey ;
789- use core:: convert:: { Infallible , TryFrom } ;
788+ use core:: convert:: TryFrom ;
790789 use core:: time:: Duration ;
791- use crate :: ln:: PaymentHash ;
792790 use crate :: ln:: msgs:: DecodeError ;
793- use crate :: ln:: features:: { BlindedHopFeatures , Bolt12InvoiceFeatures } ;
791+ use crate :: ln:: features:: Bolt12InvoiceFeatures ;
794792 use crate :: offers:: invoice_request:: InvoiceRequestTlvStreamRef ;
795793 use crate :: offers:: merkle:: { SignError , SignatureTlvStreamRef , self } ;
796794 use crate :: offers:: offer:: { OfferBuilder , OfferTlvStreamRef , Quantity } ;
797795 use crate :: offers:: parse:: { ParseError , SemanticError } ;
798796 use crate :: offers:: payer:: PayerTlvStreamRef ;
799797 use crate :: offers:: refund:: RefundBuilder ;
800- use crate :: onion_message :: { BlindedHop , BlindedPath } ;
798+ use crate :: offers :: test_utils :: * ;
801799 use crate :: util:: ser:: { BigSize , Iterable , Writeable } ;
802800
803- fn payer_keys ( ) -> KeyPair {
804- let secp_ctx = Secp256k1 :: new ( ) ;
805- KeyPair :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) )
806- }
807-
808- fn payer_sign ( digest : & Message ) -> Result < Signature , Infallible > {
809- let secp_ctx = Secp256k1 :: new ( ) ;
810- let keys = KeyPair :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
811- Ok ( secp_ctx. sign_schnorr_no_aux_rand ( digest, & keys) )
812- }
813-
814- fn payer_pubkey ( ) -> PublicKey {
815- payer_keys ( ) . public_key ( )
816- }
817-
818- fn recipient_keys ( ) -> KeyPair {
819- let secp_ctx = Secp256k1 :: new ( ) ;
820- KeyPair :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 43 ; 32 ] ) . unwrap ( ) )
821- }
822-
823- fn recipient_sign ( digest : & Message ) -> Result < Signature , Infallible > {
824- let secp_ctx = Secp256k1 :: new ( ) ;
825- let keys = KeyPair :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 43 ; 32 ] ) . unwrap ( ) ) ;
826- Ok ( secp_ctx. sign_schnorr_no_aux_rand ( digest, & keys) )
827- }
828-
829- fn recipient_pubkey ( ) -> PublicKey {
830- recipient_keys ( ) . public_key ( )
831- }
832-
833- fn pubkey ( byte : u8 ) -> PublicKey {
834- let secp_ctx = Secp256k1 :: new ( ) ;
835- PublicKey :: from_secret_key ( & secp_ctx, & privkey ( byte) )
836- }
837-
838- fn privkey ( byte : u8 ) -> SecretKey {
839- SecretKey :: from_slice ( & [ byte; 32 ] ) . unwrap ( )
840- }
841-
842801 trait ToBytes {
843802 fn to_bytes ( & self ) -> Vec < u8 > ;
844803 }
@@ -855,58 +814,6 @@ mod tests {
855814 }
856815 }
857816
858- fn payment_paths ( ) -> Vec < ( BlindedPath , BlindedPayInfo ) > {
859- let paths = vec ! [
860- BlindedPath {
861- introduction_node_id: pubkey( 40 ) ,
862- blinding_point: pubkey( 41 ) ,
863- blinded_hops: vec![
864- BlindedHop { blinded_node_id: pubkey( 43 ) , encrypted_payload: vec![ 0 ; 43 ] } ,
865- BlindedHop { blinded_node_id: pubkey( 44 ) , encrypted_payload: vec![ 0 ; 44 ] } ,
866- ] ,
867- } ,
868- BlindedPath {
869- introduction_node_id: pubkey( 40 ) ,
870- blinding_point: pubkey( 41 ) ,
871- blinded_hops: vec![
872- BlindedHop { blinded_node_id: pubkey( 45 ) , encrypted_payload: vec![ 0 ; 45 ] } ,
873- BlindedHop { blinded_node_id: pubkey( 46 ) , encrypted_payload: vec![ 0 ; 46 ] } ,
874- ] ,
875- } ,
876- ] ;
877-
878- let payinfo = vec ! [
879- BlindedPayInfo {
880- fee_base_msat: 1 ,
881- fee_proportional_millionths: 1_000 ,
882- cltv_expiry_delta: 42 ,
883- htlc_minimum_msat: 100 ,
884- htlc_maximum_msat: 1_000_000_000_000 ,
885- features: BlindedHopFeatures :: empty( ) ,
886- } ,
887- BlindedPayInfo {
888- fee_base_msat: 1 ,
889- fee_proportional_millionths: 1_000 ,
890- cltv_expiry_delta: 42 ,
891- htlc_minimum_msat: 100 ,
892- htlc_maximum_msat: 1_000_000_000_000 ,
893- features: BlindedHopFeatures :: empty( ) ,
894- } ,
895- ] ;
896-
897- paths. into_iter ( ) . zip ( payinfo. into_iter ( ) ) . collect ( )
898- }
899-
900- fn payment_hash ( ) -> PaymentHash {
901- PaymentHash ( [ 42 ; 32 ] )
902- }
903-
904- fn now ( ) -> Duration {
905- std:: time:: SystemTime :: now ( )
906- . duration_since ( std:: time:: SystemTime :: UNIX_EPOCH )
907- . expect ( "SystemTime::now() should come after SystemTime::UNIX_EPOCH" )
908- }
909-
910817 #[ test]
911818 fn builds_invoice_for_offer_with_defaults ( ) {
912819 let payment_paths = payment_paths ( ) ;
0 commit comments