@@ -56,6 +56,10 @@ const (
56
56
DefaultPushSat int64 = 1062
57
57
)
58
58
59
+ var (
60
+ NoScidOpt = fn .None [rfqmsg.SerialisedScid ]()
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 (
@@ -792,7 +799,7 @@ func createAndPayNormalInvoice(t *testing.T, src, rfqPeer, dst *HarnessNode,
792
799
793
800
numUnits , _ := payInvoiceWithAssets (
794
801
t , src , rfqPeer , invoiceResp .PaymentRequest , assetID , smallShards ,
795
- fn .None [lnrpc.Payment_PaymentStatus ](),
802
+ fn .None [lnrpc.Payment_PaymentStatus ](), NoScidOpt ,
796
803
)
797
804
798
805
return numUnits
@@ -858,7 +865,8 @@ func payInvoiceWithSatoshiLastHop(t *testing.T, payer *HarnessNode,
858
865
859
866
func payInvoiceWithAssets (t * testing.T , payer , rfqPeer * HarnessNode ,
860
867
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 ,
862
870
rfqmath.BigIntFixedPoint ) {
863
871
864
872
ctxb := context .Background ()
@@ -886,40 +894,52 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
886
894
AssetId : assetID ,
887
895
PeerPubkey : rfqPeer .PubKey [:],
888
896
PaymentRequest : sendReq ,
897
+ Scid : uint64 (manualRfq .UnwrapOr (0 )),
889
898
})
890
899
require .NoError (t , err )
891
900
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
+ )
898
905
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 )
901
913
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 )
905
916
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
907
922
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
+ }
915
933
916
934
expectedStatus := expectedPayStatus .UnwrapOr (lnrpc .Payment_SUCCEEDED )
917
935
918
- result , err := getAssetPaymentResult (stream , expectedPayStatus .IsSome ())
936
+ result , err := getAssetPaymentResult (
937
+ stream , expectedStatus == lnrpc .Payment_IN_FLIGHT ,
938
+ )
919
939
require .NoError (t , err )
920
940
require .Equal (t , expectedStatus , result .Status )
921
941
922
- return numUnits , * rate
942
+ return numUnits , rateVal
923
943
}
924
944
925
945
func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
0 commit comments