Skip to content

Commit 3a281fd

Browse files
committed
tapchannel: add test case for btc invoice paid with assets
In this commit we add an extra test case that checks if the AuxInvoiceManager will reject the asset HTLCs that pay to a btc invoice. We also do some housekeeping (commonly used vars, comments) across the other test cases.
1 parent 15e2b2e commit 3a281fd

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed

tapchannel/aux_invoice_manager_test.go

+41-11
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ import (
2424
)
2525

2626
const (
27-
// The test channel ID to use across the test cases.
28-
testChanID = 1234
29-
3027
// maxRandomInvoiceValueMSat is the maximum invoice value in mSAT to be
3128
// generated by the property based tests.
3229
maxRandomInvoiceValueMSat = 100_000_000_000
@@ -52,12 +49,20 @@ var (
5249
// The node ID to be used for the RFQ peer.
5350
testNodeID = route.Vertex{1, 2, 3}
5451

52+
// The asset rate value to use across tests.
5553
assetRate = big.NewInt(100_000)
5654

55+
// The asset rate struct based on the assetRate value.
5756
testAssetRate = rfqmath.FixedPoint[rfqmath.BigInt]{
5857
Coefficient: rfqmath.NewBigInt(assetRate),
5958
Scale: 0,
6059
}
60+
61+
// The test RFQ ID to use across tests.
62+
testRfqID = dummyRfqID(31)
63+
64+
// The test RFQ SCID that is derived from testRfqID.
65+
testScid = testRfqID.Scid()
6166
)
6267

6368
// mockRfqManager mocks the interface of the rfq manager required by the aux
@@ -293,7 +298,7 @@ func TestAuxInvoiceManager(t *testing.T) {
293298
},
294299
},
295300
buyQuotes: map[rfq.SerialisedScid]rfqmsg.BuyAccept{
296-
testChanID: {
301+
testScid: {
297302
Peer: testNodeID,
298303
},
299304
},
@@ -315,7 +320,7 @@ func TestAuxInvoiceManager(t *testing.T) {
315320
},
316321
},
317322
buyQuotes: map[rfq.SerialisedScid]rfqmsg.BuyAccept{
318-
testChanID: {
323+
testScid: {
319324
Peer: testNodeID,
320325
},
321326
},
@@ -335,7 +340,7 @@ func TestAuxInvoiceManager(t *testing.T) {
335340
dummyAssetID(1),
336341
3,
337342
),
338-
}, fn.Some(dummyRfqID(31)),
343+
}, fn.Some(testRfqID),
339344
),
340345
},
341346
},
@@ -345,7 +350,7 @@ func TestAuxInvoiceManager(t *testing.T) {
345350
},
346351
},
347352
buyQuotes: rfq.BuyAcceptMap{
348-
fn.Ptr(dummyRfqID(31)).Scid(): {
353+
testScid: {
349354
Peer: testNodeID,
350355
AssetRate: rfqmsg.NewAssetRate(
351356
testAssetRate, time.Now(),
@@ -368,7 +373,7 @@ func TestAuxInvoiceManager(t *testing.T) {
368373
dummyAssetID(1),
369374
4,
370375
),
371-
}, fn.Some(dummyRfqID(31)),
376+
}, fn.Some(testRfqID),
372377
),
373378
ExitHtlcAmt: 1234,
374379
},
@@ -379,14 +384,39 @@ func TestAuxInvoiceManager(t *testing.T) {
379384
},
380385
},
381386
buyQuotes: rfq.BuyAcceptMap{
382-
fn.Ptr(dummyRfqID(31)).Scid(): {
387+
testScid: {
383388
Peer: testNodeID,
384389
AssetRate: rfqmsg.NewAssetRate(
385390
testAssetRate, time.Now(),
386391
),
387392
},
388393
},
389394
},
395+
{
396+
name: "btc invoice, custom records",
397+
requests: []lndclient.InvoiceHtlcModifyRequest{
398+
{
399+
Invoice: &lnrpc.Invoice{
400+
ValueMsat: 10_000_000,
401+
PaymentAddr: []byte{1, 1, 1},
402+
},
403+
WireCustomRecords: newWireCustomRecords(
404+
t, []*rfqmsg.AssetBalance{
405+
rfqmsg.NewAssetBalance(
406+
dummyAssetID(1),
407+
4,
408+
),
409+
}, fn.Some(testRfqID),
410+
),
411+
ExitHtlcAmt: 1234,
412+
},
413+
},
414+
responses: []lndclient.InvoiceHtlcModifyResponse{
415+
{
416+
CancelSet: true,
417+
},
418+
},
419+
},
390420
}
391421

392422
for _, testCase := range testCases {
@@ -761,8 +791,8 @@ func testRouteHints() []*lnrpc.RouteHint {
761791
NodeId: route.Vertex{1, 1, 1}.String(),
762792
},
763793
{
764-
ChanId: 1234,
765-
NodeId: route.Vertex{1, 2, 3}.String(),
794+
ChanId: uint64(testScid),
795+
NodeId: testNodeID.String(),
766796
},
767797
},
768798
},

0 commit comments

Comments
 (0)