@@ -1087,6 +1087,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1087
1087
1088
1088
type invoiceConfig struct {
1089
1089
errSubStr string
1090
+ msats lnwire.MilliSatoshi
1090
1091
}
1091
1092
1092
1093
func defaultInvoiceConfig () * invoiceConfig {
@@ -1103,6 +1104,12 @@ func withInvoiceErrSubStr(errSubStr string) invoiceOpt {
1103
1104
}
1104
1105
}
1105
1106
1107
+ func withMsatAmount (amt uint64 ) invoiceOpt {
1108
+ return func (c * invoiceConfig ) {
1109
+ c .msats = lnwire .MilliSatoshi (amt )
1110
+ }
1111
+ }
1112
+
1106
1113
func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1107
1114
assetAmount uint64 , assetID []byte ,
1108
1115
opts ... invoiceOpt ) * lnrpc.AddInvoiceResponse {
@@ -1131,7 +1138,8 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1131
1138
InvoiceRequest : & lnrpc.Invoice {
1132
1139
Memo : fmt .Sprintf ("this is an asset invoice over " +
1133
1140
"%d units" , assetAmount ),
1134
- Expiry : timeoutSeconds ,
1141
+ Expiry : timeoutSeconds ,
1142
+ ValueMsat : int64 (cfg .msats ),
1135
1143
},
1136
1144
})
1137
1145
if cfg .errSubStr != "" {
@@ -1153,11 +1161,20 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1153
1161
1154
1162
t .Logf ("Got quote for %v asset units per BTC" , rate )
1155
1163
1156
- assetUnits := rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1157
- numMSats := rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1158
- mSatPerUnit := float64 (decodedInvoice .NumMsat ) / float64 (assetAmount )
1164
+ var mSatPerUnit float64
1165
+
1166
+ if cfg .msats > 0 {
1167
+ require .EqualValues (t , decodedInvoice .NumMsat , cfg .msats )
1168
+ units := rfqmath .MilliSatoshiToUnits (cfg .msats , * rate )
1159
1169
1160
- require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1170
+ mSatPerUnit = float64 (cfg .msats ) / float64 (units .ToUint64 ())
1171
+ } else {
1172
+ assetUnits := rfqmath .NewBigIntFixedPoint (assetAmount , 0 )
1173
+ numMSats := rfqmath .UnitsToMilliSatoshi (assetUnits , * rate )
1174
+ mSatPerUnit = float64 (decodedInvoice .NumMsat ) / float64 (assetAmount )
1175
+
1176
+ require .EqualValues (t , numMSats , decodedInvoice .NumMsat )
1177
+ }
1161
1178
1162
1179
t .Logf ("Got quote for %d mSats at %3f msat/unit from peer %x with " +
1163
1180
"SCID %d" , decodedInvoice .NumMsat , mSatPerUnit ,
@@ -1319,7 +1336,7 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1319
1336
1320
1337
require .EqualValues (t , uint64 (numMSats ), uint64 (decodedInvoice .NumMsat ))
1321
1338
1322
- t .Logf ("Got quote for %d sats at %v msat/unit from peer %x with SCID " +
1339
+ t .Logf ("Got quote for %d msats at %v msat/unit from peer %x with SCID " +
1323
1340
"%d" , decodedInvoice .NumMsat , mSatPerUnit , dstRfqPeer .PubKey [:],
1324
1341
resp .AcceptedBuyQuote .Scid )
1325
1342
0 commit comments