|
63 | 63 |
|
64 | 64 | // The test RFQ SCID that is derived from testRfqID.
|
65 | 65 | testScid = testRfqID.Scid()
|
| 66 | + |
| 67 | + // The common asset ID used on test cases. |
| 68 | + assetID = dummyAssetID(1) |
| 69 | + |
| 70 | + // The asset ID of the first asset that is considered part of the group. |
| 71 | + groupAssetID_1 = dummyAssetID(41) |
| 72 | + |
| 73 | + // The asset ID of the second asset that is considered part of the |
| 74 | + // group. |
| 75 | + groupAssetID_2 = dummyAssetID(42) |
| 76 | + |
| 77 | + // The specifier based on the common asset ID. |
| 78 | + assetSpecifier = asset.NewSpecifierFromId(assetID) |
| 79 | + |
| 80 | + // The specifier based on a dummy generated group key. |
| 81 | + groupSpecifier = asset.NewSpecifierFromGroupKey(*pubKeyFromUint64(1337)) |
66 | 82 | )
|
67 | 83 |
|
68 | 84 | // mockRfqManager mocks the interface of the rfq manager required by the aux
|
@@ -95,7 +111,11 @@ func (m *mockRfqManager) AssetMatchesSpecifier(ctx context.Context,
|
95 | 111 |
|
96 | 112 | switch {
|
97 | 113 | case specifier.HasGroupPubKey():
|
98 |
| - return true, nil |
| 114 | + if id == groupAssetID_1 || id == groupAssetID_2 { |
| 115 | + return true, nil |
| 116 | + } |
| 117 | + |
| 118 | + return false, nil |
99 | 119 |
|
100 | 120 | case specifier.HasId():
|
101 | 121 | return specifier.UnwrapIdToPtr().IsEqual(id), nil
|
@@ -292,11 +312,6 @@ func (m *mockHtlcModifierProperty) HtlcModifier(ctx context.Context,
|
292 | 312 | // TestAuxInvoiceManager tests that the htlc modifications of the aux invoice
|
293 | 313 | // manager align with our expectations.
|
294 | 314 | func TestAuxInvoiceManager(t *testing.T) {
|
295 |
| - var ( |
296 |
| - assetID = dummyAssetID(1) |
297 |
| - assetSpecifier = asset.NewSpecifierFromId(assetID) |
298 |
| - ) |
299 |
| - |
300 | 315 | testCases := []struct {
|
301 | 316 | name string
|
302 | 317 | buyQuotes rfq.BuyAcceptMap
|
@@ -494,6 +509,94 @@ func TestAuxInvoiceManager(t *testing.T) {
|
494 | 509 | },
|
495 | 510 | },
|
496 | 511 | },
|
| 512 | + { |
| 513 | + name: "asset invoice, group key rfq", |
| 514 | + requests: []lndclient.InvoiceHtlcModifyRequest{ |
| 515 | + { |
| 516 | + Invoice: &lnrpc.Invoice{ |
| 517 | + RouteHints: testRouteHints(), |
| 518 | + ValueMsat: 20_000_000, |
| 519 | + PaymentAddr: []byte{1, 1, 1}, |
| 520 | + }, |
| 521 | + WireCustomRecords: newWireCustomRecords( |
| 522 | + t, []*rfqmsg.AssetBalance{ |
| 523 | + // Balance asset ID |
| 524 | + // belongs to group. |
| 525 | + rfqmsg.NewAssetBalance( |
| 526 | + groupAssetID_1, |
| 527 | + 3, |
| 528 | + ), |
| 529 | + // Balance asset ID |
| 530 | + // belongs to group. |
| 531 | + rfqmsg.NewAssetBalance( |
| 532 | + groupAssetID_2, |
| 533 | + 4, |
| 534 | + ), |
| 535 | + }, fn.Some(testRfqID), |
| 536 | + ), |
| 537 | + }, |
| 538 | + }, |
| 539 | + responses: []lndclient.InvoiceHtlcModifyResponse{ |
| 540 | + { |
| 541 | + AmtPaid: 3_000_000 + 4_000_000, |
| 542 | + }, |
| 543 | + }, |
| 544 | + buyQuotes: rfq.BuyAcceptMap{ |
| 545 | + testScid: { |
| 546 | + Peer: testNodeID, |
| 547 | + AssetRate: rfqmsg.NewAssetRate( |
| 548 | + testAssetRate, time.Now(), |
| 549 | + ), |
| 550 | + Request: rfqmsg.BuyRequest{ |
| 551 | + AssetSpecifier: groupSpecifier, |
| 552 | + }, |
| 553 | + }, |
| 554 | + }, |
| 555 | + }, |
| 556 | + { |
| 557 | + name: "asset invoice, group key rfq, bad htlc", |
| 558 | + requests: []lndclient.InvoiceHtlcModifyRequest{ |
| 559 | + { |
| 560 | + Invoice: &lnrpc.Invoice{ |
| 561 | + RouteHints: testRouteHints(), |
| 562 | + ValueMsat: 20_000_000, |
| 563 | + PaymentAddr: []byte{1, 1, 1}, |
| 564 | + }, |
| 565 | + WireCustomRecords: newWireCustomRecords( |
| 566 | + t, []*rfqmsg.AssetBalance{ |
| 567 | + // Balance asset ID does |
| 568 | + // not belong to group. |
| 569 | + rfqmsg.NewAssetBalance( |
| 570 | + dummyAssetID(2), |
| 571 | + 3, |
| 572 | + ), |
| 573 | + // Balance asset ID does |
| 574 | + // not belong to group. |
| 575 | + rfqmsg.NewAssetBalance( |
| 576 | + dummyAssetID(3), |
| 577 | + 4, |
| 578 | + ), |
| 579 | + }, fn.Some(testRfqID), |
| 580 | + ), |
| 581 | + }, |
| 582 | + }, |
| 583 | + responses: []lndclient.InvoiceHtlcModifyResponse{ |
| 584 | + { |
| 585 | + CancelSet: true, |
| 586 | + }, |
| 587 | + }, |
| 588 | + buyQuotes: rfq.BuyAcceptMap{ |
| 589 | + testScid: { |
| 590 | + Peer: testNodeID, |
| 591 | + AssetRate: rfqmsg.NewAssetRate( |
| 592 | + testAssetRate, time.Now(), |
| 593 | + ), |
| 594 | + Request: rfqmsg.BuyRequest{ |
| 595 | + AssetSpecifier: groupSpecifier, |
| 596 | + }, |
| 597 | + }, |
| 598 | + }, |
| 599 | + }, |
497 | 600 | }
|
498 | 601 |
|
499 | 602 | for _, testCase := range testCases {
|
|
0 commit comments