routing+routerrpc: test stream cancellation

Test stream cancellation of the TrackPayments rpc call. In order to achieve
this, ControlTowerSubscriber is converted to an interface, to avoid trying to
close a null channel when closing the subscription. By returning a mock
implementation of the ControlTowerSubscriber in the test that problem is
avoided.
This commit is contained in:
Jesse de Wit
2022-09-05 13:20:38 +02:00
parent 4bc3007668
commit 0266ab77ab
5 changed files with 131 additions and 70 deletions

View File

@@ -791,7 +791,7 @@ func (s *Server) TrackPayments(request *TrackPaymentsRequest,
// trackPaymentStream streams payment updates to the client.
func (s *Server) trackPaymentStream(context context.Context,
subscription *routing.ControlTowerSubscriber, noInflightUpdates bool,
subscription routing.ControlTowerSubscriber, noInflightUpdates bool,
send func(*lnrpc.Payment) error) error {
defer subscription.Close()
@@ -799,7 +799,7 @@ func (s *Server) trackPaymentStream(context context.Context,
// Stream updates back to the client.
for {
select {
case item, ok := <-subscription.Updates:
case item, ok := <-subscription.Updates():
if !ok {
// No more payment updates.
return nil