@@ -1427,6 +1427,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1427
1427
type invoiceConfig struct {
1428
1428
errSubStr string
1429
1429
groupKey []byte
1430
+ msats lnwire.MilliSatoshi
1430
1431
routeHints []* lnrpc.RouteHint
1431
1432
}
1432
1433
@@ -1450,6 +1451,12 @@ func withInvGroupKey(groupKey []byte) invoiceOpt {
1450
1451
}
1451
1452
}
1452
1453
1454
+ func withMsatAmount (amt uint64 ) invoiceOpt {
1455
+ return func (c * invoiceConfig ) {
1456
+ c .msats = lnwire .MilliSatoshi (amt )
1457
+ }
1458
+ }
1459
+
1453
1460
func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1454
1461
assetAmount uint64 , assetID []byte ,
1455
1462
opts ... invoiceOpt ) * lnrpc.AddInvoiceResponse {
@@ -1478,7 +1485,8 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1478
1485
InvoiceRequest : & lnrpc.Invoice {
1479
1486
Memo : fmt .Sprintf ("this is an asset invoice for " +
1480
1487
"%d units" , assetAmount ),
1481
- Expiry : timeoutSeconds ,
1488
+ Expiry : timeoutSeconds ,
1489
+ ValueMsat : int64 (cfg .msats ),
1482
1490
},
1483
1491
}
1484
1492
@@ -1510,11 +1518,21 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1510
1518
1511
1519
t .Logf ("Got quote for %v asset units per BTC" , rate )
1512
1520
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 )
1516
1526
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
+ }
1518
1536
1519
1537
t .Logf ("Got quote for %d mSats at %3f msat/unit from peer %x with " +
1520
1538
"SCID %d" , decodedInvoice .NumMsat , mSatPerUnit ,
0 commit comments