@@ -1110,7 +1110,7 @@ pub(crate) mod tests {
1110
1110
data_buf : & [ u8 ] ,
1111
1111
) -> TcpSegment < ' a , & ' a mut [ u8 ] > {
1112
1112
let segment = self . write_segment_helper ( buf, false , Some ( ( data_buf, data_buf. len ( ) ) ) ) ;
1113
- assert_eq ! ( segment. payload_len( ) , data_buf. len( ) ) ;
1113
+ assert_eq ! ( usize :: from ( segment. payload_len( ) ) , data_buf. len( ) ) ;
1114
1114
segment
1115
1115
}
1116
1116
@@ -1203,7 +1203,7 @@ pub(crate) mod tests {
1203
1203
options_len : usize ,
1204
1204
flags_after_ns : TcpFlags ,
1205
1205
) {
1206
- assert_eq ! ( s. len( ) , BASIC_SEGMENT_SIZE + options_len) ;
1206
+ assert_eq ! ( usize :: from ( s. len( ) ) , BASIC_SEGMENT_SIZE + options_len) ;
1207
1207
assert_eq ! ( s. flags_after_ns( ) , flags_after_ns) ;
1208
1208
}
1209
1209
@@ -1471,13 +1471,13 @@ pub(crate) mod tests {
1471
1471
assert_eq ! (
1472
1472
t. receive_segment( & mut c, & data) . unwrap( ) ,
1473
1473
(
1474
- Some ( NonZeroUsize :: new( data. payload_len( ) ) . unwrap( ) ) ,
1474
+ Some ( NonZeroUsize :: new( data. payload_len( ) . into ( ) ) . unwrap( ) ) ,
1475
1475
RecvStatusFlags :: empty( )
1476
1476
)
1477
1477
) ;
1478
1478
1479
1479
// This is the ack number that should be set/sent.
1480
- let expected_ack = t. remote_isn . wrapping_add ( data. payload_len ( ) as u32 + 1 ) ;
1480
+ let expected_ack = t. remote_isn . wrapping_add ( u32 :: from ( data. payload_len ( ) ) + 1 ) ;
1481
1481
1482
1482
// Check that internal state gets updated properly.
1483
1483
assert_eq ! ( c. ack_to_send. 0 , expected_ack) ;
@@ -1493,7 +1493,7 @@ pub(crate) mod tests {
1493
1493
assert ! ( t. write_next_segment( & mut c, None ) . unwrap( ) . is_none( ) ) ;
1494
1494
1495
1495
{
1496
- let payload_len = data. payload_len ( ) as u32 ;
1496
+ let payload_len = u32 :: from ( data. payload_len ( ) ) ;
1497
1497
1498
1498
// Assuming no one changed the code, the local window size of the connection was 10000,
1499
1499
// so we should be able to successfully receive 9 more segments with 1000 byte payloads.
@@ -1504,7 +1504,7 @@ pub(crate) mod tests {
1504
1504
assert_eq ! (
1505
1505
t. receive_segment( & mut c, & data) . unwrap( ) ,
1506
1506
(
1507
- Some ( NonZeroUsize :: new( data. payload_len( ) ) . unwrap( ) ) ,
1507
+ Some ( NonZeroUsize :: new( data. payload_len( ) . into ( ) ) . unwrap( ) ) ,
1508
1508
RecvStatusFlags :: empty( )
1509
1509
)
1510
1510
) ;
@@ -1550,7 +1550,7 @@ pub(crate) mod tests {
1550
1550
// The mss is 1100, and the remote window is 11000, so we can send 10 data packets.
1551
1551
let max = 10 ;
1552
1552
let remote_isn = t. remote_isn ;
1553
- let mss = u32 :: from ( t. mss ) ;
1553
+ let mss = t. mss ;
1554
1554
1555
1555
let ( payload_buf, mut response_seq) = payload_src. unwrap ( ) ;
1556
1556
let mut payload_offset = 0 ;
@@ -1561,22 +1561,25 @@ pub(crate) mod tests {
1561
1561
. unwrap_or_else ( |_| panic ! ( "{}" , i) )
1562
1562
. unwrap_or_else ( || panic ! ( "{}" , i) ) ;
1563
1563
1564
- payload_offset += s. payload_len ( ) ;
1565
- response_seq += Wrapping ( s. payload_len ( ) as u32 ) ;
1564
+ payload_offset += usize :: from ( s. payload_len ( ) ) ;
1565
+ response_seq += Wrapping ( u32 :: from ( s. payload_len ( ) ) ) ;
1566
1566
1567
1567
// Again, the 1 accounts for the sequence number taken up by the SYN.
1568
- assert_eq ! ( s. sequence_number( ) , conn_isn. wrapping_add( 1 + i * mss) ) ;
1568
+ assert_eq ! (
1569
+ s. sequence_number( ) ,
1570
+ conn_isn. wrapping_add( 1 + i * u32 :: from( mss) ) ,
1571
+ ) ;
1569
1572
assert_eq ! ( s. ack_number( ) , remote_isn. wrapping_add( 1 ) ) ;
1570
1573
assert_eq ! ( s. flags_after_ns( ) , TcpFlags :: ACK ) ;
1571
- assert_eq ! ( s. payload_len( ) as u32 , mss) ;
1574
+ assert_eq ! ( s. payload_len( ) , mss) ;
1572
1575
}
1573
1576
1574
1577
// No more new data can be sent until the window advances, even though data_buf
1575
1578
// contains 20_000 bytes.
1576
1579
assert ! ( t. write_next_segment( & mut c, payload_src) . unwrap( ) . is_none( ) ) ;
1577
1580
1578
1581
// Let's ACK the first segment previously sent.
1579
- ctrl. set_ack_number ( conn_isn. wrapping_add ( 1 + mss) )
1582
+ ctrl. set_ack_number ( conn_isn. wrapping_add ( 1 + u32 :: from ( mss) ) )
1580
1583
. set_flags_after_ns ( TcpFlags :: ACK ) ;
1581
1584
assert_eq ! (
1582
1585
t. receive_segment( & mut c, & ctrl) . unwrap( ) ,
@@ -1586,8 +1589,11 @@ pub(crate) mod tests {
1586
1589
// We should be able to send one more segment now.
1587
1590
{
1588
1591
let s = t. write_next_segment ( & mut c, payload_src) . unwrap ( ) . unwrap ( ) ;
1589
- assert_eq ! ( s. sequence_number( ) , conn_isn. wrapping_add( 1 + max * mss) ) ;
1590
- assert_eq ! ( s. payload_len( ) , mss as usize ) ;
1592
+ assert_eq ! (
1593
+ s. sequence_number( ) ,
1594
+ conn_isn. wrapping_add( 1 + max * u32 :: from( mss) ) ,
1595
+ ) ;
1596
+ assert_eq ! ( s. payload_len( ) , mss) ;
1591
1597
}
1592
1598
assert ! ( t. write_next_segment( & mut c, payload_src) . unwrap( ) . is_none( ) ) ;
1593
1599
@@ -1604,7 +1610,7 @@ pub(crate) mod tests {
1604
1610
{
1605
1611
let s = t. write_next_segment ( & mut c, payload_src) . unwrap ( ) . unwrap ( ) ;
1606
1612
assert_eq ! ( s. sequence_number( ) , ctrl. ack_number( ) ) ;
1607
- assert_eq ! ( s. payload_len( ) , mss as usize ) ;
1613
+ assert_eq ! ( s. payload_len( ) , mss) ;
1608
1614
}
1609
1615
assert ! ( t. write_next_segment( & mut c, payload_src) . unwrap( ) . is_none( ) ) ;
1610
1616
@@ -1613,7 +1619,7 @@ pub(crate) mod tests {
1613
1619
{
1614
1620
let s = t. write_next_segment ( & mut c, payload_src) . unwrap ( ) . unwrap ( ) ;
1615
1621
assert_eq ! ( s. sequence_number( ) , ctrl. ack_number( ) ) ;
1616
- assert_eq ! ( s. payload_len( ) , mss as usize ) ;
1622
+ assert_eq ! ( s. payload_len( ) , mss) ;
1617
1623
}
1618
1624
assert ! ( t. write_next_segment( & mut c, payload_src) . unwrap( ) . is_none( ) ) ;
1619
1625
@@ -1626,7 +1632,7 @@ pub(crate) mod tests {
1626
1632
{
1627
1633
let s = t. write_next_segment ( & mut c, payload_src) . unwrap ( ) . unwrap ( ) ;
1628
1634
assert_eq ! ( s. sequence_number( ) , ctrl. ack_number( ) ) ;
1629
- assert_eq ! ( s. payload_len( ) , mss as usize ) ;
1635
+ assert_eq ! ( s. payload_len( ) , mss) ;
1630
1636
}
1631
1637
assert ! ( t. write_next_segment( & mut c, payload_src) . unwrap( ) . is_none( ) ) ;
1632
1638
0 commit comments