@@ -726,6 +726,12 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
726
726
opt (cfg )
727
727
}
728
728
729
+ // Nullify assetID if group key is set. RPC methods won't accept both so
730
+ // let's prioritize the group key if set.
731
+ if len (cfg .groupKey ) > 0 {
732
+ assetID = nil
733
+ }
734
+
729
735
ctxb := context .Background ()
730
736
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
731
737
defer cancel ()
@@ -755,6 +761,7 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
755
761
stream , err := srcTapd .SendPayment (ctxt , & tchrpc.SendPaymentRequest {
756
762
AssetId : assetID ,
757
763
AssetAmount : amt ,
764
+ GroupKey : cfg .groupKey ,
758
765
PaymentRequest : sendReq ,
759
766
})
760
767
require .NoError (t , err )
@@ -927,6 +934,7 @@ type payConfig struct {
927
934
payStatus lnrpc.Payment_PaymentStatus
928
935
failureReason lnrpc.PaymentFailureReason
929
936
rfq fn.Option [rfqmsg.ID ]
937
+ groupKey []byte
930
938
}
931
939
932
940
func defaultPayConfig () * payConfig {
@@ -941,6 +949,16 @@ func defaultPayConfig() *payConfig {
941
949
942
950
type payOpt func (* payConfig )
943
951
952
+ func withMaybeGroupKey (groupMode bool , groupKey []byte ) payOpt {
953
+ return func (c * payConfig ) {
954
+ if ! groupMode {
955
+ return
956
+ }
957
+
958
+ c .groupKey = groupKey
959
+ }
960
+ }
961
+
944
962
func withSmallShards () payOpt {
945
963
return func (c * payConfig ) {
946
964
c .smallShards = true
@@ -995,6 +1013,12 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
995
1013
opt (cfg )
996
1014
}
997
1015
1016
+ // Nullify assetID if group key is set. RPC methods won't accept both so
1017
+ // let's prioritize the group key if set.
1018
+ if len (cfg .groupKey ) > 0 {
1019
+ assetID = []byte {}
1020
+ }
1021
+
998
1022
ctxb := context .Background ()
999
1023
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
1000
1024
defer cancel ()
@@ -1026,6 +1050,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1026
1050
stream , err := payerTapd .SendPayment (ctxt , & tchrpc.SendPaymentRequest {
1027
1051
AssetId : assetID ,
1028
1052
PeerPubkey : rfqPeer .PubKey [:],
1053
+ GroupKey : cfg .groupKey ,
1029
1054
PaymentRequest : sendReq ,
1030
1055
RfqId : rfqBytes ,
1031
1056
AllowOverpay : cfg .allowOverpay ,
@@ -1087,6 +1112,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1087
1112
1088
1113
type invoiceConfig struct {
1089
1114
errSubStr string
1115
+ groupKey []byte
1090
1116
}
1091
1117
1092
1118
func defaultInvoiceConfig () * invoiceConfig {
@@ -1103,6 +1129,16 @@ func withInvoiceErrSubStr(errSubStr string) invoiceOpt {
1103
1129
}
1104
1130
}
1105
1131
1132
+ func withMaybeInvGroupKey (groupMode bool , groupKey []byte ) invoiceOpt {
1133
+ return func (c * invoiceConfig ) {
1134
+ if ! groupMode {
1135
+ return
1136
+ }
1137
+
1138
+ c .groupKey = groupKey
1139
+ }
1140
+ }
1141
+
1106
1142
func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1107
1143
assetAmount uint64 , assetID []byte ,
1108
1144
opts ... invoiceOpt ) * lnrpc.AddInvoiceResponse {
@@ -1112,6 +1148,12 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1112
1148
opt (cfg )
1113
1149
}
1114
1150
1151
+ // Nullify assetID if group key is set. RPC methods won't accept both so
1152
+ // let's prioritize the group key if set.
1153
+ if len (cfg .groupKey ) > 0 {
1154
+ assetID = []byte {}
1155
+ }
1156
+
1115
1157
ctxb := context .Background ()
1116
1158
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
1117
1159
defer cancel ()
@@ -1126,6 +1168,7 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1126
1168
1127
1169
resp , err := dstTapd .AddInvoice (ctxt , & tchrpc.AddInvoiceRequest {
1128
1170
AssetId : assetID ,
1171
+ GroupKey : cfg .groupKey ,
1129
1172
AssetAmount : assetAmount ,
1130
1173
PeerPubkey : dstRfqPeer .PubKey [:],
1131
1174
InvoiceRequest : & lnrpc.Invoice {
@@ -1170,7 +1213,7 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1170
1213
// individual HTLCs that arrived for it and that they show the correct asset
1171
1214
// amounts for the given ID when decoded.
1172
1215
func assertInvoiceHtlcAssets (t * testing.T , node * HarnessNode ,
1173
- addedInvoice * lnrpc.AddInvoiceResponse , assetID []byte ,
1216
+ addedInvoice * lnrpc.AddInvoiceResponse , assetID []byte , groupID [] byte ,
1174
1217
assetAmount uint64 ) {
1175
1218
1176
1219
ctxb := context .Background ()
@@ -1189,7 +1232,14 @@ func assertInvoiceHtlcAssets(t *testing.T, node *HarnessNode,
1189
1232
1190
1233
t .Logf ("Asset invoice: %v" , toProtoJSON (t , invoice ))
1191
1234
1192
- targetID := hex .EncodeToString (assetID )
1235
+ var targetID string
1236
+ switch {
1237
+ case len (groupID ) > 0 :
1238
+ targetID = hex .EncodeToString (groupID )
1239
+
1240
+ case len (assetID ) > 0 :
1241
+ targetID = hex .EncodeToString (assetID )
1242
+ }
1193
1243
1194
1244
var totalAssetAmount uint64
1195
1245
for _ , htlc := range invoice .Htlcs {
@@ -1216,7 +1266,7 @@ func assertInvoiceHtlcAssets(t *testing.T, node *HarnessNode,
1216
1266
// individual HTLCs that arrived for it and that they show the correct asset
1217
1267
// amounts for the given ID when decoded.
1218
1268
func assertPaymentHtlcAssets (t * testing.T , node * HarnessNode , payHash []byte ,
1219
- assetID []byte , assetAmount uint64 ) {
1269
+ assetID []byte , groupID [] byte , assetAmount uint64 ) {
1220
1270
1221
1271
ctxb := context .Background ()
1222
1272
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
@@ -1237,7 +1287,14 @@ func assertPaymentHtlcAssets(t *testing.T, node *HarnessNode, payHash []byte,
1237
1287
1238
1288
t .Logf ("Asset payment: %v" , toProtoJSON (t , payment ))
1239
1289
1240
- targetID := hex .EncodeToString (assetID )
1290
+ var targetID string
1291
+ switch {
1292
+ case len (groupID ) > 0 :
1293
+ targetID = hex .EncodeToString (groupID )
1294
+
1295
+ case len (assetID ) > 0 :
1296
+ targetID = hex .EncodeToString (assetID )
1297
+ }
1241
1298
1242
1299
var totalAssetAmount uint64
1243
1300
for _ , htlc := range payment .Htlcs {
@@ -1267,7 +1324,19 @@ type assetHodlInvoice struct {
1267
1324
}
1268
1325
1269
1326
func createAssetHodlInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1270
- assetAmount uint64 , assetID []byte ) assetHodlInvoice {
1327
+ assetAmount uint64 , assetID []byte ,
1328
+ opts ... invoiceOpt ) assetHodlInvoice {
1329
+
1330
+ cfg := defaultInvoiceConfig ()
1331
+ for _ , opt := range opts {
1332
+ opt (cfg )
1333
+ }
1334
+
1335
+ // Nullify assetID if group key is set. RPC methods won't accept both so
1336
+ // let's prioritize the group key if set.
1337
+ if len (cfg .groupKey ) > 0 {
1338
+ assetID = []byte {}
1339
+ }
1271
1340
1272
1341
ctxb := context .Background ()
1273
1342
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
@@ -1291,6 +1360,7 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1291
1360
1292
1361
resp , err := dstTapd .AddInvoice (ctxt , & tchrpc.AddInvoiceRequest {
1293
1362
AssetId : assetID ,
1363
+ GroupKey : cfg .groupKey ,
1294
1364
AssetAmount : assetAmount ,
1295
1365
PeerPubkey : dstRfqPeer .PubKey [:],
1296
1366
InvoiceRequest : & lnrpc.Invoice {
0 commit comments