Skip to content

Commit

Permalink
tapchannel: update AuxInvoiceManager tests for new asset ID check
Browse files Browse the repository at this point in the history
For test cases where an RFQ does not exist we fail earlier, so we need
to update the expected behavior on the tests. We also need to be more
strict when creating dummy RFQs, as now the request with the asset
specifier needs to be present, for the new checks to take place.
  • Loading branch information
GeorgeTsagk committed Jan 22, 2025
1 parent 25faf9d commit 845e0f6
Showing 1 changed file with 61 additions and 9 deletions.
70 changes: 61 additions & 9 deletions tapchannel/aux_invoice_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ func (m *mockHtlcModifierProperty) HtlcModifier(ctx context.Context,
}
} else {
if !assert.ErrorContains(
m.t, err, "price from quote",
m.t, err, "extract assetID from quote",
) {

m.t.Errorf("expected quote price err")
m.t.Errorf("expected assetID error")
}
}

Expand Down Expand Up @@ -216,7 +216,15 @@ func (m *mockHtlcModifierProperty) HtlcModifier(ctx context.Context,

quote, ok := m.rfqMap[rfqID.Scid()]
if !ok {
m.t.Errorf("no rfq quote found")
if res.CancelSet {
continue
}

if !assert.ErrorContains(m.t, err, "price from quote") {
m.t.Errorf("expected quote related error")
}

continue
}

assetRate := lnwire.MilliSatoshi(
Expand Down Expand Up @@ -264,6 +272,11 @@ func (m *mockHtlcModifierProperty) HtlcModifier(ctx context.Context,
// TestAuxInvoiceManager tests that the htlc modifications of the aux invoice
// manager align with our expectations.
func TestAuxInvoiceManager(t *testing.T) {
var (
assetID = dummyAssetID(1)
assetSpecifier = asset.NewSpecifierFromId(assetID)
)

testCases := []struct {
name string
buyQuotes rfq.BuyAcceptMap
Expand Down Expand Up @@ -342,8 +355,7 @@ func TestAuxInvoiceManager(t *testing.T) {
WireCustomRecords: newWireCustomRecords(
t, []*rfqmsg.AssetBalance{
rfqmsg.NewAssetBalance(
dummyAssetID(1),
3,
assetID, 3,
),
}, fn.Some(testRfqID),
),
Expand All @@ -360,6 +372,9 @@ func TestAuxInvoiceManager(t *testing.T) {
AssetRate: rfqmsg.NewAssetRate(
testAssetRate, time.Now(),
),
Request: rfqmsg.BuyRequest{
AssetSpecifier: assetSpecifier,
},
},
},
},
Expand All @@ -375,8 +390,7 @@ func TestAuxInvoiceManager(t *testing.T) {
WireCustomRecords: newWireCustomRecords(
t, []*rfqmsg.AssetBalance{
rfqmsg.NewAssetBalance(
dummyAssetID(1),
4,
assetID, 4,
),
}, fn.Some(testRfqID),
),
Expand All @@ -394,6 +408,9 @@ func TestAuxInvoiceManager(t *testing.T) {
AssetRate: rfqmsg.NewAssetRate(
testAssetRate, time.Now(),
),
Request: rfqmsg.BuyRequest{
AssetSpecifier: assetSpecifier,
},
},
},
},
Expand All @@ -408,8 +425,7 @@ func TestAuxInvoiceManager(t *testing.T) {
WireCustomRecords: newWireCustomRecords(
t, []*rfqmsg.AssetBalance{
rfqmsg.NewAssetBalance(
dummyAssetID(1),
4,
assetID, 4,
),
}, fn.Some(testRfqID),
),
Expand All @@ -422,6 +438,42 @@ func TestAuxInvoiceManager(t *testing.T) {
},
},
},
{
name: "asset invoice, wrong asset htlc",
requests: []lndclient.InvoiceHtlcModifyRequest{
{
Invoice: &lnrpc.Invoice{
RouteHints: testRouteHints(),
ValueMsat: 3_000_000,
PaymentAddr: []byte{1, 1, 1},
},
WireCustomRecords: newWireCustomRecords(
t, []*rfqmsg.AssetBalance{
rfqmsg.NewAssetBalance(
dummyAssetID(5),
3,
),
}, fn.Some(testRfqID),
),
},
},
responses: []lndclient.InvoiceHtlcModifyResponse{
{
CancelSet: true,
},
},
buyQuotes: rfq.BuyAcceptMap{
testScid: {
Peer: testNodeID,
AssetRate: rfqmsg.NewAssetRate(
testAssetRate, time.Now(),
),
Request: rfqmsg.BuyRequest{
AssetSpecifier: assetSpecifier,
},
},
},
},
}

for _, testCase := range testCases {
Expand Down

0 comments on commit 845e0f6

Please sign in to comment.