@@ -1102,6 +1102,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1102
1102
1103
1103
type invoiceConfig struct {
1104
1104
errSubStr string
1105
+ msats lnwire.MilliSatoshi
1105
1106
}
1106
1107
1107
1108
func defaultInvoiceConfig () * invoiceConfig {
@@ -1118,6 +1119,12 @@ func withInvoiceErrSubStr(errSubStr string) invoiceOpt {
1118
1119
}
1119
1120
}
1120
1121
1122
+ func withMsatAmount (amt uint64 ) invoiceOpt {
1123
+ return func (c * invoiceConfig ) {
1124
+ c .msats = lnwire .MilliSatoshi (amt )
1125
+ }
1126
+ }
1127
+
1121
1128
func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1122
1129
assetAmount uint64 , assetID []byte ,
1123
1130
opts ... invoiceOpt ) * lnrpc.AddInvoiceResponse {
@@ -1146,7 +1153,8 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1146
1153
InvoiceRequest : & lnrpc.Invoice {
1147
1154
Memo : fmt .Sprintf ("this is an asset invoice for " +
1148
1155
"%d units" , assetAmount ),
1149
- Expiry : timeoutSeconds ,
1156
+ Expiry : timeoutSeconds ,
1157
+ ValueMsat : int64 (cfg .msats ),
1150
1158
},
1151
1159
})
1152
1160
if cfg .errSubStr != "" {
@@ -1168,11 +1176,20 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1168
1176
1169
1177
t .Logf ("Got quote for %v asset units per BTC" , rate )
1170
1178
1171
- assetUnits := rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1172
- numMSats := rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1173
- mSatPerUnit := float64 (decodedInvoice .NumMsat ) / float64 (assetAmount )
1179
+ var mSatPerUnit float64
1180
+
1181
+ if cfg .msats > 0 {
1182
+ require .EqualValues (t , decodedInvoice .NumMsat , cfg .msats )
1183
+ units := rfqmath .MilliSatoshiToUnits (cfg .msats , * rate )
1174
1184
1175
- require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1185
+ mSatPerUnit = float64 (cfg .msats ) / float64 (units .ToUint64 ())
1186
+ } else {
1187
+ assetUnits := rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1188
+ numMSats := rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1189
+ mSatPerUnit = float64 (decodedInvoice .NumMsat ) / float64 (assetAmount )
1190
+
1191
+ require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1192
+ }
1176
1193
1177
1194
t .Logf ("Got quote for %d mSats at %3f msat/unit from peer %x with " +
1178
1195
"SCID %d" , decodedInvoice .NumMsat , mSatPerUnit ,
@@ -1334,7 +1351,7 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1334
1351
1335
1352
require .EqualValues (t , uint64 (numMSats ), uint64 (decodedInvoice .NumMsat ))
1336
1353
1337
- t .Logf ("Got quote for %d sats at %v msat/unit from peer %x with SCID " +
1354
+ t .Logf ("Got quote for %d msats at %v msat/unit from peer %x with SCID " +
1338
1355
"%d" , decodedInvoice .NumMsat , mSatPerUnit , dstRfqPeer .PubKey [:],
1339
1356
resp .AcceptedBuyQuote .Scid )
1340
1357
0 commit comments