@@ -772,68 +772,27 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
772772
773773#[ cfg( test) ]
774774mod tests {
775- use super :: { DEFAULT_RELATIVE_EXPIRY , BlindedPayInfo , FallbackAddress , FullInvoiceTlvStreamRef , Invoice , InvoiceTlvStreamRef , SIGNATURE_TAG } ;
775+ use super :: { DEFAULT_RELATIVE_EXPIRY , FallbackAddress , FullInvoiceTlvStreamRef , Invoice , InvoiceTlvStreamRef , SIGNATURE_TAG } ;
776776
777777 use bitcoin:: blockdata:: script:: Script ;
778778 use bitcoin:: hashes:: Hash ;
779779 use bitcoin:: network:: constants:: Network ;
780- use bitcoin:: secp256k1:: { KeyPair , Message , PublicKey , Secp256k1 , SecretKey , XOnlyPublicKey , self } ;
781- use bitcoin:: secp256k1:: schnorr:: Signature ;
780+ use bitcoin:: secp256k1:: { XOnlyPublicKey , self } ;
782781 use bitcoin:: util:: address:: { Address , Payload , WitnessVersion } ;
783782 use bitcoin:: util:: schnorr:: TweakedPublicKey ;
784- use core:: convert:: { Infallible , TryFrom } ;
783+ use core:: convert:: TryFrom ;
785784 use core:: time:: Duration ;
786- use crate :: ln:: PaymentHash ;
787785 use crate :: ln:: msgs:: DecodeError ;
788- use crate :: ln:: features:: { BlindedHopFeatures , Bolt12InvoiceFeatures } ;
786+ use crate :: ln:: features:: Bolt12InvoiceFeatures ;
789787 use crate :: offers:: invoice_request:: InvoiceRequestTlvStreamRef ;
790788 use crate :: offers:: merkle:: { SignError , SignatureTlvStreamRef , self } ;
791789 use crate :: offers:: offer:: { OfferBuilder , OfferTlvStreamRef , Quantity } ;
792790 use crate :: offers:: parse:: { ParseError , SemanticError } ;
793791 use crate :: offers:: payer:: PayerTlvStreamRef ;
794792 use crate :: offers:: refund:: RefundBuilder ;
795- use crate :: onion_message :: { BlindedHop , BlindedPath } ;
793+ use crate :: offers :: test_utils :: * ;
796794 use crate :: util:: ser:: { BigSize , Iterable , Writeable } ;
797795
798- fn payer_keys ( ) -> KeyPair {
799- let secp_ctx = Secp256k1 :: new ( ) ;
800- KeyPair :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) )
801- }
802-
803- fn payer_sign ( digest : & Message ) -> Result < Signature , Infallible > {
804- let secp_ctx = Secp256k1 :: new ( ) ;
805- let keys = KeyPair :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
806- Ok ( secp_ctx. sign_schnorr_no_aux_rand ( digest, & keys) )
807- }
808-
809- fn payer_pubkey ( ) -> PublicKey {
810- payer_keys ( ) . public_key ( )
811- }
812-
813- fn recipient_keys ( ) -> KeyPair {
814- let secp_ctx = Secp256k1 :: new ( ) ;
815- KeyPair :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 43 ; 32 ] ) . unwrap ( ) )
816- }
817-
818- fn recipient_sign ( digest : & Message ) -> Result < Signature , Infallible > {
819- let secp_ctx = Secp256k1 :: new ( ) ;
820- let keys = KeyPair :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 43 ; 32 ] ) . unwrap ( ) ) ;
821- Ok ( secp_ctx. sign_schnorr_no_aux_rand ( digest, & keys) )
822- }
823-
824- fn recipient_pubkey ( ) -> PublicKey {
825- recipient_keys ( ) . public_key ( )
826- }
827-
828- fn pubkey ( byte : u8 ) -> PublicKey {
829- let secp_ctx = Secp256k1 :: new ( ) ;
830- PublicKey :: from_secret_key ( & secp_ctx, & privkey ( byte) )
831- }
832-
833- fn privkey ( byte : u8 ) -> SecretKey {
834- SecretKey :: from_slice ( & [ byte; 32 ] ) . unwrap ( )
835- }
836-
837796 trait ToBytes {
838797 fn to_bytes ( & self ) -> Vec < u8 > ;
839798 }
@@ -850,58 +809,6 @@ mod tests {
850809 }
851810 }
852811
853- fn payment_paths ( ) -> Vec < ( BlindedPath , BlindedPayInfo ) > {
854- let paths = vec ! [
855- BlindedPath {
856- introduction_node_id: pubkey( 40 ) ,
857- blinding_point: pubkey( 41 ) ,
858- blinded_hops: vec![
859- BlindedHop { blinded_node_id: pubkey( 43 ) , encrypted_payload: vec![ 0 ; 43 ] } ,
860- BlindedHop { blinded_node_id: pubkey( 44 ) , encrypted_payload: vec![ 0 ; 44 ] } ,
861- ] ,
862- } ,
863- BlindedPath {
864- introduction_node_id: pubkey( 40 ) ,
865- blinding_point: pubkey( 41 ) ,
866- blinded_hops: vec![
867- BlindedHop { blinded_node_id: pubkey( 45 ) , encrypted_payload: vec![ 0 ; 45 ] } ,
868- BlindedHop { blinded_node_id: pubkey( 46 ) , encrypted_payload: vec![ 0 ; 46 ] } ,
869- ] ,
870- } ,
871- ] ;
872-
873- let payinfo = vec ! [
874- BlindedPayInfo {
875- fee_base_msat: 1 ,
876- fee_proportional_millionths: 1_000 ,
877- cltv_expiry_delta: 42 ,
878- htlc_minimum_msat: 100 ,
879- htlc_maximum_msat: 1_000_000_000_000 ,
880- features: BlindedHopFeatures :: empty( ) ,
881- } ,
882- BlindedPayInfo {
883- fee_base_msat: 1 ,
884- fee_proportional_millionths: 1_000 ,
885- cltv_expiry_delta: 42 ,
886- htlc_minimum_msat: 100 ,
887- htlc_maximum_msat: 1_000_000_000_000 ,
888- features: BlindedHopFeatures :: empty( ) ,
889- } ,
890- ] ;
891-
892- paths. into_iter ( ) . zip ( payinfo. into_iter ( ) ) . collect ( )
893- }
894-
895- fn payment_hash ( ) -> PaymentHash {
896- PaymentHash ( [ 42 ; 32 ] )
897- }
898-
899- fn now ( ) -> Duration {
900- std:: time:: SystemTime :: now ( )
901- . duration_since ( std:: time:: SystemTime :: UNIX_EPOCH )
902- . expect ( "SystemTime::now() should come after SystemTime::UNIX_EPOCH" )
903- }
904-
905812 #[ test]
906813 fn builds_invoice_for_offer_with_defaults ( ) {
907814 let payment_paths = payment_paths ( ) ;
0 commit comments