@@ -820,8 +820,8 @@ func createAndPayNormalInvoiceWithBtc(t *testing.T, src, dst *HarnessNode,
820
820
payInvoiceWithSatoshi (t , src , invoiceResp )
821
821
}
822
822
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 {
825
825
826
826
ctxb := context .Background ()
827
827
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
@@ -835,6 +835,13 @@ func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
835
835
})
836
836
require .NoError (t , err )
837
837
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 )
838
845
numUnits , _ := payInvoiceWithAssets (
839
846
t , src , rfqPeer , invoiceResp .PaymentRequest , assetID , opts ... ,
840
847
)
@@ -874,19 +881,27 @@ func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
874
881
}
875
882
876
883
func 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
+ }
879
890
880
891
ctxb := context .Background ()
881
892
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
882
893
defer cancel ()
883
894
895
+ decodedInvoice , err := payer .DecodePayReq (ctxt , & lnrpc.PayReqString {
896
+ PayReq : invoice .PaymentRequest ,
897
+ })
898
+ require .NoError (t , err )
899
+
884
900
routeRes , err := payer .RouterClient .BuildRoute (
885
901
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 ,
890
905
},
891
906
)
892
907
require .NoError (t , err )
@@ -897,11 +912,13 @@ func payInvoiceWithSatoshiLastHop(t *testing.T, payer *HarnessNode,
897
912
Route : routeRes .Route ,
898
913
},
899
914
)
915
+ require .NoError (t , err )
900
916
901
- switch expectedStatus {
917
+ switch cfg . payStatus {
902
918
case lnrpc .Payment_FAILED :
903
919
require .NoError (t , err )
904
920
require .Equal (t , lnrpc .HTLCAttempt_FAILED , res .Status )
921
+ require .NotNil (t , res .Failure )
905
922
require .Nil (t , res .Preimage )
906
923
907
924
case lnrpc .Payment_SUCCEEDED :
0 commit comments