refactor: make expected_connections optional

This commit is contained in:
UdjinM6 2024-09-25 16:21:15 +03:00
parent fd2fbe06a3
commit cedd3d52be
No known key found for this signature in database
GPG Key ID: 83592BD1400D58D9

View File

@ -45,7 +45,7 @@ class LLMQSimplePoSeTest(DashTestFramework):
self.test_no_banning()
# Lets restart masternodes with closed ports and verify that they get banned even though they are connected to other MNs (via outbound connections)
self.test_banning(self.close_mn_port, 3)
self.test_banning(self.close_mn_port)
self.deaf_mns.clear()
self.repair_masternodes(True)
@ -158,7 +158,7 @@ class LLMQSimplePoSeTest(DashTestFramework):
return new_quorum
def test_banning(self, invalidate_proc, expected_connections):
def test_banning(self, invalidate_proc, expected_connections=None):
mninfos_online = self.mninfo.copy()
mninfos_valid = self.mninfo.copy()
expected_contributors = len(mninfos_online)
@ -173,11 +173,13 @@ class LLMQSimplePoSeTest(DashTestFramework):
# NOTE: Min PoSe penalty is 100 (see CDeterministicMNList::CalcMaxPoSePenalty()),
# so nodes are PoSe-banned in the same DKG they misbehave without being PoSe-punished first.
if instant_ban:
assert expected_connections is not None
self.reset_probe_timeouts()
self.mine_quorum(expected_connections=expected_connections, expected_members=expected_contributors, expected_contributions=expected_contributors, expected_complaints=expected_complaints, expected_commitments=expected_contributors, mninfos_online=mninfos_online, mninfos_valid=mninfos_valid)
else:
# It's ok to miss probes/quorum connections up to 5 times.
# 6th time is when it should be banned for sure.
assert expected_connections is None
for _ in range(6):
self.reset_probe_timeouts()
self.mine_quorum_less_checks(expected_contributors - 1, mninfos_online)