|
|
|
|
@ -238,6 +238,156 @@ NETWORK_DIRECT_DIAL_SLOT: {value}
|
|
|
|
|
scenario.config["SYSTEMS"]["MASTER-A"],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_dial_reconnect_restores_declared_defaults_once(self):
|
|
|
|
|
name = "MASTER-A"
|
|
|
|
|
options = b"DIAL1=2348;DIAL2=2350;TS2=3340;TIMER=1"
|
|
|
|
|
for poll_before_login in (False, True):
|
|
|
|
|
with self.subTest(poll_before_login=poll_before_login), DeterministicScenario() as scenario:
|
|
|
|
|
bm = scenario.bm
|
|
|
|
|
config = scenario.config["SYSTEMS"][name]
|
|
|
|
|
config["_default_options"] = "SINGLE=1;TIMER=1"
|
|
|
|
|
peer = scenario.register_peer(name)
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + peer + options)
|
|
|
|
|
bm.options_config()
|
|
|
|
|
scenario.inject_datagram(name, b"RPTCL" + peer)
|
|
|
|
|
bm.bridge_reset()
|
|
|
|
|
if poll_before_login:
|
|
|
|
|
bm.options_config()
|
|
|
|
|
self.assertIsNone(bm.active_reflector_for_system_slot(name, 1))
|
|
|
|
|
self.assertIsNone(bm.active_reflector_for_system_slot(name, 2))
|
|
|
|
|
|
|
|
|
|
scenario.register_peer(name)
|
|
|
|
|
if poll_before_login:
|
|
|
|
|
bm.options_config() # Connected but has not sent OPTIONS.
|
|
|
|
|
self.assertIsNone(bm.active_reflector_for_system_slot(name, 2))
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + peer + options)
|
|
|
|
|
bm.options_config()
|
|
|
|
|
scenario.clock.advance(61)
|
|
|
|
|
bm.rule_timer_loop()
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, 1), "#2348")
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, 2), "#2350")
|
|
|
|
|
static = next(e for e in scenario.bridge_state["3340"]
|
|
|
|
|
if e["SYSTEM"] == name and e["TS"] == 2)
|
|
|
|
|
self.assertEqual((static["ACTIVE"], static["TO_TYPE"]), (True, "OFF"))
|
|
|
|
|
|
|
|
|
|
bm.control_dial(name, 2, "link", 91)
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + peer + options)
|
|
|
|
|
bm.options_config()
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, 2), "#91")
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + peer + options.replace(b"2350", b"2351"))
|
|
|
|
|
bm.options_config()
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, 2), "#2351")
|
|
|
|
|
|
|
|
|
|
def test_reconnect_does_not_restore_an_omitted_or_invalid_dial_default(self):
|
|
|
|
|
name = "MASTER-A"
|
|
|
|
|
with DeterministicScenario() as scenario:
|
|
|
|
|
bm = scenario.bm
|
|
|
|
|
peer = scenario.register_peer(name)
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + peer + b"DIAL1=2348;DIAL2=2350")
|
|
|
|
|
bm.options_config()
|
|
|
|
|
scenario.inject_datagram(name, b"RPTCL" + peer)
|
|
|
|
|
bm.bridge_reset()
|
|
|
|
|
peer = scenario.register_peer(name, 1002)
|
|
|
|
|
for value in (b"TS2=3340", b"DIAL1=bad;TS2=3340"):
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + peer + value)
|
|
|
|
|
bm.options_config()
|
|
|
|
|
self.assertIsNone(bm.active_reflector_for_system_slot(name, 1))
|
|
|
|
|
self.assertIsNone(bm.active_reflector_for_system_slot(name, 2))
|
|
|
|
|
bm.control_dial(name, 1, "link", 91)
|
|
|
|
|
scenario.clock.advance(61)
|
|
|
|
|
bm.rule_timer_loop()
|
|
|
|
|
self.assertIsNone(bm.active_reflector_for_system_slot(name, 1))
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + peer + b"DIAL=2350")
|
|
|
|
|
bm.options_config()
|
|
|
|
|
self.assertIsNone(bm.active_reflector_for_system_slot(name, 1))
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, 2), "#2350")
|
|
|
|
|
|
|
|
|
|
def test_reconnect_uses_only_explicit_server_homes_when_new_peer_has_no_options(self):
|
|
|
|
|
name = "MASTER-A"
|
|
|
|
|
for new_options, expected in ((None, "#2350"), (b"DIAL2=0", None), (b"DIAL2=91", "#91")):
|
|
|
|
|
with self.subTest(new_options=new_options):
|
|
|
|
|
config = minimal_config((name,))
|
|
|
|
|
config["SYSTEMS"][name]["DEFAULT_DIAL_TS2"] = 2350
|
|
|
|
|
with DeterministicScenario(config=config) as scenario:
|
|
|
|
|
bm = scenario.bm
|
|
|
|
|
bm.make_default_reflectors() # Load the sysop's file settings once at startup.
|
|
|
|
|
old = scenario.register_peer(name)
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + old + b"DIAL1=2348;DIAL2=3340")
|
|
|
|
|
bm.options_config()
|
|
|
|
|
scenario.inject_datagram(name, b"RPTCL" + old)
|
|
|
|
|
bm.bridge_reset()
|
|
|
|
|
bm.options_config()
|
|
|
|
|
self.assertIsNone(bm.active_reflector_for_system_slot(name, 2))
|
|
|
|
|
new = scenario.register_peer(name, 1002)
|
|
|
|
|
if new_options is not None:
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + new + new_options)
|
|
|
|
|
bm.options_config()
|
|
|
|
|
self.assertEqual(bm.control_dial(name, 1, "status")["default_tg"], 0)
|
|
|
|
|
self.assertIsNone(bm.active_reflector_for_system_slot(name, 1))
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, 2), expected)
|
|
|
|
|
|
|
|
|
|
def test_early_dial_before_server_home_restore_keeps_user_selection_until_expiry(self):
|
|
|
|
|
name = "MASTER-A"
|
|
|
|
|
config = minimal_config((name,))
|
|
|
|
|
config["SYSTEMS"][name]["DEFAULT_DIAL_TS1"] = 2348
|
|
|
|
|
with DeterministicScenario(config=config) as scenario:
|
|
|
|
|
bm = scenario.bm
|
|
|
|
|
bm.make_default_reflectors()
|
|
|
|
|
old = scenario.register_peer(name)
|
|
|
|
|
scenario.inject_datagram(name, b"RPTCL" + old)
|
|
|
|
|
bm.bridge_reset()
|
|
|
|
|
scenario.register_peer(name, 1002)
|
|
|
|
|
bm.control_dial(name, 1, "link", 91)
|
|
|
|
|
bm.options_config()
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, 1), "#91")
|
|
|
|
|
scenario.clock.advance(61)
|
|
|
|
|
bm.rule_timer_loop()
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, 1), "#2348")
|
|
|
|
|
|
|
|
|
|
def test_server_home_honours_current_peers_dial_enable_setting_not_previous_peers(self):
|
|
|
|
|
name = "MASTER-A"
|
|
|
|
|
config = minimal_config((name,))
|
|
|
|
|
config["SYSTEMS"][name]["DEFAULT_DIAL_TS2"] = 2350
|
|
|
|
|
with DeterministicScenario(config=config) as scenario:
|
|
|
|
|
bm = scenario.bm
|
|
|
|
|
bm.make_default_reflectors()
|
|
|
|
|
peer = scenario.register_peer(name)
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + peer + b"DIALTG=0")
|
|
|
|
|
bm.options_config()
|
|
|
|
|
self.assertIsNone(bm.active_reflector_for_system_slot(name, 2))
|
|
|
|
|
scenario.inject_datagram(name, b"RPTCL" + peer)
|
|
|
|
|
bm.bridge_reset()
|
|
|
|
|
peer = scenario.register_peer(name, 1002)
|
|
|
|
|
bm.options_config()
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, 2), "#2350")
|
|
|
|
|
for options, expected in ((b"DIALTG=0", None), (b"DIALTG=0;DIAL2=2351", None),
|
|
|
|
|
(b"DIALTG=1;DIAL2=2351", "#2351")):
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + peer + options)
|
|
|
|
|
bm.options_config()
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, 2), expected)
|
|
|
|
|
|
|
|
|
|
def test_two_quick_disconnects_do_not_block_rf_on_a_no_options_peer(self):
|
|
|
|
|
name = "MASTER-A"
|
|
|
|
|
with DeterministicScenario() as scenario:
|
|
|
|
|
bm = scenario.bm
|
|
|
|
|
peer = scenario.register_peer(name)
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + peer + b"DIAL2=2350")
|
|
|
|
|
bm.options_config()
|
|
|
|
|
scenario.inject_datagram(name, b"RPTCL" + peer)
|
|
|
|
|
scenario.register_peer(name)
|
|
|
|
|
scenario.inject_datagram(name, b"RPTO" + peer + b"DIAL2=2350")
|
|
|
|
|
bm.bridge_reset()
|
|
|
|
|
self.assertTrue(scenario.config["SYSTEMS"][name]["_reloadoptions"])
|
|
|
|
|
# This session goes away before the pending options poll.
|
|
|
|
|
scenario.inject_datagram(name, b"RPTCL" + peer)
|
|
|
|
|
bm.bridge_reset()
|
|
|
|
|
scenario.register_peer(name, 1002)
|
|
|
|
|
bm.options_config()
|
|
|
|
|
scenario.clock.advance(6)
|
|
|
|
|
scenario.inject_hbp(name, PacketSpec(peer_id=1002, dst_id=3340, slot=1))
|
|
|
|
|
self.assertIn("3340", scenario.bridge_state)
|
|
|
|
|
self.assertIsNone(bm.active_reflector_for_system_slot(name, 2))
|
|
|
|
|
|
|
|
|
|
def private_call(self, dst_id, slot=1, stream_id=0x01020304):
|
|
|
|
|
return PacketSpec(
|
|
|
|
|
dst_id=dst_id,
|
|
|
|
|
@ -436,6 +586,29 @@ NETWORK_DIRECT_DIAL_SLOT: {value}
|
|
|
|
|
self.assertTrue(ts1_entry["ACTIVE"])
|
|
|
|
|
self.assertTrue(ts2_entry["ACTIVE"])
|
|
|
|
|
|
|
|
|
|
def test_static_option_promotes_route_created_by_rf_or_mesh_before_options_poll(self):
|
|
|
|
|
for first_from in ("rf", "mesh"):
|
|
|
|
|
config = minimal_config(("MASTER-A",))
|
|
|
|
|
add_openbridge_system(config, "OBP-1", network_id=3001)
|
|
|
|
|
config["GLOBAL"]["GEN_STAT_BRIDGES"] = True
|
|
|
|
|
with self.subTest(first_from=first_from), DeterministicScenario(config=config) as scenario:
|
|
|
|
|
peer = scenario.register_peer("MASTER-A")
|
|
|
|
|
scenario.inject_datagram("MASTER-A", b"RPTO" + peer + b"TS2=3340;TIMER=1")
|
|
|
|
|
scenario.clock.advance(6)
|
|
|
|
|
if first_from == "rf":
|
|
|
|
|
scenario.inject_hbp("MASTER-A", PacketSpec(dst_id=3340, slot=2))
|
|
|
|
|
else:
|
|
|
|
|
scenario.inject_obp("OBP-1", PacketSpec(dst_id=3340, slot=1))
|
|
|
|
|
self.assertIn("3340", scenario.bridge_state)
|
|
|
|
|
scenario.bm.options_config()
|
|
|
|
|
scenario.clock.advance(61)
|
|
|
|
|
scenario.bm.rule_timer_loop()
|
|
|
|
|
scenario.bm.statTrimmer()
|
|
|
|
|
scenario.inject_obp("OBP-1", PacketSpec(dst_id=3340, slot=1, stream_id=456))
|
|
|
|
|
sent = scenario.capture.for_system("MASTER-A")[-1].fields
|
|
|
|
|
self.assertEqual((sent["dst_id"], sent["slot"], sent["stream_id"]),
|
|
|
|
|
(bytes_3(3340), 2, bytes_4(456)))
|
|
|
|
|
|
|
|
|
|
def test_options_static_tg_whitespace_is_normalized(self):
|
|
|
|
|
config = minimal_config(("MASTER-A", "MASTER-B"))
|
|
|
|
|
config["SYSTEMS"]["MASTER-A"]["OPTIONS"] = "TS1=91, 92;TS2=93, 94;DIAL=0;TIMER=1"
|
|
|
|
|
@ -1503,6 +1676,47 @@ NETWORK_DIRECT_DIAL_SLOT: {value}
|
|
|
|
|
self.assertFalse(default_entry["ACTIVE"])
|
|
|
|
|
self.assertTrue(direct_entry["ACTIVE"])
|
|
|
|
|
|
|
|
|
|
def test_network_direct_dial_returns_to_default_after_new_and_reused_routes(self):
|
|
|
|
|
name = "MASTER-A"
|
|
|
|
|
for slot in (1, 2):
|
|
|
|
|
with self.subTest(slot=slot):
|
|
|
|
|
config = minimal_config((name,))
|
|
|
|
|
config["SYSTEMS"][name]["OPTIONS"] = f"DIAL1=2348;DIAL2=2350;NDD_SLOT={slot};TIMER=1"
|
|
|
|
|
add_openbridge_system(config, "OBP-1", network_id=3001)
|
|
|
|
|
with DeterministicScenario(config=config) as scenario:
|
|
|
|
|
bm = scenario.bm
|
|
|
|
|
scenario.register_peer(name, 235193)
|
|
|
|
|
if slot == 2:
|
|
|
|
|
# The old direct entry can precede the home in the timer loop.
|
|
|
|
|
bm.make_single_reflector(bytes_3(235193), 1, name, slot)
|
|
|
|
|
bm.options_config()
|
|
|
|
|
scenario.clock.advance(6)
|
|
|
|
|
for stream in (101, 102):
|
|
|
|
|
scenario.inject_obp("OBP-1", PacketSpec(dst_id=235193, slot=1, stream_id=stream))
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, slot), "#235193")
|
|
|
|
|
sent = scenario.capture.for_system(name)[-1].fields
|
|
|
|
|
self.assertEqual((sent["dst_id"], sent["slot"]), (bytes_3(9), slot))
|
|
|
|
|
scenario.clock.advance(61)
|
|
|
|
|
bm.rule_timer_loop()
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, 1), "#2348")
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot(name, 2), "#2350")
|
|
|
|
|
home = 2348 if slot == 1 else 2350
|
|
|
|
|
self.assertEqual(scenario.reactor.thread_calls[-1],
|
|
|
|
|
(bm.disconnectedVoice, (name, slot, home), {}))
|
|
|
|
|
|
|
|
|
|
def test_network_direct_dial_to_its_own_default_does_not_make_it_temporary(self):
|
|
|
|
|
config = minimal_config(("MASTER-A",))
|
|
|
|
|
config["SYSTEMS"]["MASTER-A"]["OPTIONS"] = "DIAL1=235193;TIMER=1"
|
|
|
|
|
add_openbridge_system(config, "OBP-1", network_id=3001)
|
|
|
|
|
with DeterministicScenario(config=config) as scenario:
|
|
|
|
|
scenario.register_peer("MASTER-A", 235193)
|
|
|
|
|
scenario.bm.options_config()
|
|
|
|
|
scenario.clock.advance(6)
|
|
|
|
|
scenario.inject_obp("OBP-1", PacketSpec(dst_id=235193, slot=1))
|
|
|
|
|
scenario.clock.advance(61)
|
|
|
|
|
scenario.bm.rule_timer_loop()
|
|
|
|
|
self.assertEqual(scenario.bm.active_reflector_for_system_slot("MASTER-A", 1), "#235193")
|
|
|
|
|
|
|
|
|
|
def test_rf_traffic_to_own_repeater_id_does_not_activate_network_direct_dial(self):
|
|
|
|
|
config = minimal_config(("MASTER-A",))
|
|
|
|
|
config["SYSTEMS"]["MASTER-A"]["NETWORK_DIRECT_DIAL_SLOT"] = 1
|
|
|
|
|
@ -1578,7 +1792,7 @@ NETWORK_DIRECT_DIAL_SLOT: {value}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_dial_timeout_announcement_uses_expired_slot_and_its_default(self):
|
|
|
|
|
def test_dial_timeout_repairs_missing_home_route_and_announces_actual_link(self):
|
|
|
|
|
for slot in (1, 2):
|
|
|
|
|
for default_tg in (0, 90 + slot):
|
|
|
|
|
with self.subTest(slot=slot, default_tg=default_tg):
|
|
|
|
|
@ -1588,6 +1802,7 @@ NETWORK_DIRECT_DIAL_SLOT: {value}
|
|
|
|
|
config["SYSTEMS"]["MASTER-A"]["DEFAULT_DIAL_TS2"] = 92
|
|
|
|
|
config["SYSTEMS"]["MASTER-A"][f"DEFAULT_DIAL_TS{slot}"] = default_tg
|
|
|
|
|
with DeterministicScenario(config=config) as scenario:
|
|
|
|
|
scenario.register_peer("MASTER-A")
|
|
|
|
|
scenario.bm.make_single_reflector(bytes_3(235), 1, "MASTER-A", slot)
|
|
|
|
|
scenario.bm.make_single_reflector(bytes_3(236), 2, "MASTER-A", other_slot)
|
|
|
|
|
other_status = dict(scenario.systems["MASTER-A"].STATUS[other_slot])
|
|
|
|
|
@ -1600,8 +1815,10 @@ NETWORK_DIRECT_DIAL_SLOT: {value}
|
|
|
|
|
if entry["SYSTEM"] == "MASTER-A" and entry["TS"] == other_slot)
|
|
|
|
|
self.assertFalse(expired["ACTIVE"])
|
|
|
|
|
self.assertTrue(other["ACTIVE"])
|
|
|
|
|
self.assertEqual(scenario.bm.active_reflector_for_system_slot("MASTER-A", slot),
|
|
|
|
|
f"#{default_tg}" if default_tg else None)
|
|
|
|
|
self.assertEqual(scenario.reactor.thread_calls,
|
|
|
|
|
[(scenario.bm.disconnectedVoice, ("MASTER-A", slot), {})])
|
|
|
|
|
[(scenario.bm.disconnectedVoice, ("MASTER-A", slot, default_tg), {})])
|
|
|
|
|
|
|
|
|
|
spoken = []
|
|
|
|
|
scenario.bm.words["en_GB"].update({
|
|
|
|
|
@ -1641,6 +1858,23 @@ NETWORK_DIRECT_DIAL_SLOT: {value}
|
|
|
|
|
self.assertIn(b"notlinked", spoken)
|
|
|
|
|
self.assertNotIn(b"linkedto", spoken)
|
|
|
|
|
|
|
|
|
|
def test_dial_timeout_does_not_preempt_a_later_home_return_timer(self):
|
|
|
|
|
with DeterministicScenario() as scenario:
|
|
|
|
|
bm = scenario.bm
|
|
|
|
|
peer = scenario.register_peer("MASTER-A")
|
|
|
|
|
scenario.inject_datagram("MASTER-A", b"RPTO" + peer + b"DIAL2=2350;DIALTO2=3")
|
|
|
|
|
bm.options_config()
|
|
|
|
|
bm.control_dial("MASTER-A", 2, "link", 9990) # Echo always has a one-minute timer.
|
|
|
|
|
scenario.reactor.thread_calls.clear()
|
|
|
|
|
scenario.clock.advance(61)
|
|
|
|
|
bm.rule_timer_loop()
|
|
|
|
|
self.assertIsNone(bm.active_reflector_for_system_slot("MASTER-A", 2))
|
|
|
|
|
self.assertEqual(scenario.reactor.thread_calls,
|
|
|
|
|
[(bm.disconnectedVoice, ("MASTER-A", 2, 0), {})])
|
|
|
|
|
scenario.clock.advance(120)
|
|
|
|
|
bm.rule_timer_loop()
|
|
|
|
|
self.assertEqual(bm.active_reflector_for_system_slot("MASTER-A", 2), "#2350")
|
|
|
|
|
|
|
|
|
|
def test_disconnected_voice_legacy_default_is_slot_two_only(self):
|
|
|
|
|
config = minimal_config(("MASTER-A",))
|
|
|
|
|
system_config = config["SYSTEMS"]["MASTER-A"]
|
|
|
|
|
|