@@ -470,7 +470,7 @@ func TestInvalidAgentStarts(t *testing.T) {
470470	}()
471471
472472	ctx  :=  context .Background ()
473- 	ctx , cancel  :=  context .WithTimeout (ctx , 100 * time .Millisecond )
473+ 	ctx , cancel  :=  context .WithTimeout (ctx , 2 * time .Second )
474474	defer  cancel ()
475475
476476	_ , err  =  agent .Dial (ctx , "" , "bar" )
@@ -580,7 +580,7 @@ func TestCandidatePairsStats(t *testing.T) { //nolint:cyclop,gocyclo
580580	defer  test .CheckRoutines (t )()
581581
582582	// Avoid deadlocks? 
583- 	defer  test .TimeOut (1  *  time .Second ).Stop ()
583+ 	defer  test .TimeOut (2  *  time .Second ).Stop ()
584584
585585	agent , err  :=  NewAgent (& AgentConfig {})
586586	require .NoError (t , err )
@@ -711,7 +711,7 @@ func TestSelectedCandidatePairStats(t *testing.T) { //nolint:cyclop
711711	defer  test .CheckRoutines (t )()
712712
713713	// Avoid deadlocks? 
714- 	defer  test .TimeOut (1  *  time .Second ).Stop ()
714+ 	defer  test .TimeOut (2  *  time .Second ).Stop ()
715715
716716	agent , err  :=  NewAgent (& AgentConfig {})
717717	require .NoError (t , err )
@@ -780,7 +780,7 @@ func TestLocalCandidateStats(t *testing.T) { //nolint:cyclop
780780	defer  test .CheckRoutines (t )()
781781
782782	// Avoid deadlocks? 
783- 	defer  test .TimeOut (1  *  time .Second ).Stop ()
783+ 	defer  test .TimeOut (2  *  time .Second ).Stop ()
784784
785785	agent , err  :=  NewAgent (& AgentConfig {})
786786	require .NoError (t , err )
@@ -840,7 +840,7 @@ func TestRemoteCandidateStats(t *testing.T) { //nolint:cyclop
840840	defer  test .CheckRoutines (t )()
841841
842842	// Avoid deadlocks? 
843- 	defer  test .TimeOut (1  *  time .Second ).Stop ()
843+ 	defer  test .TimeOut (2  *  time .Second ).Stop ()
844844
845845	agent , err  :=  NewAgent (& AgentConfig {})
846846	require .NoError (t , err )
@@ -1817,13 +1817,19 @@ func TestAcceptAggressiveNomination(t *testing.T) { //nolint:cyclop
18171817				}
18181818			}
18191819
1820- 			time .Sleep (1  *  time .Second )
18211820			select  {
18221821			case  selected  :=  <- selectedCh :
1823- 				require .True (t , selected .Equal (expectNewSelectedCandidate ))
1824- 			default :
1825- 				require .False (t , tc .isExpectedToSwitch )
1826- 				require .True (t , aAgent .getSelectedPair ().Remote .Equal (expectNewSelectedCandidate ))
1822+ 				if  tc .isExpectedToSwitch  {
1823+ 					require .True (t , selected .Equal (expectNewSelectedCandidate ))
1824+ 				} else  {
1825+ 					require .Fail (t , "unexpected candidate pair change: %v" , selected )
1826+ 				}
1827+ 			case  <- time .After (1200  *  time .Millisecond ):
1828+ 				if  tc .isExpectedToSwitch  {
1829+ 					require .Fail (t , "timeout waiting for candidate pair change" )
1830+ 				} else  {
1831+ 					require .True (t , aAgent .getSelectedPair ().Remote .Equal (expectNewSelectedCandidate ))
1832+ 				}
18271833			}
18281834		})
18291835	}
@@ -1933,7 +1939,7 @@ func TestAlwaysSentKeepAlive(t *testing.T) { //nolint:cyclop
19331939	defer  test .CheckRoutines (t )()
19341940
19351941	// Avoid deadlocks? 
1936- 	defer  test .TimeOut (1  *  time .Second ).Stop ()
1942+ 	defer  test .TimeOut (2  *  time .Second ).Stop ()
19371943
19381944	agent , err  :=  NewAgent (& AgentConfig {})
19391945	require .NoError (t , err )
0 commit comments