Couple of fixes

This commit is contained in:
Miroslav Štampar
2026-08-17 22:20:42 +02:00
parent 77ee160875
commit 848ba68ccf
11 changed files with 53 additions and 11 deletions
+13
View File
@@ -58,6 +58,19 @@ class KbCharsDistinctTest(unittest.TestCase):
self.assertEqual(len(set(drawn)), len(MARKERS),
msg="colliding kb.chars markers on round %d: %s" % (i, dict(zip(MARKERS, drawn))))
def test_markers_never_contain_each_other(self):
# whole-string distinctness is not enough: the boundary character wrapping every marker used
# to be drawn for the inner letters as well, so a start marker could render as 'qzqxq', which
# carries the perfectly legal replacement marker 'qzq' (and 'qxq') inside it
for i in range(ROUNDS):
_setKnowledgeBaseAttributes()
drawn = [getattr(kb.chars, _) for _ in MARKERS]
for one in drawn:
for other in drawn:
if one is not other:
self.assertNotIn(other, one,
msg="kb.chars marker %r contains %r on round %d" % (one, other, i))
def test_markers_keep_their_shape(self):
# the fix must not change the on-the-wire length of a payload
for _ in range(ROUNDS // 100):
+16
View File
@@ -30,6 +30,7 @@ bootstrap()
from lib.core.data import conf, kb, queries
from lib.core.enums import DBMS
from lib.core.enums import PAYLOAD
from lib.core.settings import MULTIBIT_MAX_FAILURES
from lib.core.settings import MULTIBIT_NARROW
from lib.core.settings import MULTIBIT_WIDEN
from plugins.dbms.sqlite import SQLiteMap # registers the SQLite escaper used by the read-back
@@ -236,6 +237,21 @@ class MultibitTest(unittest.TestCase):
good = target.secret("plain ascii value that must still come back")
self.assertEqual(self._read(target, good, len(good)), good, "condemned after %r" % first)
def test_null_values_do_not_condemn_the_channel(self):
# a NULL column has no length, so the read-back's length probe comes back unselected no matter
# what the channel did - i.e. exactly the way a channel dropping rows fails it. That is the
# data's doing, and a handful of NULLs in one dump must not retire a working channel
first = "first value is perfectly readable ascii"
target = _Target(first)
self.assertEqual(self._read(target, first, len(first)), first)
for _ in range(MULTIBIT_MAX_FAILURES + 1):
target.secret(None)
self.assertIsNone(self._read(target, ""))
good = target.secret("and the channel is still fine afterwards")
self.assertEqual(self._read(target, good, len(good)), good)
def test_unreadable_value_mid_run_keeps_the_channel(self):
target = _Target("first value is perfectly readable ascii")
self.assertEqual(self._read(target, "first value is perfectly readable ascii", 39), "first value is perfectly readable ascii")