From 5836d58a99ed2dcd46fbe226a3bc1b4e2fe36a46 Mon Sep 17 00:00:00 2001 From: carla Date: Mon, 7 Feb 2022 09:03:10 +0200 Subject: [PATCH] lnrpc: add unit test covering too many hop hints --- lnrpc/invoicesrpc/addinvoice_test.go | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lnrpc/invoicesrpc/addinvoice_test.go b/lnrpc/invoicesrpc/addinvoice_test.go index fd2aa60b7..64d93d9f6 100644 --- a/lnrpc/invoicesrpc/addinvoice_test.go +++ b/lnrpc/invoicesrpc/addinvoice_test.go @@ -307,6 +307,36 @@ func TestSelectHopHints(t *testing.T) { numHints: 1, expectedHints: nil, }, + { + // This test case reproduces a bug where we have too + // many hop hints for our maximum hint number. + name: "too many hints", + setupMock: func(h *hopHintsConfigMock) { + setMockChannelUsed( + h, private1ShortID, privateChan1Policy, + ) + + setMockChannelUsed( + h, private2ShortID, privateChan2Policy, + ) + + }, + // Set our amount to less than our channel balance of + // 100. + amount: 30, + channels: []*HopHintInfo{ + privateChannel1, privateChannel2, + }, + numHints: 1, + expectedHints: [][]zpay32.HopHint{ + { + privateChannel1Hint, + }, + { + privateChannel2Hint, + }, + }, + }, { // If a channel has more balance than the amount we're // looking for, it'll be added in our first pass. We