@@ -741,6 +741,12 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
741
741
opt (cfg )
742
742
}
743
743
744
+ // Nullify assetID if group key is set. RPC methods won't accept both so
745
+ // let's prioritize the group key if set.
746
+ if len (cfg .groupKey ) > 0 {
747
+ assetID = nil
748
+ }
749
+
744
750
ctxb := context .Background ()
745
751
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
746
752
defer cancel ()
@@ -770,6 +776,7 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
770
776
stream , err := srcTapd .SendPayment (ctxt , & tchrpc.SendPaymentRequest {
771
777
AssetId : assetID ,
772
778
AssetAmount : amt ,
779
+ GroupKey : cfg .groupKey ,
773
780
PaymentRequest : sendReq ,
774
781
})
775
782
require .NoError (t , err )
@@ -942,6 +949,7 @@ type payConfig struct {
942
949
payStatus lnrpc.Payment_PaymentStatus
943
950
failureReason lnrpc.PaymentFailureReason
944
951
rfq fn.Option [rfqmsg.ID ]
952
+ groupKey []byte
945
953
}
946
954
947
955
func defaultPayConfig () * payConfig {
@@ -956,6 +964,12 @@ func defaultPayConfig() *payConfig {
956
964
957
965
type payOpt func (* payConfig )
958
966
967
+ func withGroupKey (groupKey []byte ) payOpt {
968
+ return func (c * payConfig ) {
969
+ c .groupKey = groupKey
970
+ }
971
+ }
972
+
959
973
func withSmallShards () payOpt {
960
974
return func (c * payConfig ) {
961
975
c .smallShards = true
@@ -1010,6 +1024,12 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1010
1024
opt (cfg )
1011
1025
}
1012
1026
1027
+ // Nullify assetID if group key is set. RPC methods won't accept both so
1028
+ // let's prioritize the group key if set.
1029
+ if len (cfg .groupKey ) > 0 {
1030
+ assetID = []byte {}
1031
+ }
1032
+
1013
1033
ctxb := context .Background ()
1014
1034
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
1015
1035
defer cancel ()
@@ -1041,6 +1061,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1041
1061
stream , err := payerTapd .SendPayment (ctxt , & tchrpc.SendPaymentRequest {
1042
1062
AssetId : assetID ,
1043
1063
PeerPubkey : rfqPeer .PubKey [:],
1064
+ GroupKey : cfg .groupKey ,
1044
1065
PaymentRequest : sendReq ,
1045
1066
RfqId : rfqBytes ,
1046
1067
AllowOverpay : cfg .allowOverpay ,
@@ -1102,6 +1123,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1102
1123
1103
1124
type invoiceConfig struct {
1104
1125
errSubStr string
1126
+ groupKey []byte
1105
1127
}
1106
1128
1107
1129
func defaultInvoiceConfig () * invoiceConfig {
@@ -1118,6 +1140,12 @@ func withInvoiceErrSubStr(errSubStr string) invoiceOpt {
1118
1140
}
1119
1141
}
1120
1142
1143
+ func withInvGroupKey (groupKey []byte ) invoiceOpt {
1144
+ return func (c * invoiceConfig ) {
1145
+ c .groupKey = groupKey
1146
+ }
1147
+ }
1148
+
1121
1149
func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1122
1150
assetAmount uint64 , assetID []byte ,
1123
1151
opts ... invoiceOpt ) * lnrpc.AddInvoiceResponse {
@@ -1127,6 +1155,12 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1127
1155
opt (cfg )
1128
1156
}
1129
1157
1158
+ // Nullify assetID if group key is set. RPC methods won't accept both so
1159
+ // let's prioritize the group key if set.
1160
+ if len (cfg .groupKey ) > 0 {
1161
+ assetID = []byte {}
1162
+ }
1163
+
1130
1164
ctxb := context .Background ()
1131
1165
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
1132
1166
defer cancel ()
@@ -1141,6 +1175,7 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1141
1175
1142
1176
resp , err := dstTapd .AddInvoice (ctxt , & tchrpc.AddInvoiceRequest {
1143
1177
AssetId : assetID ,
1178
+ GroupKey : cfg .groupKey ,
1144
1179
AssetAmount : assetAmount ,
1145
1180
PeerPubkey : dstRfqPeer .PubKey [:],
1146
1181
InvoiceRequest : & lnrpc.Invoice {
@@ -1185,7 +1220,7 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1185
1220
// individual HTLCs that arrived for it and that they show the correct asset
1186
1221
// amounts for the given ID when decoded.
1187
1222
func assertInvoiceHtlcAssets (t * testing.T , node * HarnessNode ,
1188
- addedInvoice * lnrpc.AddInvoiceResponse , assetID []byte ,
1223
+ addedInvoice * lnrpc.AddInvoiceResponse , assetID []byte , groupID [] byte ,
1189
1224
assetAmount uint64 ) {
1190
1225
1191
1226
ctxb := context .Background ()
@@ -1204,7 +1239,14 @@ func assertInvoiceHtlcAssets(t *testing.T, node *HarnessNode,
1204
1239
1205
1240
t .Logf ("Asset invoice: %v" , toProtoJSON (t , invoice ))
1206
1241
1207
- targetID := hex .EncodeToString (assetID )
1242
+ var targetID string
1243
+ switch {
1244
+ case len (groupID ) > 0 :
1245
+ targetID = hex .EncodeToString (groupID )
1246
+
1247
+ case len (assetID ) > 0 :
1248
+ targetID = hex .EncodeToString (assetID )
1249
+ }
1208
1250
1209
1251
var totalAssetAmount uint64
1210
1252
for _ , htlc := range invoice .Htlcs {
@@ -1231,7 +1273,7 @@ func assertInvoiceHtlcAssets(t *testing.T, node *HarnessNode,
1231
1273
// individual HTLCs that arrived for it and that they show the correct asset
1232
1274
// amounts for the given ID when decoded.
1233
1275
func assertPaymentHtlcAssets (t * testing.T , node * HarnessNode , payHash []byte ,
1234
- assetID []byte , assetAmount uint64 ) {
1276
+ assetID []byte , groupID [] byte , assetAmount uint64 ) {
1235
1277
1236
1278
ctxb := context .Background ()
1237
1279
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
@@ -1252,7 +1294,14 @@ func assertPaymentHtlcAssets(t *testing.T, node *HarnessNode, payHash []byte,
1252
1294
1253
1295
t .Logf ("Asset payment: %v" , toProtoJSON (t , payment ))
1254
1296
1255
- targetID := hex .EncodeToString (assetID )
1297
+ var targetID string
1298
+ switch {
1299
+ case len (groupID ) > 0 :
1300
+ targetID = hex .EncodeToString (groupID )
1301
+
1302
+ case len (assetID ) > 0 :
1303
+ targetID = hex .EncodeToString (assetID )
1304
+ }
1256
1305
1257
1306
var totalAssetAmount uint64
1258
1307
for _ , htlc := range payment .Htlcs {
@@ -1282,7 +1331,19 @@ type assetHodlInvoice struct {
1282
1331
}
1283
1332
1284
1333
func createAssetHodlInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1285
- assetAmount uint64 , assetID []byte ) assetHodlInvoice {
1334
+ assetAmount uint64 , assetID []byte ,
1335
+ opts ... invoiceOpt ) assetHodlInvoice {
1336
+
1337
+ cfg := defaultInvoiceConfig ()
1338
+ for _ , opt := range opts {
1339
+ opt (cfg )
1340
+ }
1341
+
1342
+ // Nullify assetID if group key is set. RPC methods won't accept both so
1343
+ // let's prioritize the group key if set.
1344
+ if len (cfg .groupKey ) > 0 {
1345
+ assetID = []byte {}
1346
+ }
1286
1347
1287
1348
ctxb := context .Background ()
1288
1349
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
@@ -1306,6 +1367,7 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1306
1367
1307
1368
resp , err := dstTapd .AddInvoice (ctxt , & tchrpc.AddInvoiceRequest {
1308
1369
AssetId : assetID ,
1370
+ GroupKey : cfg .groupKey ,
1309
1371
AssetAmount : assetAmount ,
1310
1372
PeerPubkey : dstRfqPeer .PubKey [:],
1311
1373
InvoiceRequest : & lnrpc.Invoice {
0 commit comments