@@ -90,7 +90,6 @@ async fn test_pair_priority() -> Result<(), Error> {
90
90
} ,
91
91
rel_addr : "4.3.2.1" . to_owned ( ) ,
92
92
rel_port : 43212 ,
93
- ..Default :: default ( )
94
93
} ;
95
94
96
95
let srflx_remote = srflx_config
@@ -107,7 +106,6 @@ async fn test_pair_priority() -> Result<(), Error> {
107
106
} ,
108
107
rel_addr : "4.3.2.1" . to_owned ( ) ,
109
108
rel_port : 43211 ,
110
- ..Default :: default ( )
111
109
} ;
112
110
113
111
let prflx_remote = prflx_config
@@ -161,7 +159,7 @@ async fn test_pair_priority() -> Result<(), Error> {
161
159
remote. to_string( ) ,
162
160
) ;
163
161
} else {
164
- assert ! ( false , "expected Some, but got None" ) ;
162
+ panic ! ( "expected Some, but got None" ) ;
165
163
}
166
164
}
167
165
}
@@ -310,8 +308,7 @@ async fn test_handle_peer_reflexive_udp_pflx_candidate() -> Result<(), Error> {
310
308
311
309
assert_eq ! ( c. port( ) , 999 , "Port number mismatch" ) ;
312
310
} else {
313
- assert ! (
314
- false ,
311
+ panic ! (
315
312
"expected non-empty remote candidate for network type {}" ,
316
313
local. network_type( )
317
314
) ;
@@ -914,18 +911,18 @@ async fn test_connection_state_callback() -> Result<(), Error> {
914
911
let cfg0 = AgentConfig {
915
912
urls : vec ! [ ] ,
916
913
network_types : supported_network_types ( ) ,
917
- disconnected_timeout : Some ( disconnected_duration. clone ( ) ) ,
918
- failed_timeout : Some ( failed_duration. clone ( ) ) ,
919
- keepalive_interval : Some ( keepalive_interval. clone ( ) ) ,
914
+ disconnected_timeout : Some ( disconnected_duration) ,
915
+ failed_timeout : Some ( failed_duration) ,
916
+ keepalive_interval : Some ( keepalive_interval) ,
920
917
..Default :: default ( )
921
918
} ;
922
919
923
920
let cfg1 = AgentConfig {
924
921
urls : vec ! [ ] ,
925
922
network_types : supported_network_types ( ) ,
926
- disconnected_timeout : Some ( disconnected_duration. clone ( ) ) ,
927
- failed_timeout : Some ( failed_duration. clone ( ) ) ,
928
- keepalive_interval : Some ( keepalive_interval. clone ( ) ) ,
923
+ disconnected_timeout : Some ( disconnected_duration) ,
924
+ failed_timeout : Some ( failed_duration) ,
925
+ keepalive_interval : Some ( keepalive_interval) ,
929
926
..Default :: default ( )
930
927
} ;
931
928
@@ -1068,7 +1065,6 @@ async fn test_candidate_pair_stats() -> Result<(), Error> {
1068
1065
} ,
1069
1066
rel_addr : "4.3.2.1" . to_owned ( ) ,
1070
1067
rel_port : 43212 ,
1071
- ..Default :: default ( )
1072
1068
}
1073
1069
. new_candidate_server_reflexive ( Some ( Arc :: clone ( & a. agent_internal ) ) )
1074
1070
. await ?,
@@ -1085,7 +1081,6 @@ async fn test_candidate_pair_stats() -> Result<(), Error> {
1085
1081
} ,
1086
1082
rel_addr : "4.3.2.1" . to_owned ( ) ,
1087
1083
rel_port : 43211 ,
1088
- ..Default :: default ( )
1089
1084
}
1090
1085
. new_candidate_peer_reflexive ( Some ( Arc :: clone ( & a. agent_internal ) ) )
1091
1086
. await ?,
@@ -1113,10 +1108,10 @@ async fn test_candidate_pair_stats() -> Result<(), Error> {
1113
1108
Arc :: clone ( & host_remote) ,
1114
1109
] {
1115
1110
let mut ai = a. agent_internal . lock ( ) . await ;
1116
- let p = ai. find_pair ( & host_local, & remote) . await ;
1111
+ let p = ai. find_pair ( & host_local, remote) . await ;
1117
1112
1118
1113
if p. is_none ( ) {
1119
- ai. add_pair ( Arc :: clone ( & host_local) , Arc :: clone ( & remote) )
1114
+ ai. add_pair ( Arc :: clone ( & host_local) , Arc :: clone ( remote) )
1120
1115
. await ;
1121
1116
}
1122
1117
}
@@ -1155,7 +1150,7 @@ async fn test_candidate_pair_stats() -> Result<(), Error> {
1155
1150
} else if cps. remote_candidate_id == host_remote. id ( ) {
1156
1151
host_pair_stat = cps;
1157
1152
} else {
1158
- assert ! ( false , "invalid remote candidate ID" ) ;
1153
+ panic ! ( "invalid remote candidate ID" ) ;
1159
1154
}
1160
1155
}
1161
1156
@@ -1221,7 +1216,6 @@ async fn test_local_candidate_stats() -> Result<(), Error> {
1221
1216
} ,
1222
1217
rel_addr : "4.3.2.1" . to_owned ( ) ,
1223
1218
rel_port : 43212 ,
1224
- ..Default :: default ( )
1225
1219
}
1226
1220
. new_candidate_server_reflexive ( Some ( Arc :: clone ( & a. agent_internal ) ) )
1227
1221
. await ?,
@@ -1253,8 +1247,7 @@ async fn test_local_candidate_stats() -> Result<(), Error> {
1253
1247
srflx_local_stat = stats. clone ( ) ;
1254
1248
Arc :: clone ( & srflx_local)
1255
1249
} else {
1256
- assert ! ( false , "invalid local candidate ID" ) ;
1257
- Arc :: clone ( & srflx_local)
1250
+ panic ! ( "invalid local candidate ID" ) ;
1258
1251
} ;
1259
1252
1260
1253
assert_eq ! (
@@ -1318,7 +1311,6 @@ async fn test_remote_candidate_stats() -> Result<(), Error> {
1318
1311
} ,
1319
1312
rel_addr : "4.3.2.1" . to_owned ( ) ,
1320
1313
rel_port : 43212 ,
1321
- ..Default :: default ( )
1322
1314
}
1323
1315
. new_candidate_server_reflexive ( Some ( Arc :: clone ( & a. agent_internal ) ) )
1324
1316
. await ?,
@@ -1335,7 +1327,6 @@ async fn test_remote_candidate_stats() -> Result<(), Error> {
1335
1327
} ,
1336
1328
rel_addr : "4.3.2.1" . to_owned ( ) ,
1337
1329
rel_port : 43211 ,
1338
- ..Default :: default ( )
1339
1330
}
1340
1331
. new_candidate_peer_reflexive ( Some ( Arc :: clone ( & a. agent_internal ) ) )
1341
1332
. await ?,
@@ -1397,8 +1388,7 @@ async fn test_remote_candidate_stats() -> Result<(), Error> {
1397
1388
host_remote_stat = stats. clone ( ) ;
1398
1389
Arc :: clone ( & host_remote)
1399
1390
} else {
1400
- assert ! ( false , "invalid remote candidate ID" ) ;
1401
- Arc :: clone ( & host_remote)
1391
+ panic ! ( "invalid remote candidate ID" ) ;
1402
1392
} ;
1403
1393
1404
1394
assert_eq ! (
@@ -1479,7 +1469,7 @@ async fn test_init_ext_ip_mapping() -> Result<(), Error> {
1479
1469
err
1480
1470
) ;
1481
1471
} else {
1482
- assert ! ( false , "expected error, but got ok" ) ;
1472
+ panic ! ( "expected error, but got ok" ) ;
1483
1473
}
1484
1474
1485
1475
// NewAgent should return an error when 1:1 NAT for srflx candidate is enabled
@@ -1498,7 +1488,7 @@ async fn test_init_ext_ip_mapping() -> Result<(), Error> {
1498
1488
err
1499
1489
) ;
1500
1490
} else {
1501
- assert ! ( false , "expected error, but got ok" ) ;
1491
+ panic ! ( "expected error, but got ok" ) ;
1502
1492
}
1503
1493
1504
1494
// NewAgent should return an error when 1:1 NAT for host candidate is enabled
@@ -1517,7 +1507,7 @@ async fn test_init_ext_ip_mapping() -> Result<(), Error> {
1517
1507
err
1518
1508
) ;
1519
1509
} else {
1520
- assert ! ( false , "expected error, but got ok" ) ;
1510
+ panic ! ( "expected error, but got ok" ) ;
1521
1511
}
1522
1512
1523
1513
// NewAgent should return if newExternalIPMapper() returns an error.
@@ -1534,7 +1524,7 @@ async fn test_init_ext_ip_mapping() -> Result<(), Error> {
1534
1524
err
1535
1525
) ;
1536
1526
} else {
1537
- assert ! ( false , "expected error, but got ok" ) ;
1527
+ panic ! ( "expected error, but got ok" ) ;
1538
1528
}
1539
1529
1540
1530
Ok ( ( ) )
@@ -1603,7 +1593,7 @@ async fn test_agent_credentials() -> Result<(), Error> {
1603
1593
{
1604
1594
assert_eq ! ( err, * ERR_LOCAL_UFRAG_INSUFFICIENT_BITS ) ;
1605
1595
} else {
1606
- assert ! ( false , "expected error, but got ok" ) ;
1596
+ panic ! ( "expected error, but got ok" ) ;
1607
1597
}
1608
1598
1609
1599
if let Err ( err) = Agent :: new ( AgentConfig {
@@ -1614,7 +1604,7 @@ async fn test_agent_credentials() -> Result<(), Error> {
1614
1604
{
1615
1605
assert_eq ! ( err, * ERR_LOCAL_PWD_INSUFFICIENT_BITS ) ;
1616
1606
} else {
1617
- assert ! ( false , "expected error, but got ok" ) ;
1607
+ panic ! ( "expected error, but got ok" ) ;
1618
1608
}
1619
1609
1620
1610
Ok ( ( ) )
@@ -1629,16 +1619,16 @@ async fn test_connection_state_failed_delete_all_candidates() -> Result<(), Erro
1629
1619
1630
1620
let cfg0 = AgentConfig {
1631
1621
network_types : supported_network_types ( ) ,
1632
- disconnected_timeout : Some ( one_second. clone ( ) ) ,
1633
- failed_timeout : Some ( one_second. clone ( ) ) ,
1634
- keepalive_interval : Some ( keepalive_interval. clone ( ) ) ,
1622
+ disconnected_timeout : Some ( one_second) ,
1623
+ failed_timeout : Some ( one_second) ,
1624
+ keepalive_interval : Some ( keepalive_interval) ,
1635
1625
..Default :: default ( )
1636
1626
} ;
1637
1627
let cfg1 = AgentConfig {
1638
1628
network_types : supported_network_types ( ) ,
1639
- disconnected_timeout : Some ( one_second. clone ( ) ) ,
1640
- failed_timeout : Some ( one_second. clone ( ) ) ,
1641
- keepalive_interval : Some ( keepalive_interval. clone ( ) ) ,
1629
+ disconnected_timeout : Some ( one_second) ,
1630
+ failed_timeout : Some ( one_second) ,
1631
+ keepalive_interval : Some ( keepalive_interval) ,
1642
1632
..Default :: default ( )
1643
1633
} ;
1644
1634
@@ -1681,15 +1671,15 @@ async fn test_connection_state_connecting_to_failed() -> Result<(), Error> {
1681
1671
let keepalive_interval = Duration :: from_secs ( 0 ) ;
1682
1672
1683
1673
let cfg0 = AgentConfig {
1684
- disconnected_timeout : Some ( one_second. clone ( ) ) ,
1685
- failed_timeout : Some ( one_second. clone ( ) ) ,
1686
- keepalive_interval : Some ( keepalive_interval. clone ( ) ) ,
1674
+ disconnected_timeout : Some ( one_second) ,
1675
+ failed_timeout : Some ( one_second) ,
1676
+ keepalive_interval : Some ( keepalive_interval) ,
1687
1677
..Default :: default ( )
1688
1678
} ;
1689
1679
let cfg1 = AgentConfig {
1690
- disconnected_timeout : Some ( one_second. clone ( ) ) ,
1691
- failed_timeout : Some ( one_second. clone ( ) ) ,
1692
- keepalive_interval : Some ( keepalive_interval. clone ( ) ) ,
1680
+ disconnected_timeout : Some ( one_second) ,
1681
+ failed_timeout : Some ( one_second) ,
1682
+ keepalive_interval : Some ( keepalive_interval) ,
1693
1683
..Default :: default ( )
1694
1684
} ;
1695
1685
@@ -1713,7 +1703,7 @@ async fn test_connection_state_connecting_to_failed() -> Result<(), Error> {
1713
1703
let mut c = wc_clone. lock ( ) . await ;
1714
1704
c. take ( ) ;
1715
1705
} else if c == ConnectionState :: Connected || c == ConnectionState :: Completed {
1716
- assert ! ( false , "Unexpected ConnectionState: {}" , c) ;
1706
+ panic ! ( "Unexpected ConnectionState: {}" , c) ;
1717
1707
}
1718
1708
} )
1719
1709
} ) ;
@@ -1770,7 +1760,7 @@ async fn test_agent_restart_during_gather() -> Result<(), Error> {
1770
1760
if let Err ( err) = agent. restart ( "" . to_owned ( ) , "" . to_owned ( ) ) . await {
1771
1761
assert_eq ! ( err, * ERR_RESTART_WHEN_GATHERING ) ;
1772
1762
} else {
1773
- assert ! ( false , "expected error, but got ok" ) ;
1763
+ panic ! ( "expected error, but got ok" ) ;
1774
1764
}
1775
1765
1776
1766
agent. close ( ) . await ?;
@@ -1788,7 +1778,7 @@ async fn test_agent_restart_when_closed() -> Result<(), Error> {
1788
1778
if let Err ( err) = agent. restart ( "" . to_owned ( ) , "" . to_owned ( ) ) . await {
1789
1779
assert_eq ! ( err, * ERR_CLOSED ) ;
1790
1780
} else {
1791
- assert ! ( false , "expected error, but got ok" ) ;
1781
+ panic ! ( "expected error, but got ok" ) ;
1792
1782
}
1793
1783
1794
1784
Ok ( ( ) )
@@ -1801,13 +1791,13 @@ async fn test_agent_restart_one_side() -> Result<(), Error> {
1801
1791
//"Restart One Side"
1802
1792
let ( _, _, agent_a, agent_b) = pipe (
1803
1793
Some ( AgentConfig {
1804
- disconnected_timeout : Some ( one_second. clone ( ) ) ,
1805
- failed_timeout : Some ( one_second. clone ( ) ) ,
1794
+ disconnected_timeout : Some ( one_second) ,
1795
+ failed_timeout : Some ( one_second) ,
1806
1796
..Default :: default ( )
1807
1797
} ) ,
1808
1798
Some ( AgentConfig {
1809
- disconnected_timeout : Some ( one_second. clone ( ) ) ,
1810
- failed_timeout : Some ( one_second. clone ( ) ) ,
1799
+ disconnected_timeout : Some ( one_second) ,
1800
+ failed_timeout : Some ( one_second) ,
1811
1801
..Default :: default ( )
1812
1802
} ) ,
1813
1803
)
@@ -1861,13 +1851,13 @@ async fn test_agent_restart_both_side() -> Result<(), Error> {
1861
1851
// Store the original candidates, confirm that after we reconnect we have new pairs
1862
1852
let ( _, _, agent_a, agent_b) = pipe (
1863
1853
Some ( AgentConfig {
1864
- disconnected_timeout : Some ( one_second. clone ( ) ) ,
1865
- failed_timeout : Some ( one_second. clone ( ) ) ,
1854
+ disconnected_timeout : Some ( one_second) ,
1855
+ failed_timeout : Some ( one_second) ,
1866
1856
..Default :: default ( )
1867
1857
} ) ,
1868
1858
Some ( AgentConfig {
1869
- disconnected_timeout : Some ( one_second. clone ( ) ) ,
1870
- failed_timeout : Some ( one_second. clone ( ) ) ,
1859
+ disconnected_timeout : Some ( one_second) ,
1860
+ failed_timeout : Some ( one_second) ,
1871
1861
..Default :: default ( )
1872
1862
} ) ,
1873
1863
)
0 commit comments