@@ -56,6 +56,10 @@ const (
56
56
DefaultPushSat int64 = 1062
57
57
)
58
58
59
+ var (
60
+ NoRfqIDOpt = fn .None [rfqmsg.ID ]()
61
+ )
62
+
59
63
// createTestAssetNetwork sends asset funds from Charlie to Dave and Erin, so
60
64
// they can fund asset channels with Yara and Fabia, respectively. So the asset
61
65
// 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,
714
718
715
719
result , err := getAssetPaymentResult (stream , false )
716
720
require .NoError (t , err )
721
+ if result .Status == lnrpc .Payment_FAILED {
722
+ t .Logf ("Failure reason: %v" , result .FailureReason )
723
+ }
717
724
require .Equal (t , expectedStatus , result .Status )
718
725
719
726
expectedReason := failReason .UnwrapOr (
@@ -772,7 +779,9 @@ func createAndPayNormalInvoiceWithBtc(t *testing.T, src, dst *HarnessNode,
772
779
})
773
780
require .NoError (t , err )
774
781
775
- payInvoiceWithSatoshi (t , src , invoiceResp , lnrpc .Payment_SUCCEEDED )
782
+ payInvoiceWithSatoshi (
783
+ t , src , invoiceResp , lnrpc .Payment_SUCCEEDED , false ,
784
+ )
776
785
}
777
786
778
787
func createAndPayNormalInvoice (t * testing.T , src , rfqPeer , dst * HarnessNode ,
@@ -792,15 +801,15 @@ func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
792
801
793
802
numUnits , _ := payInvoiceWithAssets (
794
803
t , src , rfqPeer , invoiceResp .PaymentRequest , assetID , smallShards ,
795
- fn .None [lnrpc.Payment_PaymentStatus ](),
804
+ fn .None [lnrpc.Payment_PaymentStatus ](), NoRfqIDOpt ,
796
805
)
797
806
798
807
return numUnits
799
808
}
800
809
801
810
func payInvoiceWithSatoshi (t * testing.T , payer * HarnessNode ,
802
811
invoice * lnrpc.AddInvoiceResponse ,
803
- expectedStatus lnrpc.Payment_PaymentStatus ) {
812
+ expectedStatus lnrpc.Payment_PaymentStatus , expectTimeout bool ) {
804
813
805
814
ctxb := context .Background ()
806
815
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
@@ -816,8 +825,12 @@ func payInvoiceWithSatoshi(t *testing.T, payer *HarnessNode,
816
825
require .NoError (t , err )
817
826
818
827
result , err := getPaymentResult (stream )
819
- require .NoError (t , err )
820
- require .Equal (t , expectedStatus , result .Status )
828
+ if expectTimeout {
829
+ require .ErrorContains (t , err , "context deadline exceeded" )
830
+ } else {
831
+ require .NoError (t , err )
832
+ require .Equal (t , expectedStatus , result .Status )
833
+ }
821
834
}
822
835
823
836
func payInvoiceWithSatoshiLastHop (t * testing.T , payer * HarnessNode ,
@@ -858,7 +871,8 @@ func payInvoiceWithSatoshiLastHop(t *testing.T, payer *HarnessNode,
858
871
859
872
func payInvoiceWithAssets (t * testing.T , payer , rfqPeer * HarnessNode ,
860
873
payReq string , assetID []byte , smallShards bool ,
861
- expectedPayStatus fn.Option [lnrpc.Payment_PaymentStatus ]) (uint64 ,
874
+ expectedPayStatus fn.Option [lnrpc.Payment_PaymentStatus ],
875
+ manualRfq fn.Option [rfqmsg.ID ]) (uint64 ,
862
876
rfqmath.BigIntFixedPoint ) {
863
877
864
878
ctxb := context .Background ()
@@ -882,44 +896,61 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
882
896
sendReq .MaxShardSizeMsat = 80_000_000
883
897
}
884
898
899
+ var rfqBytes []byte
900
+ manualRfq .WhenSome (func (i rfqmsg.ID ) {
901
+ copy (rfqBytes , i [:])
902
+ })
903
+
885
904
stream , err := payerTapd .SendPayment (ctxt , & tchrpc.SendPaymentRequest {
886
905
AssetId : assetID ,
887
906
PeerPubkey : rfqPeer .PubKey [:],
888
907
PaymentRequest : sendReq ,
908
+ RfqId : rfqBytes ,
889
909
})
890
910
require .NoError (t , err )
891
911
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 )
912
+ var (
913
+ numUnits uint64
914
+ rateVal rfqmath.FixedPoint [rfqmath.BigInt ]
915
+ )
898
916
899
- peerPubKey := acceptedQuote .Peer
900
- require .Equal (t , peerPubKey , rfqPeer .PubKeyStr )
917
+ if manualRfq .IsNone () {
918
+ // We want to receive the accepted quote message first, so we know how
919
+ // many assets we're going to pay.
920
+ quoteMsg , err := stream .Recv ()
921
+ require .NoError (t , err )
922
+ acceptedQuote := quoteMsg .GetAcceptedSellOrder ()
923
+ require .NotNil (t , acceptedQuote )
901
924
902
- rpcRate := acceptedQuote .BidAssetRate
903
- rate , err := rfqrpc .UnmarshalFixedPoint (rpcRate )
904
- require .NoError (t , err )
925
+ peerPubKey := acceptedQuote .Peer
926
+ require .Equal (t , peerPubKey , rfqPeer .PubKeyStr )
905
927
906
- t .Logf ("Got quote for %v asset units per BTC" , rate )
928
+ rpcRate := acceptedQuote .BidAssetRate
929
+ rate , err := rfqrpc .UnmarshalFixedPoint (rpcRate )
930
+ require .NoError (t , err )
931
+
932
+ rateVal = * rate
907
933
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 )
934
+ t .Logf ("Got quote for %v asset units per BTC" , rate )
935
+
936
+ amountMsat := lnwire .MilliSatoshi (decodedInvoice .NumMsat )
937
+ milliSatsFP := rfqmath .MilliSatoshiToUnits (amountMsat , * rate )
938
+ numUnits = milliSatsFP .ScaleTo (0 ).ToUint64 ()
939
+ msatPerUnit := float64 (decodedInvoice .NumMsat ) / float64 (numUnits )
940
+ t .Logf ("Got quote for %v asset units at %3f msat/unit from peer %s " +
941
+ "with SCID %d" , numUnits , msatPerUnit , peerPubKey ,
942
+ acceptedQuote .Scid )
943
+ }
915
944
916
945
expectedStatus := expectedPayStatus .UnwrapOr (lnrpc .Payment_SUCCEEDED )
917
946
918
- result , err := getAssetPaymentResult (stream , expectedPayStatus .IsSome ())
947
+ result , err := getAssetPaymentResult (
948
+ stream , expectedStatus == lnrpc .Payment_IN_FLIGHT ,
949
+ )
919
950
require .NoError (t , err )
920
951
require .Equal (t , expectedStatus , result .Status )
921
952
922
- return numUnits , * rate
953
+ return numUnits , rateVal
923
954
}
924
955
925
956
func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
0 commit comments