@@ -95,7 +95,7 @@ class TestPacketHandlerRxTx(TestCase):
95
95
The RX-TX packet flow integration test class.
96
96
"""
97
97
98
- def setUp (self ):
98
+ def setUp (self ) -> None :
99
99
"""
100
100
Setup tests.
101
101
"""
@@ -107,7 +107,7 @@ def setUp(self):
107
107
# Assembled packet result is usually taken from 'self.packet_tx',
108
108
# below list is used only for tx fragmentation test where multiple
109
109
# packets are being generated by single packet assembler run.
110
- self .packets_tx = []
110
+ self .packets_tx : list [ memoryview ] = []
111
111
112
112
self .mock_ArpCache = StrictMock (template = ArpCache )
113
113
self .mock_callable (
@@ -139,7 +139,9 @@ def setUp(self):
139
139
method = "enqueue" ,
140
140
).with_implementation (
141
141
lambda _ : _ .assemble (self .packet_tx )
142
- or self .packets_tx .append (self .packet_tx )
142
+ or self .packets_tx .append (
143
+ self .packet_tx
144
+ ) # type: ignore[func-returns-value]
143
145
)
144
146
self .patch_attribute (
145
147
target = "pytcp.lib.stack" ,
@@ -151,7 +153,7 @@ def setUp(self):
151
153
# Initialize packet handler and manually set all the variables
152
154
# that normally would require network connectivity.
153
155
self .packet_handler = PacketHandler ()
154
- self .packet_handler .mac_address = STACK_MAC_ADDRESS
156
+ self .packet_handler .mac_unicast = STACK_MAC_ADDRESS
155
157
self .packet_handler .mac_multicast = [
156
158
STACK_IP6_HOST .address .solicited_node_multicast .multicast_mac
157
159
]
@@ -164,7 +166,7 @@ def setUp(self):
164
166
165
167
self .packet_tx = memoryview (bytearray (2048 ))
166
168
167
- def _patch_config (self ):
169
+ def _patch_config (self ) -> None :
168
170
"""
169
171
Patch critical config setting for all packet handler modules.
170
172
"""
@@ -182,7 +184,7 @@ def _patch_config(self):
182
184
# Test name format:
183
185
# 'test_name__protocol_tested__test_description__optional_condition'
184
186
185
- def test_packet_flow_rx_tx__icmp4__ip4_ping (self ):
187
+ def test_packet_flow_rx_tx__icmp4__ip4_ping (self ) -> None :
186
188
"""
187
189
[ICMPv4] Receive ICMPv4 echo-request packet, respond with echo-reply.
188
190
"""
@@ -217,7 +219,7 @@ def test_packet_flow_rx_tx__icmp4__ip4_ping(self):
217
219
)
218
220
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
219
221
220
- def test_packet_flow_rx_tx__udp__ip4_udp_to_closed_port (self ):
222
+ def test_packet_flow_rx_tx__udp__ip4_udp_to_closed_port (self ) -> None :
221
223
"""
222
224
[UDP] Receive IPv4/UDP packet for closed port,
223
225
respond with ICMPv4 unreachable packet.
@@ -259,7 +261,7 @@ def test_packet_flow_rx_tx__udp__ip4_udp_to_closed_port(self):
259
261
)
260
262
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
261
263
262
- def test_packet_flow_rx_tx__udp__ip4_udp_echo (self ):
264
+ def test_packet_flow_rx_tx__udp__ip4_udp_echo (self ) -> None :
263
265
"""
264
266
[UDP] Receive IPv4/UDP packet and echo it back to the sender.
265
267
"""
@@ -299,8 +301,8 @@ def test_packet_flow_rx_tx__udp__ip4_udp_echo(self):
299
301
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
300
302
301
303
def _test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag (
302
- self , order : list ( int )
303
- ):
304
+ self , order : list [ int ]
305
+ ) -> None :
304
306
"""
305
307
[IPv4 frag] Receive fragmented IPv4/UDP packets and echo them
306
308
back to the sender in specified order.
@@ -346,7 +348,9 @@ def _test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag(
346
348
)
347
349
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
348
350
349
- def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag_01234 (self ):
351
+ def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag_01234 (
352
+ self ,
353
+ ) -> None :
350
354
"""
351
355
[IPv4 frag] Receive fragmented IPv4/UDP packets and echo them
352
356
back to the sender.
@@ -355,7 +359,9 @@ def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag_01234(self):
355
359
[0 , 1 , 2 , 3 , 4 ]
356
360
)
357
361
358
- def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag_43210 (self ):
362
+ def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag_43210 (
363
+ self ,
364
+ ) -> None :
359
365
"""
360
366
[IPv4 frag] Receive fragmented IPv4/UDP packets and echo them
361
367
back to the sender.
@@ -364,7 +370,9 @@ def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag_43210(self):
364
370
[4 , 3 , 2 , 1 , 0 ]
365
371
)
366
372
367
- def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag_12043 (self ):
373
+ def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag_12043 (
374
+ self ,
375
+ ) -> None :
368
376
"""
369
377
[IPv4 frag] Receive fragmented IPv4/UDP packets and echo them
370
378
back to the sender.
@@ -376,7 +384,7 @@ def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag_12043(self):
376
384
377
385
def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag_1202103341 (
378
386
self ,
379
- ):
387
+ ) -> None :
380
388
"""
381
389
[IPv4 frag] Receive fragmented IPv4/UDP packets and echo them
382
390
back to the sender.
@@ -385,7 +393,7 @@ def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_rx_frag_1202103341(
385
393
[1 , 2 , 0 , 2 , 1 , 0 , 3 , 3 , 4 , 1 ]
386
394
)
387
395
388
- def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_tx_frag (self ):
396
+ def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_tx_frag (self ) -> None :
389
397
"""
390
398
[IPv4 frag] Receive IPv4/UDP packet and echo it back to the sender
391
399
in fragments.
@@ -432,7 +440,7 @@ def test_packet_flow_rx_tx__ip4_frag__ip4_udp_echo_tx_frag(self):
432
440
self .packets_tx [index ][: len (frags [index ])], frags [index ]
433
441
)
434
442
435
- def test_packet_flow_rx_tx__tcp__ip4_tcp_syn_to_closed_port (self ):
443
+ def test_packet_flow_rx_tx__tcp__ip4_tcp_syn_to_closed_port (self ) -> None :
436
444
"""
437
445
[TCP] Receive IPv4/TCP SYN packet to closed port, respond with
438
446
IPv4/TCP RST/ACK packet.
@@ -476,7 +484,7 @@ def test_packet_flow_rx_tx__tcp__ip4_tcp_syn_to_closed_port(self):
476
484
)
477
485
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
478
486
479
- def test_packet_flow_rx_tx__icmp6__ip6_ping (self ):
487
+ def test_packet_flow_rx_tx__icmp6__ip6_ping (self ) -> None :
480
488
"""
481
489
[ICMPv6] Receive ICMPv6 echo-request packet, respond with echo-reply.
482
490
"""
@@ -511,7 +519,7 @@ def test_packet_flow_rx_tx__icmp6__ip6_ping(self):
511
519
)
512
520
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
513
521
514
- def test_packet_flow_rx_tx__udp__ip6_udp_to_closed_port (self ):
522
+ def test_packet_flow_rx_tx__udp__ip6_udp_to_closed_port (self ) -> None :
515
523
"""
516
524
[UDP] Receive IPv6/UDP packet for closed port, respond with
517
525
ICMPv6 unreachable packet.
@@ -553,7 +561,7 @@ def test_packet_flow_rx_tx__udp__ip6_udp_to_closed_port(self):
553
561
)
554
562
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
555
563
556
- def test_packet_flow_rx_tx__udp__ip6_udp_echo (self ):
564
+ def test_packet_flow_rx_tx__udp__ip6_udp_echo (self ) -> None :
557
565
"""
558
566
[UDP] Receive IPv4/UDP packet and echo it back to the sender.
559
567
"""
@@ -593,8 +601,8 @@ def test_packet_flow_rx_tx__udp__ip6_udp_echo(self):
593
601
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
594
602
595
603
def _test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag (
596
- self , order : list ( int )
597
- ):
604
+ self , order : list [ int ]
605
+ ) -> None :
598
606
"""
599
607
[IPv6 frag] Receive fragmented IPv6/UDP packets and echo them back
600
608
to the sender in specified order.
@@ -642,7 +650,9 @@ def _test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag(
642
650
)
643
651
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
644
652
645
- def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag_01234 (self ):
653
+ def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag_01234 (
654
+ self ,
655
+ ) -> None :
646
656
"""
647
657
[IPv6 frag] Receive fragmented IPv6/UDP packets and echo them back
648
658
to the sender.
@@ -651,7 +661,9 @@ def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag_01234(self):
651
661
[0 , 1 , 2 , 3 , 4 ]
652
662
)
653
663
654
- def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag_43210 (self ):
664
+ def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag_43210 (
665
+ self ,
666
+ ) -> None :
655
667
"""
656
668
[IPv6 frag] Receive fragmented IPv6/UDP packets and echo them back
657
669
to the sender.
@@ -660,7 +672,9 @@ def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag_43210(self):
660
672
[4 , 3 , 2 , 1 , 0 ]
661
673
)
662
674
663
- def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag_12043 (self ):
675
+ def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag_12043 (
676
+ self ,
677
+ ) -> None :
664
678
"""
665
679
[IPv6 frag] Receive fragmented IPv6/UDP packets and echo them back
666
680
to the sender.
@@ -671,7 +685,7 @@ def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag_12043(self):
671
685
672
686
def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag_1202103341 (
673
687
self ,
674
- ):
688
+ ) -> None :
675
689
"""
676
690
[IPv6 frag] Receive fragmented IPv6/UDP packets and echo them back
677
691
to the sender.
@@ -680,7 +694,7 @@ def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_rx_frag_1202103341(
680
694
[1 , 2 , 0 , 2 , 1 , 0 , 3 , 3 , 4 , 1 ]
681
695
)
682
696
683
- def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_tx_frag (self ):
697
+ def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_tx_frag (self ) -> None :
684
698
"""
685
699
[IPv6 frag] Receive IPv4/UDP packet and echo it back to the sender
686
700
in fragments.
@@ -730,7 +744,7 @@ def test_packet_flow_rx_tx__ip6_frag__ip6_udp_echo_tx_frag(self):
730
744
self .packets_tx [index ][: len (frags [index ])], frags [index ]
731
745
)
732
746
733
- def test_packet_flow_rx_tx__tcp__ip6_tcp_syn_to_closed_port (self ):
747
+ def test_packet_flow_rx_tx__tcp__ip6_tcp_syn_to_closed_port (self ) -> None :
734
748
"""
735
749
[TCP] Receive IPv6/TCP SYN packet to closed port, respond with
736
750
IPv6/TCP RST/ACK packet.
@@ -774,7 +788,7 @@ def test_packet_flow_rx_tx__tcp__ip6_tcp_syn_to_closed_port(self):
774
788
)
775
789
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
776
790
777
- def test_packet_flow_rx_tx__arp__arp_request (self ):
791
+ def test_packet_flow_rx_tx__arp__arp_request (self ) -> None :
778
792
"""
779
793
[ARP] Receive ARP Request packet for stack IPv4 address,
780
794
respond with ARP Reply.
@@ -814,7 +828,7 @@ def test_packet_flow_rx_tx__arp__arp_request(self):
814
828
)
815
829
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
816
830
817
- def test_packet_flow_rx_tx__icmp6_nd__nd_ns__unicast_dst (self ):
831
+ def test_packet_flow_rx_tx__icmp6_nd__nd_ns__unicast_dst (self ) -> None :
818
832
"""
819
833
[ICMPv6 ND] Receive ICMPv6 Neighbor Solicitation packet for stack
820
834
IPv6 address, respond with Neighbor Advertisement.
@@ -858,7 +872,7 @@ def test_packet_flow_rx_tx__icmp6_nd__nd_ns__unicast_dst(self):
858
872
)
859
873
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
860
874
861
- def test_packet_flow_rx_tx__icmp6_nd__nd_ns__no_slla (self ):
875
+ def test_packet_flow_rx_tx__icmp6_nd__nd_ns__no_slla (self ) -> None :
862
876
"""
863
877
[ICMPv6 ND] Receive ICMPv6 Neighbor Solicitation packet,
864
878
respond with Neighbor Advertisement.
@@ -901,7 +915,7 @@ def test_packet_flow_rx_tx__icmp6_nd__nd_ns__no_slla(self):
901
915
)
902
916
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
903
917
904
- def test_packet_flow_rx_tx__icmp6_nd__nd_ns (self ):
918
+ def test_packet_flow_rx_tx__icmp6_nd__nd_ns (self ) -> None :
905
919
"""
906
920
[ICMPv6 ND] Receive ICMPv6 Neighbor Solicitation packet,
907
921
respond with Neighbor Advertisement.
@@ -943,7 +957,7 @@ def test_packet_flow_rx_tx__icmp6_nd__nd_ns(self):
943
957
)
944
958
self .assertEqual (self .packet_tx [: len (packet_tx )], packet_tx )
945
959
946
- def test_packet_flow_rx_tx__icmp6_nd__nd_ns__dad (self ):
960
+ def test_packet_flow_rx_tx__icmp6_nd__nd_ns__dad (self ) -> None :
947
961
"""
948
962
[ICMPv6 ND] Receive ICMPv6 Neighbor Solicitation DAD packet,
949
963
respond with Neighbor Advertisement
0 commit comments