@@ -56,6 +56,10 @@ const (
5656 DefaultPushSat int64 = 1062
5757)
5858
59+ var (
60+ NoScidOpt = fn .None [rfqmsg.SerialisedScid ]()
61+ )
62+
5963// createTestAssetNetwork sends asset funds from Charlie to Dave and Erin, so
6064// they can fund asset channels with Yara and Fabia, respectively. So the asset
6165// channels created are Charlie->Dave, Dave->Yara, Erin->Fabia. The channels
@@ -714,6 +718,9 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
714718
715719 result , err := getAssetPaymentResult (stream , false )
716720 require .NoError (t , err )
721+ if result .Status == lnrpc .Payment_FAILED {
722+ t .Logf ("Failure reason: %v" , result .FailureReason )
723+ }
717724 require .Equal (t , expectedStatus , result .Status )
718725
719726 expectedReason := failReason .UnwrapOr (
@@ -792,7 +799,7 @@ func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
792799
793800 numUnits , _ := payInvoiceWithAssets (
794801 t , src , rfqPeer , invoiceResp .PaymentRequest , assetID , smallShards ,
795- fn .None [lnrpc.Payment_PaymentStatus ](),
802+ fn .None [lnrpc.Payment_PaymentStatus ](), NoScidOpt ,
796803 )
797804
798805 return numUnits
@@ -858,7 +865,8 @@ func payInvoiceWithSatoshiLastHop(t *testing.T, payer *HarnessNode,
858865
859866func payInvoiceWithAssets (t * testing.T , payer , rfqPeer * HarnessNode ,
860867 payReq string , assetID []byte , smallShards bool ,
861- expectedPayStatus fn.Option [lnrpc.Payment_PaymentStatus ]) (uint64 ,
868+ expectedPayStatus fn.Option [lnrpc.Payment_PaymentStatus ],
869+ manualRfq fn.Option [rfqmsg.SerialisedScid ]) (uint64 ,
862870 rfqmath.BigIntFixedPoint ) {
863871
864872 ctxb := context .Background ()
@@ -886,40 +894,52 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
886894 AssetId : assetID ,
887895 PeerPubkey : rfqPeer .PubKey [:],
888896 PaymentRequest : sendReq ,
897+ Scid : uint64 (manualRfq .UnwrapOr (0 )),
889898 })
890899 require .NoError (t , err )
891900
892- // We want to receive the accepted quote message first, so we know how
893- // many assets we're going to pay.
894- quoteMsg , err := stream .Recv ()
895- require .NoError (t , err )
896- acceptedQuote := quoteMsg .GetAcceptedSellOrder ()
897- require .NotNil (t , acceptedQuote )
901+ var (
902+ numUnits uint64
903+ rateVal rfqmath.FixedPoint [rfqmath.BigInt ]
904+ )
898905
899- peerPubKey := acceptedQuote .Peer
900- require .Equal (t , peerPubKey , rfqPeer .PubKeyStr )
906+ if manualRfq .IsNone () {
907+ // We want to receive the accepted quote message first, so we know how
908+ // many assets we're going to pay.
909+ quoteMsg , err := stream .Recv ()
910+ require .NoError (t , err )
911+ acceptedQuote := quoteMsg .GetAcceptedSellOrder ()
912+ require .NotNil (t , acceptedQuote )
901913
902- rpcRate := acceptedQuote .BidAssetRate
903- rate , err := rfqrpc .UnmarshalFixedPoint (rpcRate )
904- require .NoError (t , err )
914+ peerPubKey := acceptedQuote .Peer
915+ require .Equal (t , peerPubKey , rfqPeer .PubKeyStr )
905916
906- t .Logf ("Got quote for %v asset units per BTC" , rate )
917+ rpcRate := acceptedQuote .BidAssetRate
918+ rate , err := rfqrpc .UnmarshalFixedPoint (rpcRate )
919+ require .NoError (t , err )
920+
921+ rateVal = * rate
907922
908- amountMsat := lnwire .MilliSatoshi (decodedInvoice .NumMsat )
909- milliSatsFP := rfqmath .MilliSatoshiToUnits (amountMsat , * rate )
910- numUnits := milliSatsFP .ScaleTo (0 ).ToUint64 ()
911- msatPerUnit := float64 (decodedInvoice .NumMsat ) / float64 (numUnits )
912- t .Logf ("Got quote for %v asset units at %3f msat/unit from peer %s " +
913- "with SCID %d" , numUnits , msatPerUnit , peerPubKey ,
914- acceptedQuote .Scid )
923+ t .Logf ("Got quote for %v asset units per BTC" , rate )
924+
925+ amountMsat := lnwire .MilliSatoshi (decodedInvoice .NumMsat )
926+ milliSatsFP := rfqmath .MilliSatoshiToUnits (amountMsat , * rate )
927+ numUnits = milliSatsFP .ScaleTo (0 ).ToUint64 ()
928+ msatPerUnit := float64 (decodedInvoice .NumMsat ) / float64 (numUnits )
929+ t .Logf ("Got quote for %v asset units at %3f msat/unit from peer %s " +
930+ "with SCID %d" , numUnits , msatPerUnit , peerPubKey ,
931+ acceptedQuote .Scid )
932+ }
915933
916934 expectedStatus := expectedPayStatus .UnwrapOr (lnrpc .Payment_SUCCEEDED )
917935
918- result , err := getAssetPaymentResult (stream , expectedPayStatus .IsSome ())
936+ result , err := getAssetPaymentResult (
937+ stream , expectedStatus == lnrpc .Payment_IN_FLIGHT ,
938+ )
919939 require .NoError (t , err )
920940 require .Equal (t , expectedStatus , result .Status )
921941
922- return numUnits , * rate
942+ return numUnits , rateVal
923943}
924944
925945func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
0 commit comments