@@ -1427,6 +1427,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
14271427type invoiceConfig struct {
14281428 errSubStr string
14291429 groupKey []byte
1430+ msats lnwire.MilliSatoshi
14301431 routeHints []* lnrpc.RouteHint
14311432}
14321433
@@ -1450,6 +1451,12 @@ func withInvGroupKey(groupKey []byte) invoiceOpt {
14501451 }
14511452}
14521453
1454+ func withMsatAmount (amt uint64 ) invoiceOpt {
1455+ return func (c * invoiceConfig ) {
1456+ c .msats = lnwire .MilliSatoshi (amt )
1457+ }
1458+ }
1459+
14531460func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
14541461 assetAmount uint64 , assetID []byte ,
14551462 opts ... invoiceOpt ) * lnrpc.AddInvoiceResponse {
@@ -1478,7 +1485,8 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
14781485 InvoiceRequest : & lnrpc.Invoice {
14791486 Memo : fmt .Sprintf ("this is an asset invoice for " +
14801487 "%d units" , assetAmount ),
1481- Expiry : timeoutSeconds ,
1488+ Expiry : timeoutSeconds ,
1489+ ValueMsat : int64 (cfg .msats ),
14821490 },
14831491 }
14841492
@@ -1510,11 +1518,21 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
15101518
15111519 t .Logf ("Got quote for %v asset units per BTC" , rate )
15121520
1513- assetUnits := rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1514- numMSats := rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1515- mSatPerUnit := float64 (decodedInvoice .NumMsat ) / float64 (assetAmount )
1521+ var mSatPerUnit float64
1522+
1523+ if cfg .msats > 0 {
1524+ require .EqualValues (t , decodedInvoice .NumMsat , cfg .msats )
1525+ units := rfqmath .MilliSatoshiToUnits (cfg .msats , * rate )
15161526
1517- require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1527+ mSatPerUnit = float64 (cfg .msats ) / float64 (units .ToUint64 ())
1528+ } else {
1529+ assetUnits := rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1530+ numMSats := rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1531+ mSatPerUnit = float64 (decodedInvoice .NumMsat ) /
1532+ float64 (assetAmount )
1533+
1534+ require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1535+ }
15181536
15191537 t .Logf ("Got quote for %d mSats at %3f msat/unit from peer %x with " +
15201538 "SCID %d" , decodedInvoice .NumMsat , mSatPerUnit ,
0 commit comments