@@ -1102,6 +1102,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
11021102
11031103type  invoiceConfig  struct  {
11041104	errSubStr  string 
1105+ 	msats      lnwire.MilliSatoshi 
11051106}
11061107
11071108func  defaultInvoiceConfig () * invoiceConfig  {
@@ -1118,6 +1119,12 @@ func withInvoiceErrSubStr(errSubStr string) invoiceOpt {
11181119	}
11191120}
11201121
1122+ func  withMsatAmount (amt  uint64 ) invoiceOpt  {
1123+ 	return  func (c  * invoiceConfig ) {
1124+ 		c .msats  =  lnwire .MilliSatoshi (amt )
1125+ 	}
1126+ }
1127+ 
11211128func  createAssetInvoice (t  * testing.T , dstRfqPeer , dst  * HarnessNode ,
11221129	assetAmount  uint64 , assetID  []byte ,
11231130	opts  ... invoiceOpt ) * lnrpc.AddInvoiceResponse  {
@@ -1146,7 +1153,8 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
11461153		InvoiceRequest : & lnrpc.Invoice {
11471154			Memo : fmt .Sprintf ("this is an asset invoice for " + 
11481155				"%d units" , assetAmount ),
1149- 			Expiry : timeoutSeconds ,
1156+ 			Expiry :    timeoutSeconds ,
1157+ 			ValueMsat : int64 (cfg .msats ),
11501158		},
11511159	})
11521160	if  cfg .errSubStr  !=  ""  {
@@ -1168,11 +1176,20 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
11681176
11691177	t .Logf ("Got quote for %v asset units per BTC" , rate )
11701178
1171- 	assetUnits  :=  rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1172- 	numMSats  :=  rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1173- 	mSatPerUnit  :=  float64 (decodedInvoice .NumMsat ) /  float64 (assetAmount )
1179+ 	var  mSatPerUnit  float64 
1180+ 
1181+ 	if  cfg .msats  >  0  {
1182+ 		require .EqualValues (t , decodedInvoice .NumMsat , cfg .msats )
1183+ 		units  :=  rfqmath .MilliSatoshiToUnits (cfg .msats , * rate )
11741184
1175- 	require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1185+ 		mSatPerUnit  =  float64 (cfg .msats ) /  float64 (units .ToUint64 ())
1186+ 	} else  {
1187+ 		assetUnits  :=  rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1188+ 		numMSats  :=  rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1189+ 		mSatPerUnit  =  float64 (decodedInvoice .NumMsat ) /  float64 (assetAmount )
1190+ 
1191+ 		require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1192+ 	}
11761193
11771194	t .Logf ("Got quote for %d mSats at %3f msat/unit from peer %x with " + 
11781195		"SCID %d" , decodedInvoice .NumMsat , mSatPerUnit ,
@@ -1334,7 +1351,7 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
13341351
13351352	require .EqualValues (t , uint64 (numMSats ), uint64 (decodedInvoice .NumMsat ))
13361353
1337- 	t .Logf ("Got quote for %d sats  at %v msat/unit from peer %x with SCID " + 
1354+ 	t .Logf ("Got quote for %d msats  at %v msat/unit from peer %x with SCID " + 
13381355		"%d" , decodedInvoice .NumMsat , mSatPerUnit , dstRfqPeer .PubKey [:],
13391356		resp .AcceptedBuyQuote .Scid )
13401357
0 commit comments