@@ -1420,6 +1420,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1420
1420
type invoiceConfig struct {
1421
1421
errSubStr string
1422
1422
groupKey []byte
1423
+ msats lnwire.MilliSatoshi
1423
1424
}
1424
1425
1425
1426
func defaultInvoiceConfig () * invoiceConfig {
@@ -1442,6 +1443,12 @@ func withInvGroupKey(groupKey []byte) invoiceOpt {
1442
1443
}
1443
1444
}
1444
1445
1446
+ func withMsatAmount (amt uint64 ) invoiceOpt {
1447
+ return func (c * invoiceConfig ) {
1448
+ c .msats = lnwire .MilliSatoshi (amt )
1449
+ }
1450
+ }
1451
+
1445
1452
func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1446
1453
assetAmount uint64 , assetID []byte ,
1447
1454
opts ... invoiceOpt ) * lnrpc.AddInvoiceResponse {
@@ -1470,7 +1477,8 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1470
1477
InvoiceRequest : & lnrpc.Invoice {
1471
1478
Memo : fmt .Sprintf ("this is an asset invoice for " +
1472
1479
"%d units" , assetAmount ),
1473
- Expiry : timeoutSeconds ,
1480
+ Expiry : timeoutSeconds ,
1481
+ ValueMsat : int64 (cfg .msats ),
1474
1482
},
1475
1483
}
1476
1484
@@ -1502,11 +1510,20 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1502
1510
1503
1511
t .Logf ("Got quote for %v asset units per BTC" , rate )
1504
1512
1505
- assetUnits := rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1506
- numMSats := rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1507
- mSatPerUnit := float64 (decodedInvoice .NumMsat ) / float64 (assetAmount )
1513
+ var mSatPerUnit float64
1514
+
1515
+ if cfg .msats > 0 {
1516
+ require .EqualValues (t , decodedInvoice .NumMsat , cfg .msats )
1517
+ units := rfqmath .MilliSatoshiToUnits (cfg .msats , * rate )
1508
1518
1509
- require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1519
+ mSatPerUnit = float64 (cfg .msats ) / float64 (units .ToUint64 ())
1520
+ } else {
1521
+ assetUnits := rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1522
+ numMSats := rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1523
+ mSatPerUnit = float64 (decodedInvoice .NumMsat ) / float64 (assetAmount )
1524
+
1525
+ require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1526
+ }
1510
1527
1511
1528
t .Logf ("Got quote for %d mSats at %3f msat/unit from peer %x with " +
1512
1529
"SCID %d" , decodedInvoice .NumMsat , mSatPerUnit ,
0 commit comments