@@ -820,8 +820,8 @@ func createAndPayNormalInvoiceWithBtc(t *testing.T, src, dst *HarnessNode,
820820 payInvoiceWithSatoshi (t , src , invoiceResp )
821821}
822822
823- func createAndPayNormalInvoice (t * testing.T , src , rfqPeer , dst * HarnessNode ,
824- amountSat btcutil.Amount , assetID [] byte , opts ... payOpt ) uint64 {
823+ func createNormalInvoice (t * testing.T , dst * HarnessNode ,
824+ amountSat btcutil.Amount ) * lnrpc. AddInvoiceResponse {
825825
826826 ctxb := context .Background ()
827827 ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
@@ -835,6 +835,13 @@ func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
835835 })
836836 require .NoError (t , err )
837837
838+ return invoiceResp
839+ }
840+
841+ func createAndPayNormalInvoice (t * testing.T , src , rfqPeer , dst * HarnessNode ,
842+ amountSat btcutil.Amount , assetID []byte , opts ... payOpt ) uint64 {
843+
844+ invoiceResp := createNormalInvoice (t , dst , amountSat )
838845 numUnits , _ := payInvoiceWithAssets (
839846 t , src , rfqPeer , invoiceResp .PaymentRequest , assetID , opts ... ,
840847 )
@@ -874,19 +881,27 @@ func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
874881}
875882
876883func payInvoiceWithSatoshiLastHop (t * testing.T , payer * HarnessNode ,
877- invoice * lnrpc.AddInvoiceResponse , hopPub []byte ,
878- expectedStatus lnrpc.Payment_PaymentStatus ) {
884+ invoice * lnrpc.AddInvoiceResponse , hops [][]byte , opts ... payOpt ) {
885+
886+ cfg := defaultPayConfig ()
887+ for _ , opt := range opts {
888+ opt (cfg )
889+ }
879890
880891 ctxb := context .Background ()
881892 ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
882893 defer cancel ()
883894
895+ decodedInvoice , err := payer .DecodePayReq (ctxt , & lnrpc.PayReqString {
896+ PayReq : invoice .PaymentRequest ,
897+ })
898+ require .NoError (t , err )
899+
884900 routeRes , err := payer .RouterClient .BuildRoute (
885901 ctxb , & routerrpc.BuildRouteRequest {
886- AmtMsat : 17800 ,
887- FinalCltvDelta : 80 ,
888- PaymentAddr : invoice .PaymentAddr ,
889- HopPubkeys : [][]byte {hopPub },
902+ AmtMsat : decodedInvoice .NumMsat ,
903+ PaymentAddr : invoice .PaymentAddr ,
904+ HopPubkeys : hops ,
890905 },
891906 )
892907 require .NoError (t , err )
@@ -897,11 +912,13 @@ func payInvoiceWithSatoshiLastHop(t *testing.T, payer *HarnessNode,
897912 Route : routeRes .Route ,
898913 },
899914 )
915+ require .NoError (t , err )
900916
901- switch expectedStatus {
917+ switch cfg . payStatus {
902918 case lnrpc .Payment_FAILED :
903919 require .NoError (t , err )
904920 require .Equal (t , lnrpc .HTLCAttempt_FAILED , res .Status )
921+ require .NotNil (t , res .Failure )
905922 require .Nil (t , res .Preimage )
906923
907924 case lnrpc .Payment_SUCCEEDED :
0 commit comments