@@ -864,8 +864,8 @@ func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
864864	require .NoError (t , err )
865865
866866	result , err  :=  getPaymentResult (stream )
867- 	if  cfg .expectTimeout  {
868- 		require .ErrorContains (t , err , "context deadline exceeded" )
867+ 	if  cfg .errSubStr   !=   ""  {
868+ 		require .ErrorContains (t , err , cfg . errSubStr )
869869	} else  {
870870		require .NoError (t , err )
871871		require .Equal (t , cfg .payStatus , result .Status )
@@ -911,17 +911,20 @@ func payInvoiceWithSatoshiLastHop(t *testing.T, payer *HarnessNode,
911911}
912912
913913type  payConfig  struct  {
914- 	smallShards    bool 
915- 	expectTimeout  bool 
916- 	payStatus      lnrpc.Payment_PaymentStatus 
917- 	failureReason  lnrpc.PaymentFailureReason 
918- 	rfq            fn.Option [rfqmsg.ID ]
914+ 	smallShards        bool 
915+ 	errSubStr          string 
916+ 	allowUnEconomical  bool 
917+ 	feeLimit           lnwire.MilliSatoshi 
918+ 	payStatus          lnrpc.Payment_PaymentStatus 
919+ 	failureReason      lnrpc.PaymentFailureReason 
920+ 	rfq                fn.Option [rfqmsg.ID ]
919921}
920922
921923func  defaultPayConfig () * payConfig  {
922924	return  & payConfig {
923925		smallShards :   false ,
924- 		expectTimeout : false ,
926+ 		errSubStr :     "" ,
927+ 		feeLimit :      1_000_000 ,
925928		payStatus :     lnrpc .Payment_SUCCEEDED ,
926929		failureReason : lnrpc .PaymentFailureReason_FAILURE_REASON_NONE ,
927930	}
@@ -935,9 +938,9 @@ func withSmallShards() payOpt {
935938	}
936939}
937940
938- func  withExpectTimeout ( ) payOpt  {
941+ func  withPayErrSubStr ( errSubStr   string ) payOpt  {
939942	return  func (c  * payConfig ) {
940- 		c .expectTimeout  =  true 
943+ 		c .errSubStr  =  errSubStr 
941944	}
942945}
943946
@@ -956,6 +959,18 @@ func withRFQ(rfqID rfqmsg.ID) payOpt {
956959	}
957960}
958961
962+ func  withFeeLimit (limit  lnwire.MilliSatoshi ) payOpt  {
963+ 	return  func (c  * payConfig ) {
964+ 		c .feeLimit  =  limit 
965+ 	}
966+ }
967+ 
968+ func  withAllowUnEconomical () payOpt  {
969+ 	return  func (c  * payConfig ) {
970+ 		c .allowUnEconomical  =  true 
971+ 	}
972+ }
973+ 
959974func  payInvoiceWithAssets (t  * testing.T , payer , rfqPeer  * HarnessNode ,
960975	payReq  string , assetID  []byte ,
961976	opts  ... payOpt ) (uint64 , rfqmath.BigIntFixedPoint ) {
@@ -979,7 +994,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
979994	sendReq  :=  & routerrpc.SendPaymentRequest {
980995		PaymentRequest : payReq ,
981996		TimeoutSeconds : int32 (PaymentTimeout .Seconds ()),
982- 		FeeLimitMsat :   1_000_000 ,
997+ 		FeeLimitMsat :   int64 ( cfg . feeLimit ) ,
983998	}
984999
9851000	if  cfg .smallShards  {
@@ -993,13 +1008,24 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
9931008	})
9941009
9951010	stream , err  :=  payerTapd .SendPayment (ctxt , & tchrpc.SendPaymentRequest {
996- 		AssetId :        assetID ,
997- 		PeerPubkey :     rfqPeer .PubKey [:],
998- 		PaymentRequest : sendReq ,
999- 		RfqId :          rfqBytes ,
1011+ 		AssetId :           assetID ,
1012+ 		PeerPubkey :        rfqPeer .PubKey [:],
1013+ 		PaymentRequest :    sendReq ,
1014+ 		RfqId :             rfqBytes ,
1015+ 		AllowUneconomical : cfg .allowUnEconomical ,
10001016	})
10011017	require .NoError (t , err )
10021018
1019+ 	// If an error is returned by the RPC method (meaning the stream itself 
1020+ 	// was established, no network or auth error), we expect the error to be 
1021+ 	// returned on the first read on the stream. 
1022+ 	if  cfg .errSubStr  !=  ""  {
1023+ 		_ , err  :=  stream .Recv ()
1024+ 		require .ErrorContains (t , err , cfg .errSubStr )
1025+ 
1026+ 		return  0 , rfqmath.BigIntFixedPoint {}
1027+ 	}
1028+ 
10031029	var  (
10041030		numUnits  uint64 
10051031		rateVal   rfqmath.FixedPoint [rfqmath.BigInt ]
@@ -1043,8 +1069,32 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
10431069	return  numUnits , rateVal 
10441070}
10451071
1072+ type  invoiceConfig  struct  {
1073+ 	errSubStr  string 
1074+ }
1075+ 
1076+ func  defaultInvoiceConfig () * invoiceConfig  {
1077+ 	return  & invoiceConfig {
1078+ 		errSubStr : "" ,
1079+ 	}
1080+ }
1081+ 
1082+ type  invoiceOpt  func (* invoiceConfig )
1083+ 
1084+ func  withInvoiceErrSubStr (errSubStr  string ) invoiceOpt  {
1085+ 	return  func (c  * invoiceConfig ) {
1086+ 		c .errSubStr  =  errSubStr 
1087+ 	}
1088+ }
1089+ 
10461090func  createAssetInvoice (t  * testing.T , dstRfqPeer , dst  * HarnessNode ,
1047- 	assetAmount  uint64 , assetID  []byte ) * lnrpc.AddInvoiceResponse  {
1091+ 	assetAmount  uint64 , assetID  []byte ,
1092+ 	opts  ... invoiceOpt ) * lnrpc.AddInvoiceResponse  {
1093+ 
1094+ 	cfg  :=  defaultInvoiceConfig ()
1095+ 	for  _ , opt  :=  range  opts  {
1096+ 		opt (cfg )
1097+ 	}
10481098
10491099	ctxb  :=  context .Background ()
10501100	ctxt , cancel  :=  context .WithTimeout (ctxb , defaultTimeout )
@@ -1068,7 +1118,13 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
10681118			Expiry : timeoutSeconds ,
10691119		},
10701120	})
1071- 	require .NoError (t , err )
1121+ 	if  cfg .errSubStr  !=  ""  {
1122+ 		require .ErrorContains (t , err , cfg .errSubStr )
1123+ 
1124+ 		return  nil 
1125+ 	} else  {
1126+ 		require .NoError (t , err )
1127+ 	}
10721128
10731129	decodedInvoice , err  :=  dst .DecodePayReq (ctxt , & lnrpc.PayReqString {
10741130		PayReq : resp .InvoiceResult .PaymentRequest ,
0 commit comments