@@ -1124,6 +1124,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1124
1124
type invoiceConfig struct {
1125
1125
errSubStr string
1126
1126
groupKey []byte
1127
+ msats lnwire.MilliSatoshi
1127
1128
}
1128
1129
1129
1130
func defaultInvoiceConfig () * invoiceConfig {
@@ -1146,6 +1147,12 @@ func withInvGroupKey(groupKey []byte) invoiceOpt {
1146
1147
}
1147
1148
}
1148
1149
1150
+ func withMsatAmount (amt uint64 ) invoiceOpt {
1151
+ return func (c * invoiceConfig ) {
1152
+ c .msats = lnwire .MilliSatoshi (amt )
1153
+ }
1154
+ }
1155
+
1149
1156
func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1150
1157
assetAmount uint64 , assetID []byte ,
1151
1158
opts ... invoiceOpt ) * lnrpc.AddInvoiceResponse {
@@ -1181,7 +1188,8 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1181
1188
InvoiceRequest : & lnrpc.Invoice {
1182
1189
Memo : fmt .Sprintf ("this is an asset invoice for " +
1183
1190
"%d units" , assetAmount ),
1184
- Expiry : timeoutSeconds ,
1191
+ Expiry : timeoutSeconds ,
1192
+ ValueMsat : int64 (cfg .msats ),
1185
1193
},
1186
1194
})
1187
1195
if cfg .errSubStr != "" {
@@ -1203,11 +1211,20 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1203
1211
1204
1212
t .Logf ("Got quote for %v asset units per BTC" , rate )
1205
1213
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 )
1209
1219
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
+ }
1211
1228
1212
1229
t .Logf ("Got quote for %d mSats at %3f msat/unit from peer %x with " +
1213
1230
"SCID %d" , decodedInvoice .NumMsat , mSatPerUnit ,
@@ -1396,7 +1413,7 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1396
1413
1397
1414
require .EqualValues (t , uint64 (numMSats ), uint64 (decodedInvoice .NumMsat ))
1398
1415
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 " +
1400
1417
"%d" , decodedInvoice .NumMsat , mSatPerUnit , dstRfqPeer .PubKey [:],
1401
1418
resp .AcceptedBuyQuote .Scid )
1402
1419
0 commit comments