diff --git a/itest/assets_test.go b/itest/assets_test.go index d22d15c7d..1cb7b3448 100644 --- a/itest/assets_test.go +++ b/itest/assets_test.go @@ -1427,6 +1427,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode, type invoiceConfig struct { errSubStr string groupKey []byte + msats lnwire.MilliSatoshi routeHints []*lnrpc.RouteHint } @@ -1450,6 +1451,12 @@ func withInvGroupKey(groupKey []byte) invoiceOpt { } } +func withMsatAmount(amt uint64) invoiceOpt { + return func(c *invoiceConfig) { + c.msats = lnwire.MilliSatoshi(amt) + } +} + func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode, assetAmount uint64, assetID []byte, opts ...invoiceOpt) *lnrpc.AddInvoiceResponse { @@ -1478,7 +1485,8 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode, InvoiceRequest: &lnrpc.Invoice{ Memo: fmt.Sprintf("this is an asset invoice for "+ "%d units", assetAmount), - Expiry: timeoutSeconds, + Expiry: timeoutSeconds, + ValueMsat: int64(cfg.msats), }, } @@ -1510,11 +1518,21 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode, t.Logf("Got quote for %v asset units per BTC", rate) - assetUnits := rfqmath.NewBigIntFixedPoint(assetAmount, 0) - numMSats := rfqmath.UnitsToMilliSatoshi(assetUnits, *rate) - mSatPerUnit := float64(decodedInvoice.NumMsat) / float64(assetAmount) + var mSatPerUnit float64 + + if cfg.msats > 0 { + require.EqualValues(t, decodedInvoice.NumMsat, cfg.msats) + units := rfqmath.MilliSatoshiToUnits(cfg.msats, *rate) - require.EqualValues(t, numMSats, decodedInvoice.NumMsat) + mSatPerUnit = float64(cfg.msats) / float64(units.ToUint64()) + } else { + assetUnits := rfqmath.NewBigIntFixedPoint(assetAmount, 0) + numMSats := rfqmath.UnitsToMilliSatoshi(assetUnits, *rate) + mSatPerUnit = float64(decodedInvoice.NumMsat) / + float64(assetAmount) + + require.EqualValues(t, numMSats, decodedInvoice.NumMsat) + } t.Logf("Got quote for %d mSats at %3f msat/unit from peer %x with "+ "SCID %d", decodedInvoice.NumMsat, mSatPerUnit, diff --git a/itest/litd_custom_channels_test.go b/itest/litd_custom_channels_test.go index d1912e2bc..3372d0d81 100644 --- a/itest/litd_custom_channels_test.go +++ b/itest/litd_custom_channels_test.go @@ -2679,10 +2679,13 @@ func testCustomChannelsLiquidityEdgeCasesCore(ctx context.Context, assertNumHtlcs(t.t, erin, 0) assertNumHtlcs(t.t, fabia, 0) - // Now Fabia creates the normal invoice. + // Now Fabia creates another invoice. We also use a fixed msat value for + // the invoice. Since our itest oracle evaluates every asset to about + // 17.1 sats, this invoice should be a bit below 10k assets, so roughly + // the same volume as the previous invoice we just cancelled. invoiceResp = createAssetInvoice( - t.t, erin, fabia, 10_000, assetID, - withInvGroupKey(groupID), + t.t, erin, fabia, 0, assetID, withInvGroupKey(groupID), + withMsatAmount(170_000_000), ) // Now Charlie pays the invoice, again by using the manually specified