@@ -1124,6 +1124,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
11241124type invoiceConfig struct {
11251125 errSubStr string
11261126 groupKey []byte
1127+ msats lnwire.MilliSatoshi
11271128}
11281129
11291130func defaultInvoiceConfig () * invoiceConfig {
@@ -1146,6 +1147,12 @@ func withInvGroupKey(groupKey []byte) invoiceOpt {
11461147 }
11471148}
11481149
1150+ func withMsatAmount (amt uint64 ) invoiceOpt {
1151+ return func (c * invoiceConfig ) {
1152+ c .msats = lnwire .MilliSatoshi (amt )
1153+ }
1154+ }
1155+
11491156func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
11501157 assetAmount uint64 , assetID []byte ,
11511158 opts ... invoiceOpt ) * lnrpc.AddInvoiceResponse {
@@ -1181,7 +1188,8 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
11811188 InvoiceRequest : & lnrpc.Invoice {
11821189 Memo : fmt .Sprintf ("this is an asset invoice for " +
11831190 "%d units" , assetAmount ),
1184- Expiry : timeoutSeconds ,
1191+ Expiry : timeoutSeconds ,
1192+ ValueMsat : int64 (cfg .msats ),
11851193 },
11861194 })
11871195 if cfg .errSubStr != "" {
@@ -1203,11 +1211,20 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
12031211
12041212 t .Logf ("Got quote for %v asset units per BTC" , rate )
12051213
1206- assetUnits := rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1207- numMSats := rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1208- mSatPerUnit := float64 (decodedInvoice .NumMsat ) / float64 (assetAmount )
1214+ var mSatPerUnit float64
1215+
1216+ if cfg .msats > 0 {
1217+ require .EqualValues (t , decodedInvoice .NumMsat , cfg .msats )
1218+ units := rfqmath .MilliSatoshiToUnits (cfg .msats , * rate )
12091219
1210- require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1220+ mSatPerUnit = float64 (cfg .msats ) / float64 (units .ToUint64 ())
1221+ } else {
1222+ assetUnits := rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1223+ numMSats := rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1224+ mSatPerUnit = float64 (decodedInvoice .NumMsat ) / float64 (assetAmount )
1225+
1226+ require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1227+ }
12111228
12121229 t .Logf ("Got quote for %d mSats at %3f msat/unit from peer %x with " +
12131230 "SCID %d" , decodedInvoice .NumMsat , mSatPerUnit ,
@@ -1396,7 +1413,7 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
13961413
13971414 require .EqualValues (t , uint64 (numMSats ), uint64 (decodedInvoice .NumMsat ))
13981415
1399- t .Logf ("Got quote for %d sats at %v msat/unit from peer %x with SCID " +
1416+ t .Logf ("Got quote for %d msats at %v msat/unit from peer %x with SCID " +
14001417 "%d" , decodedInvoice .NumMsat , mSatPerUnit , dstRfqPeer .PubKey [:],
14011418 resp .AcceptedBuyQuote .Scid )
14021419
0 commit comments