@@ -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,16 @@ func defaultPayConfig() *payConfig {
956
964
957
965
type payOpt func (* payConfig )
958
966
967
+ func withMaybeGroupKey (groupMode bool , groupKey []byte ) payOpt {
968
+ return func (c * payConfig ) {
969
+ if ! groupMode {
970
+ return
971
+ }
972
+
973
+ c .groupKey = groupKey
974
+ }
975
+ }
976
+
959
977
func withSmallShards () payOpt {
960
978
return func (c * payConfig ) {
961
979
c .smallShards = true
@@ -1010,6 +1028,12 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1010
1028
opt (cfg )
1011
1029
}
1012
1030
1031
+ // Nullify assetID if group key is set. RPC methods won't accept both so
1032
+ // let's prioritize the group key if set.
1033
+ if len (cfg .groupKey ) > 0 {
1034
+ assetID = []byte {}
1035
+ }
1036
+
1013
1037
ctxb := context .Background ()
1014
1038
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
1015
1039
defer cancel ()
@@ -1041,6 +1065,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1041
1065
stream , err := payerTapd .SendPayment (ctxt , & tchrpc.SendPaymentRequest {
1042
1066
AssetId : assetID ,
1043
1067
PeerPubkey : rfqPeer .PubKey [:],
1068
+ GroupKey : cfg .groupKey ,
1044
1069
PaymentRequest : sendReq ,
1045
1070
RfqId : rfqBytes ,
1046
1071
AllowOverpay : cfg .allowOverpay ,
@@ -1102,6 +1127,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
1102
1127
1103
1128
type invoiceConfig struct {
1104
1129
errSubStr string
1130
+ groupKey []byte
1105
1131
}
1106
1132
1107
1133
func defaultInvoiceConfig () * invoiceConfig {
@@ -1118,6 +1144,16 @@ func withInvoiceErrSubStr(errSubStr string) invoiceOpt {
1118
1144
}
1119
1145
}
1120
1146
1147
+ func withMaybeInvGroupKey (groupMode bool , groupKey []byte ) invoiceOpt {
1148
+ return func (c * invoiceConfig ) {
1149
+ if ! groupMode {
1150
+ return
1151
+ }
1152
+
1153
+ c .groupKey = groupKey
1154
+ }
1155
+ }
1156
+
1121
1157
func createAssetInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1122
1158
assetAmount uint64 , assetID []byte ,
1123
1159
opts ... invoiceOpt ) * lnrpc.AddInvoiceResponse {
@@ -1127,6 +1163,12 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1127
1163
opt (cfg )
1128
1164
}
1129
1165
1166
+ // Nullify assetID if group key is set. RPC methods won't accept both so
1167
+ // let's prioritize the group key if set.
1168
+ if len (cfg .groupKey ) > 0 {
1169
+ assetID = []byte {}
1170
+ }
1171
+
1130
1172
ctxb := context .Background ()
1131
1173
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
1132
1174
defer cancel ()
@@ -1141,6 +1183,7 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1141
1183
1142
1184
resp , err := dstTapd .AddInvoice (ctxt , & tchrpc.AddInvoiceRequest {
1143
1185
AssetId : assetID ,
1186
+ GroupKey : cfg .groupKey ,
1144
1187
AssetAmount : assetAmount ,
1145
1188
PeerPubkey : dstRfqPeer .PubKey [:],
1146
1189
InvoiceRequest : & lnrpc.Invoice {
@@ -1185,7 +1228,7 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1185
1228
// individual HTLCs that arrived for it and that they show the correct asset
1186
1229
// amounts for the given ID when decoded.
1187
1230
func assertInvoiceHtlcAssets (t * testing.T , node * HarnessNode ,
1188
- addedInvoice * lnrpc.AddInvoiceResponse , assetID []byte ,
1231
+ addedInvoice * lnrpc.AddInvoiceResponse , assetID []byte , groupID [] byte ,
1189
1232
assetAmount uint64 ) {
1190
1233
1191
1234
ctxb := context .Background ()
@@ -1204,7 +1247,14 @@ func assertInvoiceHtlcAssets(t *testing.T, node *HarnessNode,
1204
1247
1205
1248
t .Logf ("Asset invoice: %v" , toProtoJSON (t , invoice ))
1206
1249
1207
- targetID := hex .EncodeToString (assetID )
1250
+ var targetID string
1251
+ switch {
1252
+ case len (groupID ) > 0 :
1253
+ targetID = hex .EncodeToString (groupID )
1254
+
1255
+ case len (assetID ) > 0 :
1256
+ targetID = hex .EncodeToString (assetID )
1257
+ }
1208
1258
1209
1259
var totalAssetAmount uint64
1210
1260
for _ , htlc := range invoice .Htlcs {
@@ -1231,7 +1281,7 @@ func assertInvoiceHtlcAssets(t *testing.T, node *HarnessNode,
1231
1281
// individual HTLCs that arrived for it and that they show the correct asset
1232
1282
// amounts for the given ID when decoded.
1233
1283
func assertPaymentHtlcAssets (t * testing.T , node * HarnessNode , payHash []byte ,
1234
- assetID []byte , assetAmount uint64 ) {
1284
+ assetID []byte , groupID [] byte , assetAmount uint64 ) {
1235
1285
1236
1286
ctxb := context .Background ()
1237
1287
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
@@ -1252,7 +1302,14 @@ func assertPaymentHtlcAssets(t *testing.T, node *HarnessNode, payHash []byte,
1252
1302
1253
1303
t .Logf ("Asset payment: %v" , toProtoJSON (t , payment ))
1254
1304
1255
- targetID := hex .EncodeToString (assetID )
1305
+ var targetID string
1306
+ switch {
1307
+ case len (groupID ) > 0 :
1308
+ targetID = hex .EncodeToString (groupID )
1309
+
1310
+ case len (assetID ) > 0 :
1311
+ targetID = hex .EncodeToString (assetID )
1312
+ }
1256
1313
1257
1314
var totalAssetAmount uint64
1258
1315
for _ , htlc := range payment .Htlcs {
@@ -1282,7 +1339,19 @@ type assetHodlInvoice struct {
1282
1339
}
1283
1340
1284
1341
func createAssetHodlInvoice (t * testing.T , dstRfqPeer , dst * HarnessNode ,
1285
- assetAmount uint64 , assetID []byte ) assetHodlInvoice {
1342
+ assetAmount uint64 , assetID []byte ,
1343
+ opts ... invoiceOpt ) assetHodlInvoice {
1344
+
1345
+ cfg := defaultInvoiceConfig ()
1346
+ for _ , opt := range opts {
1347
+ opt (cfg )
1348
+ }
1349
+
1350
+ // Nullify assetID if group key is set. RPC methods won't accept both so
1351
+ // let's prioritize the group key if set.
1352
+ if len (cfg .groupKey ) > 0 {
1353
+ assetID = []byte {}
1354
+ }
1286
1355
1287
1356
ctxb := context .Background ()
1288
1357
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
@@ -1306,6 +1375,7 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
1306
1375
1307
1376
resp , err := dstTapd .AddInvoice (ctxt , & tchrpc.AddInvoiceRequest {
1308
1377
AssetId : assetID ,
1378
+ GroupKey : cfg .groupKey ,
1309
1379
AssetAmount : assetAmount ,
1310
1380
PeerPubkey : dstRfqPeer .PubKey [:],
1311
1381
InvoiceRequest : & lnrpc.Invoice {
0 commit comments