| // Copyright 2015 The Vanadium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // WaitForNotifications waits till all notifications in 'wants' have been received. |
| func WaitForNotifications(notify <-chan interface{}, wants ...interface{}) error { |
| expected := make(map[interface{}]struct{}) |
| for _, w := range wants { |
| if _, exists := expected[n]; !exists { |
| return fmt.Errorf("unexpected notification %v", n) |
| // WaitWithTimeout returns error if any notification has been received before |
| func WaitWithTimeout(notify <-chan interface{}, timeout time.Duration) error { |
| timer := time.After(timeout) |
| return fmt.Errorf("unexpected notification %v", n) |