3
3
import ipaddress
4
4
import itertools
5
5
import logging
6
+ import math
6
7
import os
7
8
import socket
8
9
import struct
@@ -1034,7 +1035,7 @@ async def asyncSetUp(self): # noqa: N802
1034
1035
INITIAL_DELAY_MAX = ticks (2 ),
1035
1036
REPETITIONS_BASE_DELAY = ticks (1 ),
1036
1037
REPETITIONS_MAX = 3 ,
1037
- FIND_TTL = 5 ,
1038
+ FIND_TTL = math . ceil ( ticks ( 25 )) ,
1038
1039
)
1039
1040
mock_sd .log = logging .getLogger ("someip.sd" )
1040
1041
self ._mock_send_sd = mock_sd .send_sd = unittest .mock .Mock ()
@@ -1057,7 +1058,7 @@ async def test_send_find(self):
1057
1058
service_id = 0x5566 ,
1058
1059
instance_id = 0xFFFF ,
1059
1060
major_version = 0xFF ,
1060
- ttl = 5 ,
1061
+ ttl = math . ceil ( ticks ( 25 )) ,
1061
1062
minver_or_counter = 0xFFFFFFFF ,
1062
1063
)
1063
1064
@@ -1081,7 +1082,7 @@ async def test_send_no_finds_after_early_offer(self):
1081
1082
service_id = 0x5566 ,
1082
1083
instance_id = 0x7788 ,
1083
1084
major_version = 1 ,
1084
- ttl = 1 ,
1085
+ ttl = math . ceil ( ticks ( 5 )) ,
1085
1086
minver_or_counter = 0xDEADBEEF ,
1086
1087
options_1 = (
1087
1088
hdr .IPv4EndpointOption (
@@ -1110,7 +1111,7 @@ async def test_send_no_finds_after_late_offer(self):
1110
1111
service_id = 0x5566 ,
1111
1112
instance_id = 0x7788 ,
1112
1113
major_version = 1 ,
1113
- ttl = 1 ,
1114
+ ttl = math . ceil ( ticks ( 5 )) ,
1114
1115
minver_or_counter = 0xDEADBEEF ,
1115
1116
options_1 = (
1116
1117
hdr .IPv4EndpointOption (
@@ -1130,7 +1131,7 @@ async def test_send_no_finds_after_late_offer(self):
1130
1131
service_id = 0x5566 ,
1131
1132
instance_id = 0xFFFF ,
1132
1133
major_version = 0xFF ,
1133
- ttl = 5 ,
1134
+ ttl = math . ceil ( ticks ( 25 )) ,
1134
1135
minver_or_counter = 0xFFFFFFFF ,
1135
1136
)
1136
1137
@@ -1157,7 +1158,7 @@ async def test_send_multiple_services_one_offer_early(self):
1157
1158
service_id = 0x4433 ,
1158
1159
instance_id = 0x7788 ,
1159
1160
major_version = 1 ,
1160
- ttl = int (ticks (10 )),
1161
+ ttl = math . ceil (ticks (10 )),
1161
1162
minver_or_counter = 0xDEADBEEF ,
1162
1163
options_1 = (
1163
1164
hdr .IPv4EndpointOption (
@@ -1177,7 +1178,7 @@ async def test_send_multiple_services_one_offer_early(self):
1177
1178
service_id = 0x5566 ,
1178
1179
instance_id = 0xFFFF ,
1179
1180
major_version = 0xFF ,
1180
- ttl = 5 ,
1181
+ ttl = math . ceil ( ticks ( 25 )) ,
1181
1182
minver_or_counter = 0xFFFFFFFF ,
1182
1183
)
1183
1184
@@ -1211,7 +1212,7 @@ async def test_find_subscribe(self):
1211
1212
service_id = 0x5566 ,
1212
1213
instance_id = 0x7788 ,
1213
1214
major_version = 1 ,
1214
- ttl = ticks (10 ),
1215
+ ttl = math . ceil ( ticks (10 ) ),
1215
1216
minver_or_counter = 0xDEADBEEF ,
1216
1217
options_1 = (
1217
1218
hdr .IPv4EndpointOption (
@@ -1233,7 +1234,7 @@ async def test_find_subscribe(self):
1233
1234
service_id = 0x5566 ,
1234
1235
instance_id = 0xFFFF ,
1235
1236
major_version = 0xFF ,
1236
- ttl = 5 ,
1237
+ ttl = math . ceil ( ticks ( 25 )) ,
1237
1238
minver_or_counter = 0xFFFFFFFF ,
1238
1239
)
1239
1240
evgrp = cfg .Eventgroup (
@@ -2075,7 +2076,7 @@ async def test_sd_multiple_listener(self):
2075
2076
2076
2077
2077
2078
class TestSDSubscriptionTTL1 (_BaseSDSubscriptionTest ):
2078
- TTL = 1
2079
+ TTL = math . floor ( ticks ( 5 ))
2079
2080
2080
2081
test_sd_reject_subscription = _BaseSDSubscriptionTest ._test_sd_reject_subscription
2081
2082
test_sd_disconnect = _BaseSDSubscriptionTest ._test_sd_disconnect
@@ -2156,7 +2157,7 @@ async def test_sd(self):
2156
2157
2157
2158
self .reset_mock ()
2158
2159
2159
- await asyncio .sleep (1.2 )
2160
+ await asyncio .sleep (ticks ( 5.1 ) )
2160
2161
2161
2162
self .assertEqual (
2162
2163
self .mock .method_calls ,
0 commit comments