@@ -1087,6 +1087,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
10871087
10881088type  invoiceConfig  struct  {
10891089	errSubStr  string 
1090+ 	msats      lnwire.MilliSatoshi 
10901091}
10911092
10921093func  defaultInvoiceConfig () * invoiceConfig  {
@@ -1103,6 +1104,12 @@ func withInvoiceErrSubStr(errSubStr string) invoiceOpt {
11031104	}
11041105}
11051106
1107+ func  withMsatAmount (amt  uint64 ) invoiceOpt  {
1108+ 	return  func (c  * invoiceConfig ) {
1109+ 		c .msats  =  lnwire .MilliSatoshi (amt )
1110+ 	}
1111+ }
1112+ 
11061113func  createAssetInvoice (t  * testing.T , dstRfqPeer , dst  * HarnessNode ,
11071114	assetAmount  uint64 , assetID  []byte ,
11081115	opts  ... invoiceOpt ) * lnrpc.AddInvoiceResponse  {
@@ -1131,7 +1138,8 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
11311138		InvoiceRequest : & lnrpc.Invoice {
11321139			Memo : fmt .Sprintf ("this is an asset invoice over " + 
11331140				"%d units" , assetAmount ),
1134- 			Expiry : timeoutSeconds ,
1141+ 			Expiry :    timeoutSeconds ,
1142+ 			ValueMsat : int64 (cfg .msats ),
11351143		},
11361144	})
11371145	if  cfg .errSubStr  !=  ""  {
@@ -1153,11 +1161,20 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
11531161
11541162	t .Logf ("Got quote for %v asset units per BTC" , rate )
11551163
1156- 	assetUnits  :=  rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1157- 	numMSats  :=  rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1158- 	mSatPerUnit  :=  float64 (decodedInvoice .NumMsat ) /  float64 (assetAmount )
1164+ 	var  mSatPerUnit  float64 
1165+ 
1166+ 	if  cfg .msats  >  0  {
1167+ 		require .EqualValues (t , decodedInvoice .NumMsat , cfg .msats )
1168+ 		units  :=  rfqmath .MilliSatoshiToUnits (cfg .msats , * rate )
11591169
1160- 	require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1170+ 		mSatPerUnit  =  float64 (cfg .msats ) /  float64 (units .ToUint64 ())
1171+ 	} else  {
1172+ 		assetUnits  :=  rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1173+ 		numMSats  :=  rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1174+ 		mSatPerUnit  =  float64 (decodedInvoice .NumMsat ) /  float64 (assetAmount )
1175+ 
1176+ 		require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1177+ 	}
11611178
11621179	t .Logf ("Got quote for %d mSats at %3f msat/unit from peer %x with " + 
11631180		"SCID %d" , decodedInvoice .NumMsat , mSatPerUnit ,
@@ -1319,7 +1336,7 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
13191336
13201337	require .EqualValues (t , uint64 (numMSats ), uint64 (decodedInvoice .NumMsat ))
13211338
1322- 	t .Logf ("Got quote for %d sats  at %v msat/unit from peer %x with SCID " + 
1339+ 	t .Logf ("Got quote for %d msats  at %v msat/unit from peer %x with SCID " + 
13231340		"%d" , decodedInvoice .NumMsat , mSatPerUnit , dstRfqPeer .PubKey [:],
13241341		resp .AcceptedBuyQuote .Scid )
13251342
0 commit comments