AwaitState waits for sc to enter stateWant or fatal errors if it doesn't happen before ctx expires.
(ctx context.Context, t *testing.T, sc StateChanger, stateWant connectivity.State)
| 56 | // AwaitState waits for sc to enter stateWant or fatal errors if it doesn't |
| 57 | // happen before ctx expires. |
| 58 | func AwaitState(ctx context.Context, t *testing.T, sc StateChanger, stateWant connectivity.State) { |
| 59 | t.Helper() |
| 60 | for state := sc.GetState(); state != stateWant; state = sc.GetState() { |
| 61 | if !sc.WaitForStateChange(ctx, state) { |
| 62 | t.Fatalf("Timed out waiting for state change. got %v; want %v", state, stateWant) |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // AwaitNotState waits for sc to leave stateDoNotWant or fatal errors if it |
| 68 | // doesn't happen before ctx expires. |