77	"encoding/json" 
88	"fmt" 
99	"math/big" 
10+ 	"math/rand/v2" 
1011	"testing" 
1112	"time" 
1213
@@ -271,28 +272,29 @@ func (m *mockHtlcModifierProperty) HtlcModifier(ctx context.Context,
271272			continue 
272273		}
273274
274- 		assetRate  :=  lnwire .MilliSatoshi (
275- 			quote .AssetRate .Rate .ToUint64 (),
276- 		)
277- 		msatPerBtc  :=  float64 (btcutil .SatoshiPerBitcoin  *  1000 )
278- 		unitValue  :=  msatPerBtc  /  float64 (assetRate )
279- 		assetUnits  :=  lnwire .MilliSatoshi (htlc .Amounts .Val .Sum ())
280- 
281- 		floatValue  :=  float64 (assetUnits ) *  unitValue 
275+ 		assetRate  :=  quote .AssetRate .Rate 
276+ 		htlcAssets  :=  htlc .Amounts .Val .Sum ()
277+ 		totalAssetAmount  :=  rfqmath .NewBigIntFixedPoint (htlcAssets , 0 )
282278
283- 		assetValueMsat  :=  lnwire .MilliSatoshi (floatValue )
279+ 		amtPaid  :=  rfqmath .UnitsToMilliSatoshi (
280+ 			totalAssetAmount , assetRate ,
281+ 		)
284282
285283		acceptedMsat  :=  lnwire .MilliSatoshi (0 )
286284		for  _ , htlc  :=  range  r .Invoice .Htlcs  {
287285			acceptedMsat  +=  lnwire .MilliSatoshi (htlc .AmtMsat )
288286		}
289287
290- 		marginHtlcs  :=  len (r .Invoice .Htlcs ) +  1 
291- 		marginMsat  :=  lnwire .MilliSatoshi (
292- 			float64 (marginHtlcs ) *  unitValue ,
288+ 		marginHtlcs  :=  uint64 (len (r .Invoice .Htlcs ) +  1 )
289+ 		marginHtlcs ++ 
290+ 
291+ 		marginAssetUnits  :=  rfqmath .NewBigIntFixedPoint (marginHtlcs , 0 )
292+ 
293+ 		marginMsat  :=  rfqmath .UnitsToMilliSatoshi (
294+ 			marginAssetUnits , assetRate ,
293295		)
294296
295- 		totalMsatIn  :=  marginMsat  +  assetValueMsat  +  acceptedMsat  +  1 
297+ 		totalMsatIn  :=  marginMsat  +  amtPaid  +  acceptedMsat  +  1 
296298
297299		invoiceValue  :=  lnwire .MilliSatoshi (r .Invoice .ValueMsat )
298300
@@ -301,9 +303,9 @@ func (m *mockHtlcModifierProperty) HtlcModifier(ctx context.Context,
301303				m .t .Errorf ("amt + accepted != invoice amt" )
302304			}
303305		} else  {
304- 			if  assetValueMsat  !=  res .AmtPaid  {
306+ 			if  amtPaid  !=  res .AmtPaid  {
305307				m .t .Errorf ("unexpected final asset value, " + 
306- 					"wanted %d, got %d" , assetValueMsat ,
308+ 					"wanted %d, got %d" , amtPaid ,
307309					res .AmtPaid )
308310			}
309311		}
@@ -819,11 +821,10 @@ func genHtlc(t *rapid.T, balance []*rfqmsg.AssetBalance,
819821// method also returns the assetUnits and the rfqID used by the htlc. 
820822func  genRequest (t  * rapid.T ) (lndclient.InvoiceHtlcModifyRequest , uint64 ,
821823	asset.ID , rfqmsg.ID ) {
822- 
823824	request  :=  lndclient.InvoiceHtlcModifyRequest {
824825		CircuitKey : invoices.CircuitKey {
825826			ChanID : lnwire .NewShortChanIDFromInt (
826- 				rapid .Uint64 (). Draw ( t ,  "chan_id" ),
827+ 				rand .Uint64 (),
827828			),
828829		},
829830	}
0 commit comments