@@ -766,68 +766,27 @@ impl TryFrom<PartialInvoiceTlvStream> for InvoiceContents {
766766
767767#[ cfg( test) ]
768768mod tests {
769- use super :: { DEFAULT_RELATIVE_EXPIRY , BlindedPayInfo , FallbackAddress , FullInvoiceTlvStreamRef , Invoice , InvoiceTlvStreamRef , SIGNATURE_TAG } ;
769+ use super :: { DEFAULT_RELATIVE_EXPIRY , FallbackAddress , FullInvoiceTlvStreamRef , Invoice , InvoiceTlvStreamRef , SIGNATURE_TAG } ;
770770
771771 use bitcoin:: blockdata:: script:: Script ;
772772 use bitcoin:: hashes:: Hash ;
773773 use bitcoin:: network:: constants:: Network ;
774- use bitcoin:: secp256k1:: { KeyPair , Message , PublicKey , Secp256k1 , SecretKey , XOnlyPublicKey , self } ;
775- use bitcoin:: secp256k1:: schnorr:: Signature ;
774+ use bitcoin:: secp256k1:: { XOnlyPublicKey , self } ;
776775 use bitcoin:: util:: address:: { Address , Payload , WitnessVersion } ;
777776 use bitcoin:: util:: schnorr:: TweakedPublicKey ;
778- use core:: convert:: { Infallible , TryFrom } ;
777+ use core:: convert:: TryFrom ;
779778 use core:: time:: Duration ;
780- use crate :: ln:: PaymentHash ;
781779 use crate :: ln:: msgs:: DecodeError ;
782- use crate :: ln:: features:: { BlindedHopFeatures , Bolt12InvoiceFeatures } ;
780+ use crate :: ln:: features:: Bolt12InvoiceFeatures ;
783781 use crate :: offers:: invoice_request:: InvoiceRequestTlvStreamRef ;
784782 use crate :: offers:: merkle:: { SignError , SignatureTlvStreamRef , self } ;
785783 use crate :: offers:: offer:: { OfferBuilder , OfferTlvStreamRef } ;
786784 use crate :: offers:: parse:: { ParseError , SemanticError } ;
787785 use crate :: offers:: payer:: PayerTlvStreamRef ;
788786 use crate :: offers:: refund:: RefundBuilder ;
789- use crate :: onion_message :: { BlindedHop , BlindedPath } ;
787+ use crate :: offers :: test_utils :: * ;
790788 use crate :: util:: ser:: { BigSize , Iterable , Writeable } ;
791789
792- fn payer_keys ( ) -> KeyPair {
793- let secp_ctx = Secp256k1 :: new ( ) ;
794- KeyPair :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) )
795- }
796-
797- fn payer_sign ( digest : & Message ) -> Result < Signature , Infallible > {
798- let secp_ctx = Secp256k1 :: new ( ) ;
799- let keys = KeyPair :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
800- Ok ( secp_ctx. sign_schnorr_no_aux_rand ( digest, & keys) )
801- }
802-
803- fn payer_pubkey ( ) -> PublicKey {
804- payer_keys ( ) . public_key ( )
805- }
806-
807- fn recipient_keys ( ) -> KeyPair {
808- let secp_ctx = Secp256k1 :: new ( ) ;
809- KeyPair :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 43 ; 32 ] ) . unwrap ( ) )
810- }
811-
812- fn recipient_sign ( digest : & Message ) -> Result < Signature , Infallible > {
813- let secp_ctx = Secp256k1 :: new ( ) ;
814- let keys = KeyPair :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 43 ; 32 ] ) . unwrap ( ) ) ;
815- Ok ( secp_ctx. sign_schnorr_no_aux_rand ( digest, & keys) )
816- }
817-
818- fn recipient_pubkey ( ) -> PublicKey {
819- recipient_keys ( ) . public_key ( )
820- }
821-
822- fn pubkey ( byte : u8 ) -> PublicKey {
823- let secp_ctx = Secp256k1 :: new ( ) ;
824- PublicKey :: from_secret_key ( & secp_ctx, & privkey ( byte) )
825- }
826-
827- fn privkey ( byte : u8 ) -> SecretKey {
828- SecretKey :: from_slice ( & [ byte; 32 ] ) . unwrap ( )
829- }
830-
831790 trait ToBytes {
832791 fn to_bytes ( & self ) -> Vec < u8 > ;
833792 }
@@ -844,58 +803,6 @@ mod tests {
844803 }
845804 }
846805
847- fn payment_paths ( ) -> Vec < ( BlindedPath , BlindedPayInfo ) > {
848- let paths = vec ! [
849- BlindedPath {
850- introduction_node_id: pubkey( 40 ) ,
851- blinding_point: pubkey( 41 ) ,
852- blinded_hops: vec![
853- BlindedHop { blinded_node_id: pubkey( 43 ) , encrypted_payload: vec![ 0 ; 43 ] } ,
854- BlindedHop { blinded_node_id: pubkey( 44 ) , encrypted_payload: vec![ 0 ; 44 ] } ,
855- ] ,
856- } ,
857- BlindedPath {
858- introduction_node_id: pubkey( 40 ) ,
859- blinding_point: pubkey( 41 ) ,
860- blinded_hops: vec![
861- BlindedHop { blinded_node_id: pubkey( 45 ) , encrypted_payload: vec![ 0 ; 45 ] } ,
862- BlindedHop { blinded_node_id: pubkey( 46 ) , encrypted_payload: vec![ 0 ; 46 ] } ,
863- ] ,
864- } ,
865- ] ;
866-
867- let payinfo = vec ! [
868- BlindedPayInfo {
869- fee_base_msat: 1 ,
870- fee_proportional_millionths: 1_000 ,
871- cltv_expiry_delta: 42 ,
872- htlc_minimum_msat: 100 ,
873- htlc_maximum_msat: 1_000_000_000_000 ,
874- features: BlindedHopFeatures :: empty( ) ,
875- } ,
876- BlindedPayInfo {
877- fee_base_msat: 1 ,
878- fee_proportional_millionths: 1_000 ,
879- cltv_expiry_delta: 42 ,
880- htlc_minimum_msat: 100 ,
881- htlc_maximum_msat: 1_000_000_000_000 ,
882- features: BlindedHopFeatures :: empty( ) ,
883- } ,
884- ] ;
885-
886- paths. into_iter ( ) . zip ( payinfo. into_iter ( ) ) . collect ( )
887- }
888-
889- fn payment_hash ( ) -> PaymentHash {
890- PaymentHash ( [ 42 ; 32 ] )
891- }
892-
893- fn now ( ) -> Duration {
894- std:: time:: SystemTime :: now ( )
895- . duration_since ( std:: time:: SystemTime :: UNIX_EPOCH )
896- . expect ( "SystemTime::now() should come after SystemTime::UNIX_EPOCH" )
897- }
898-
899806 #[ test]
900807 fn builds_invoice_for_offer_with_defaults ( ) {
901808 let payment_paths = payment_paths ( ) ;
0 commit comments