@@ -594,11 +594,13 @@ func genHopHints(t *rapid.T, rfqID rfqmsg.ID) []*lnrpc.HopHint {
594
594
// genCustomRecords generates custom records that have a random amount of random
595
595
// asset units, and may have an SCID as routing hint.
596
596
func genCustomRecords (t * rapid.T , amtMsat int64 ,
597
- rfqID rfqmsg.ID ) (lnwire.CustomRecords , uint64 ) {
597
+ rfqID rfqmsg.ID ) (asset.ID , lnwire.CustomRecords , uint64 ) {
598
+
599
+ var assetID asset.ID
598
600
599
601
// Introduce a chance of no wire custom records.
600
602
if rapid .Bool ().Draw (t , "no_wire_custom_records" ) {
601
- return nil , 0
603
+ return assetID , nil , 0
602
604
}
603
605
604
606
// Pick a random number of asset units. The amount of units may be as
@@ -609,19 +611,18 @@ func genCustomRecords(t *rapid.T, amtMsat int64,
609
611
uint64 (amtMsat * 1000 )+ 1 ,
610
612
).Draw (t , "asset_units" )
611
613
614
+ assetID = dummyAssetID (rapid .Byte ().Draw (t , "asset_id" ))
615
+
612
616
balance := []* rfqmsg.AssetBalance {
613
- rfqmsg .NewAssetBalance (
614
- dummyAssetID (rapid .Byte ().Draw (t , "asset_id" )),
615
- assetUnits ,
616
- ),
617
+ rfqmsg .NewAssetBalance (assetID , assetUnits ),
617
618
}
618
619
619
620
htlc := genHtlc (t , balance , rfqID )
620
621
621
622
customRecords , err := lnwire .ParseCustomRecords (htlc .Bytes ())
622
623
require .NoError (t , err )
623
624
624
- return customRecords , assetUnits
625
+ return assetID , customRecords , assetUnits
625
626
}
626
627
627
628
// genHtlc generates an instance of rfqmsg.Htlc with the provided asset amounts
@@ -648,7 +649,7 @@ func genHtlc(t *rapid.T, balance []*rfqmsg.AssetBalance,
648
649
// genRequest generates an InvoiceHtlcModifyRequest with random values. This
649
650
// method also returns the assetUnits and the rfqID used by the htlc.
650
651
func genRequest (t * rapid.T ) (lndclient.InvoiceHtlcModifyRequest , uint64 ,
651
- rfqmsg.ID ) {
652
+ asset. ID , rfqmsg.ID ) {
652
653
653
654
request := lndclient.InvoiceHtlcModifyRequest {}
654
655
@@ -661,13 +662,13 @@ func genRequest(t *rapid.T) (lndclient.InvoiceHtlcModifyRequest, uint64,
661
662
recordsAmt = request .Invoice .ValueMsat
662
663
}
663
664
664
- wireRecords , assetUnits := genCustomRecords (
665
+ assetID , wireRecords , assetUnits := genCustomRecords (
665
666
t , recordsAmt , rfqID ,
666
667
)
667
668
request .WireCustomRecords = wireRecords
668
669
request .ExitHtlcAmt = lnwire .MilliSatoshi (recordsAmt )
669
670
670
- return request , assetUnits , rfqID
671
+ return request , assetUnits , assetID , rfqID
671
672
}
672
673
673
674
// genRequests generates a random array of requests to be processed by the
@@ -681,15 +682,15 @@ func genRequests(t *rapid.T) ([]lndclient.InvoiceHtlcModifyRequest,
681
682
requests := make ([]lndclient.InvoiceHtlcModifyRequest , 0 )
682
683
683
684
for range numRequests {
684
- req , numAssets , scid := genRequest (t )
685
+ req , numAssets , assetID , scid := genRequest (t )
685
686
requests = append (requests , req )
686
687
687
688
quoteAmt := uint64 (0 )
688
689
if req .Invoice != nil {
689
690
quoteAmt = uint64 (req .Invoice .ValueMsat )
690
691
}
691
692
692
- genBuyQuotes (t , rfqMap , numAssets , quoteAmt , scid )
693
+ genBuyQuotes (t , rfqMap , numAssets , quoteAmt , assetID , scid )
693
694
}
694
695
695
696
return requests , rfqMap
@@ -708,7 +709,7 @@ func genRandomVertex(t *rapid.T) route.Vertex {
708
709
// genBuyQuotes populates the provided map of rfq quotes with the desired values
709
710
// for a specific
710
711
func genBuyQuotes (t * rapid.T , rfqMap rfq.BuyAcceptMap , units , amtMsat uint64 ,
711
- scid rfqmsg.ID ) {
712
+ assetID asset. ID , scid rfqmsg.ID ) {
712
713
713
714
// If the passed asset units is set to 0 this means that no wire custom
714
715
// records were set. To avoid a division by zero in the lines below we
@@ -762,6 +763,9 @@ func genBuyQuotes(t *rapid.T, rfqMap rfq.BuyAcceptMap, units, amtMsat uint64,
762
763
rfqMap [rfqScid .Scid ()] = rfqmsg.BuyAccept {
763
764
Peer : peer ,
764
765
AssetRate : rfqmsg .NewAssetRate (rateFp , time .Now ()),
766
+ Request : rfqmsg.BuyRequest {
767
+ AssetSpecifier : asset .NewSpecifierFromId (assetID ),
768
+ },
765
769
}
766
770
}
767
771
0 commit comments