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:
5 files changed
+131
-70
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user