@@ -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 = []byte {}
733
+ }
734
+
729
735
ctxb := context .Background ()
730
736
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
731
737
defer cancel ()
@@ -1013,6 +1019,12 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1013
1019
opt (cfg )
1014
1020
}
1015
1021
1022
+ // Nullify assetID if group key is set. RPC methods won't accept both so
1023
+ // let's prioritize the group key if set.
1024
+ if len (cfg .groupKey ) > 0 {
1025
+ assetID = []byte {}
1026
+ }
1027
+
1016
1028
ctxb := context .Background ()
1017
1029
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
1018
1030
defer cancel ()
@@ -1138,6 +1150,12 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1138
1150
opt (cfg )
1139
1151
}
1140
1152
1153
+ // Nullify assetID if group key is set. RPC methods won't accept both so
1154
+ // let's prioritize the group key if set.
1155
+ if len (cfg .groupKey ) > 0 {
1156
+ assetID = []byte {}
1157
+ }
1158
+
1141
1159
ctxb := context .Background ()
1142
1160
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
1143
1161
defer cancel ()
@@ -1218,12 +1236,12 @@ func assertInvoiceHtlcAssets(t *testing.T, node *HarnessNode,
1218
1236
1219
1237
var targetID string
1220
1238
switch {
1221
- case len (assetID ) > 0 :
1222
- targetID = hex .EncodeToString (assetID )
1223
-
1224
1239
case len (groupID ) > 0 :
1225
1240
groupHash := sha256 .Sum256 (groupID )
1226
1241
targetID = hex .EncodeToString (groupHash [:])
1242
+
1243
+ case len (assetID ) > 0 :
1244
+ targetID = hex .EncodeToString (assetID )
1227
1245
}
1228
1246
1229
1247
var totalAssetAmount uint64
@@ -1274,12 +1292,12 @@ func assertPaymentHtlcAssets(t *testing.T, node *HarnessNode, payHash []byte,
1274
1292
1275
1293
var targetID string
1276
1294
switch {
1277
- case len (assetID ) > 0 :
1278
- targetID = hex .EncodeToString (assetID )
1279
-
1280
1295
case len (groupID ) > 0 :
1281
1296
groupHash := sha256 .Sum256 (groupID )
1282
1297
targetID = hex .EncodeToString (groupHash [:])
1298
+
1299
+ case len (assetID ) > 0 :
1300
+ targetID = hex .EncodeToString (assetID )
1283
1301
}
1284
1302
1285
1303
var totalAssetAmount uint64
@@ -1310,7 +1328,19 @@ type assetHodlInvoice struct {
1310
1328
}
1311
1329
1312
1330
func createAssetHodlInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1313
- assetAmount uint64 , assetID []byte ) assetHodlInvoice {
1331
+ assetAmount uint64 , assetID []byte ,
1332
+ opts ... invoiceOpt ) assetHodlInvoice {
1333
+
1334
+ cfg := defaultInvoiceConfig ()
1335
+ for _ , opt := range opts {
1336
+ opt (cfg )
1337
+ }
1338
+
1339
+ // Nullify assetID if group key is set. RPC methods won't accept both so
1340
+ // let's prioritize the group key if set.
1341
+ if len (cfg .groupKey ) > 0 {
1342
+ assetID = []byte {}
1343
+ }
1314
1344
1315
1345
ctxb := context .Background ()
1316
1346
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
@@ -1334,6 +1364,7 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1334
1364
1335
1365
resp , err := dstTapd .AddInvoice (ctxt , & tchrpc.AddInvoiceRequest {
1336
1366
AssetId : assetID ,
1367
+ GroupKey : cfg .groupKey ,
1337
1368
AssetAmount : assetAmount ,
1338
1369
PeerPubkey : dstRfqPeer .PubKey [:],
1339
1370
InvoiceRequest : & lnrpc.Invoice {
@@ -1372,6 +1403,22 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1372
1403
}
1373
1404
}
1374
1405
1406
+ // addGroupModeOpt may add a group key option to the opts array, if the group
1407
+ // mode boolean is true.
1408
+ func addGroupModeOpt (opts * []payOpt , groupMode bool , groupID []byte ) {
1409
+ if groupMode {
1410
+ * opts = append (* opts , withGroupKey (groupID ))
1411
+ }
1412
+ }
1413
+
1414
+ // addGroupModeInvOpt may add a group key option to the opts array, if the group
1415
+ // mode boolean is true.
1416
+ func addGroupModeInvOpt (opts * []invoiceOpt , groupMode bool , groupID []byte ) {
1417
+ if groupMode {
1418
+ * opts = append (* opts , withInvGroupKey (groupID ))
1419
+ }
1420
+ }
1421
+
1375
1422
func waitForSendEvent (t * testing.T ,
1376
1423
sendEvents taprpc.TaprootAssets_SubscribeSendEventsClient ,
1377
1424
expectedState tapfreighter.SendState ) {
0 commit comments