@@ -1425,6 +1425,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1425
1425
type invoiceConfig struct {
1426
1426
errSubStr string
1427
1427
groupKey []byte
1428
+ msats lnwire.MilliSatoshi
1428
1429
}
1429
1430
1430
1431
func defaultInvoiceConfig () * invoiceConfig {
@@ -1447,6 +1448,12 @@ func withInvGroupKey(groupKey []byte) invoiceOpt {
1447
1448
}
1448
1449
}
1449
1450
1451
+ func withMsatAmount (amt uint64 ) invoiceOpt {
1452
+ return func (c * invoiceConfig ) {
1453
+ c .msats = lnwire .MilliSatoshi (amt )
1454
+ }
1455
+ }
1456
+
1450
1457
func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1451
1458
assetAmount uint64 , assetID []byte ,
1452
1459
opts ... invoiceOpt ) * lnrpc.AddInvoiceResponse {
@@ -1475,7 +1482,8 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1475
1482
InvoiceRequest : & lnrpc.Invoice {
1476
1483
Memo : fmt .Sprintf ("this is an asset invoice for " +
1477
1484
"%d units" , assetAmount ),
1478
- Expiry : timeoutSeconds ,
1485
+ Expiry : timeoutSeconds ,
1486
+ ValueMsat : int64 (cfg .msats ),
1479
1487
},
1480
1488
}
1481
1489
@@ -1507,11 +1515,20 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1507
1515
1508
1516
t .Logf ("Got quote for %v asset units per BTC" , rate )
1509
1517
1510
- assetUnits := rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1511
- numMSats := rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1512
- mSatPerUnit := float64 (decodedInvoice .NumMsat ) / float64 (assetAmount )
1518
+ var mSatPerUnit float64
1519
+
1520
+ if cfg .msats > 0 {
1521
+ require .EqualValues (t , decodedInvoice .NumMsat , cfg .msats )
1522
+ units := rfqmath .MilliSatoshiToUnits (cfg .msats , * rate )
1513
1523
1514
- require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1524
+ mSatPerUnit = float64 (cfg .msats ) / float64 (units .ToUint64 ())
1525
+ } else {
1526
+ assetUnits := rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1527
+ numMSats := rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1528
+ mSatPerUnit = float64 (decodedInvoice .NumMsat ) / float64 (assetAmount )
1529
+
1530
+ require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1531
+ }
1515
1532
1516
1533
t .Logf ("Got quote for %d mSats at %3f msat/unit from peer %x with " +
1517
1534
"SCID %d" , decodedInvoice .NumMsat , mSatPerUnit ,
0 commit comments