scientific-method-engine 0.9.1__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/PKG-INFO +2 -1
  2. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/pyproject.toml +2 -2
  3. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/__init__.py +1 -1
  4. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/x86/image.py +17 -8
  5. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/x86/machine.py +8 -5
  6. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/tests/test_pe.py +5 -4
  7. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/tests/test_x86.py +49 -7
  8. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/.gitignore +0 -0
  9. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/LICENSE +0 -0
  10. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/README.md +0 -0
  11. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/__main__.py +0 -0
  12. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/cli.py +0 -0
  13. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ClearNoReturnFunctions.java +0 -0
  14. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/CreateFunctions.java +0 -0
  15. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ExportBoundedFlow.java +0 -0
  16. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ExportCallEdges.java +0 -0
  17. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ExportFunctionFingerprints.java +0 -0
  18. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ExportFunctionInventory.java +0 -0
  19. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/MergeFallThroughFragment.java +0 -0
  20. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/RecoverCitedFunctions.java +0 -0
  21. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/RepairReturningCallers.java +0 -0
  22. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportCallArguments.java +0 -0
  23. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportCallPaths.java +0 -0
  24. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportCallSitesWithScalars.java +0 -0
  25. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportCallsToRange.java +0 -0
  26. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportConstantFirstArgumentCalls.java +0 -0
  27. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportDataBytes.java +0 -0
  28. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportDecompileMatches.java +0 -0
  29. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportDecompileWindow.java +0 -0
  30. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportFilePatternInMemory.java +0 -0
  31. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportFirstArgumentCallSummary.java +0 -0
  32. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportFunctionScalarConstants.java +0 -0
  33. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportFunctionSummary.java +0 -0
  34. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportInstructionContext.java +0 -0
  35. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportInstructionWindow.java +0 -0
  36. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportMemoryBlockForFileOffset.java +0 -0
  37. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportMemoryBlocks.java +0 -0
  38. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportRandomnessCandidates.java +0 -0
  39. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportReferences.java +0 -0
  40. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportScalarConstants.java +0 -0
  41. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportStringReferences.java +0 -0
  42. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/ghidra/ReportSymbolReferences.java +0 -0
  43. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/x86/__init__.py +0 -0
  44. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/x86/dispatch.py +0 -0
  45. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/x86/effect_order.py +0 -0
  46. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/x86/pcode.py +0 -0
  47. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/x86/pcode_backend.py +0 -0
  48. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/x86/pe.py +0 -0
  49. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/x86/reports.py +0 -0
  50. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/x86/result_flow.py +0 -0
  51. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/x86/trace.py +0 -0
  52. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/src/scientific_method_engine/x86/values.py +0 -0
  53. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/tests/oracle.py +0 -0
  54. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/tests/test_dispatch.py +0 -0
  55. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/tests/test_effect_order.py +0 -0
  56. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/tests/test_nested_frame_request.py +0 -0
  57. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/tests/test_oracle.py +0 -0
  58. {scientific_method_engine-0.9.1 → scientific_method_engine-1.0.1}/tests/test_table_continuations.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: scientific-method-engine
3
- Version: 0.9.1
3
+ Version: 1.0.1
4
4
  Summary: Bounded instruction-derived x86 evidence reports for segmented MZ/FBOV and PE32/i386 code.
5
5
  Project-URL: Source, https://github.com/kibertoad/refurbished-dinosaurs-toolkit/tree/main/packages/scientific-method-engine
6
6
  Author: kibertoad
@@ -9,6 +9,7 @@ License-File: LICENSE
9
9
  Requires-Python: >=3.12
10
10
  Requires-Dist: capstone==5.0.7
11
11
  Requires-Dist: pypcode==4.0.0
12
+ Requires-Dist: xxhash==4.0.1
12
13
  Provides-Extra: test
13
14
  Requires-Dist: unicorn==2.1.4; extra == 'test'
14
15
  Description-Content-Type: text/markdown
@@ -5,13 +5,13 @@ build-backend = "hatchling.build"
5
5
  [project]
6
6
  name = "scientific-method-engine"
7
7
  # The release workflow writes the published version from the package's release tag.
8
- version = "0.9.1"
8
+ version = "1.0.1"
9
9
  description = "Bounded instruction-derived x86 evidence reports for segmented MZ/FBOV and PE32/i386 code."
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.12"
12
12
  license = "MIT"
13
13
  authors = [{ name = "kibertoad" }]
14
- dependencies = ["capstone==5.0.7", "pypcode==4.0.0"]
14
+ dependencies = ["capstone==5.0.7", "pypcode==4.0.0", "xxhash==4.0.1"]
15
15
 
16
16
  [project.optional-dependencies]
17
17
  # Unicorn is the tests' concrete oracle (ADR 0003, decision 4). Its core is GPLv2, so it never
@@ -2,4 +2,4 @@
2
2
 
3
3
  # The reader passes this number with every prepared config it pipes to the engine. A reader and
4
4
  # engine that disagree on it refuse to run instead of exchanging relocation data in another shape.
5
- PREPARED_PROTOCOL = 1
5
+ PREPARED_PROTOCOL = 2
@@ -1,11 +1,13 @@
1
1
  """Bounded explicit code mappings. No guessed linear disassembly domains."""
2
- import hashlib
2
+ import re
3
3
  from pathlib import Path
4
+ import xxhash
4
5
  from capstone import Cs, CS_ARCH_X86, CS_MODE_16, CS_MODE_32
5
6
  from .pe import prepare_pe
6
7
  import capstone
7
8
 
8
9
  MAX_SOURCE = 256 * 1024 * 1024
10
+ XXH3_FORM = re.compile("[0-9a-f]{32}")
9
11
 
10
12
 
11
13
  def integer(value, low, high, label):
@@ -17,21 +19,28 @@ def integer(value, low, high, label):
17
19
  def read_source(config, base):
18
20
  """Read the source a report config names and check its hash.
19
21
 
20
- ``config["source"]`` is a path relative to ``base``; the file must be at most 256 MiB and hash to
21
- ``config["sha256"]``. Returns ``(data, identity)`` where ``identity`` is
22
- ``{"size": ..., "sha256": ...}``. Raises ``ValueError`` otherwise.
22
+ ``config["source"]`` is a path relative to ``base``; the file must be at most 256 MiB and its
23
+ XXH3-128 hash must equal ``config["xxh3"]``, given as 32 lower-case hex digits. A config that
24
+ still names a ``sha256`` is refused, so a hash from before prepared-config protocol 2 is never
25
+ taken as checked. Returns ``(data, identity)`` where ``identity`` is
26
+ ``{"size": ..., "xxh3": ...}``. Raises ``ValueError`` otherwise.
23
27
  """
24
28
  path = config.get("source")
25
29
  if not isinstance(path, str) or not path:
26
30
  raise ValueError("source path required")
31
+ if "sha256" in config:
32
+ raise ValueError("sha256 is no longer read; name the source by its xxh3 (prepared-config protocol 2)")
33
+ expected = config.get("xxh3")
34
+ if not isinstance(expected, str) or not XXH3_FORM.fullmatch(expected):
35
+ raise ValueError("xxh3 must be the source's XXH3-128 hash as 32 lower-case hex digits")
27
36
  path = Path(base) / path
28
37
  if not path.is_file() or path.stat().st_size > MAX_SOURCE:
29
38
  raise ValueError("source must be a regular file of at most 256 MiB")
30
39
  data = path.read_bytes()
31
- digest = hashlib.sha256(data).hexdigest()
32
- if digest != config.get("sha256"):
33
- raise ValueError("Source SHA-256 differs from the supplied baseline")
34
- return data, {"size": len(data), "sha256": digest}
40
+ digest = xxhash.xxh3_128_hexdigest(data)
41
+ if digest != expected:
42
+ raise ValueError("Source xxh3 differs from the supplied baseline")
43
+ return data, {"size": len(data), "xxh3": digest}
35
44
 
36
45
 
37
46
  class Image:
@@ -67,7 +67,9 @@ class State:
67
67
  self.assumptions = {}
68
68
  self.flags = None
69
69
  # Arithmetic flags as values from the last flag-writing instruction's p-code; None when no
70
- # instruction computed them yet or the last one forgot them.
70
+ # instruction computed them yet or the last one forgot them. Branch conditions run their p-code
71
+ # on these values, and carry_value reads a comparable flag producer's CF from here without
72
+ # running a branch condition.
71
73
  self.flag_values = None
72
74
  # CF when an instruction sets it without leaving a comparable flag producer; None defers to flags.
73
75
  self.carry = None
@@ -126,10 +128,11 @@ class State:
126
128
  def carry_value(self):
127
129
  """CF as a one-bit value: from the last comparable flag producer, an explicit carry, or unknown."""
128
130
  if self.flags is not None:
129
- if self.flag_values is not None and "CF" in self.flag_values:
130
- answer, _ = self.semantics.condition(self, "jb")
131
- if answer is not None:
132
- return const(int(answer), 1, self.flags[3])
131
+ # The producer's p-code CF, read as JB's CBRANCH reads it: nonzero is set. Reading it here
132
+ # skips running the JB p-code and building the branch report each time CF is read.
133
+ carry = (self.flag_values or {}).get("CF")
134
+ if carry is not None and carry.number is not None:
135
+ return const(int(carry.number != 0), 1, self.flags[3])
133
136
  # Name the carry by its producer's operands, so every reading of one comparison shares an assumption.
134
137
  a, b, operation, site = self.flags
135
138
  return unknown(f"carry:{site}:{(operation, a.term, b.term)!r}", 1, site)
@@ -1,5 +1,4 @@
1
1
  """PE32 acceptance uses constructed headers and instructions only."""
2
- import hashlib
3
2
  import json
4
3
  import os
5
4
  from pathlib import Path
@@ -9,6 +8,8 @@ import sys
9
8
  import tempfile
10
9
  import unittest
11
10
 
11
+ import xxhash
12
+
12
13
  SRC = Path(__file__).resolve().parents[1] / "src"
13
14
  sys.path.insert(0, str(SRC))
14
15
  # The engine CLI runs from this checkout's source whether or not the package is installed.
@@ -152,7 +153,7 @@ class PEReporterTests(unittest.TestCase):
152
153
  with tempfile.TemporaryDirectory() as directory:
153
154
  path = Path(directory)
154
155
  (path / 'source.bin').write_bytes(data)
155
- config.update(source='source.bin', sha256=hashlib.sha256(data).hexdigest(), regions=[1])
156
+ config.update(source='source.bin', xxh3=xxhash.xxh3_128_hexdigest(data), regions=[1])
156
157
  (path / 'config.json').write_text(json.dumps(config))
157
158
  process = subprocess.run([*ENGINE, 'trace', str(path / 'config.json')],
158
159
  capture_output=True, text=True, env=ENGINE_ENV)
@@ -324,13 +325,13 @@ class PEReporterTests(unittest.TestCase):
324
325
  with tempfile.TemporaryDirectory() as directory:
325
326
  path = Path(directory)
326
327
  (path / 'source.bin').write_bytes(data)
327
- config.update(source='source.bin', sha256=hashlib.sha256(data).hexdigest())
328
+ config.update(source='source.bin', xxh3=xxhash.xxh3_128_hexdigest(data))
328
329
  environment = {**ENGINE_ENV, 'EVIDENCE_PYTHON': sys.executable}
329
330
  (path / 'config.json').write_text(json.dumps(config))
330
331
  process = subprocess.run(['node', str(READER), 'trace', str(path / 'config.json')], capture_output=True, text=True, env=environment)
331
332
  self.assertEqual(process.returncode, 0, process.stderr)
332
333
  r = json.loads(process.stdout)
333
- self.assertEqual(r['sourceIdentity']['sha256'], config['sha256'])
334
+ self.assertEqual(r['sourceIdentity']['xxh3'], config['xxh3'])
334
335
  self.assertEqual(r['sourceMapping']['format'], 'PE32/i386')
335
336
  config['regions'][0]['ip'] = CODE_VA + 1
336
337
  (path / 'config.json').write_text(json.dumps(config))
@@ -8,6 +8,8 @@ import sys
8
8
  import tempfile
9
9
  import unittest
10
10
 
11
+ import xxhash
12
+
11
13
  SRC = Path(__file__).resolve().parents[1] / "src"
12
14
  sys.path.insert(0, str(SRC))
13
15
  # The engine CLI runs from this checkout's source whether or not the package is installed.
@@ -1097,6 +1099,33 @@ class ReporterTests(unittest.TestCase):
1097
1099
  self.assertEqual(report("ba 05 00 21 d8 83 d2 00 c3")["paths"][0]["registers"]["dx"]["value"], 5)
1098
1100
  self.assertIn("Operand-size", report("b9 02 00 66 e2 fd c3")["paths"][0]["stop"])
1099
1101
 
1102
+ def test_carry_reads_the_producers_pcode_carry_without_a_branch_condition(self):
1103
+ from unittest import mock
1104
+ from scientific_method_engine.x86.pcode_backend import Pypcode
1105
+
1106
+ cases = [
1107
+ ("b8 01 00 05 ff ff", 6), # ADD AX, 0FFFFh carries.
1108
+ ("b8 01 00 05 01 00", 5), # ADD AX, 1 does not.
1109
+ ("b8 01 00 bb 02 00 39 d8", 6), # CMP AX, BX borrows.
1110
+ ("b8 02 00 bb 01 00 39 d8", 5), # CMP AX, BX does not.
1111
+ ("b8 01 00 f7 d8", 6), # NEG of nonzero sets CF.
1112
+ ("b8 00 00 f7 d8", 5), # NEG of zero clears it.
1113
+ ]
1114
+ with mock.patch.object(Pypcode, "condition", autospec=True, side_effect=Pypcode.condition) as condition:
1115
+ for producer, dx in cases:
1116
+ with self.subTest(producer=producer):
1117
+ # The producer, MOV DX, 5 (flags untouched), ADC DX, 0.
1118
+ r = report(producer + " ba 05 00 83 d2 00 c3")
1119
+ self.assertEqual(r["paths"][0]["registers"]["dx"]["value"], dx)
1120
+ self.assertEqual(events(r, "arithmetic")[-1]["carryIn"]["value"], dx - 5)
1121
+ # An unknown producer's carry stays named by the producer's operands.
1122
+ unresolved = events(report("39 d8 83 d2 00 c3"), "arithmetic")[-1]["carryIn"]
1123
+ self.assertIsNone(unresolved["value"])
1124
+ condition.assert_not_called()
1125
+ # A JB still runs its own condition once; its assumption key reads CF without another.
1126
+ self.assertEqual(len(report("39 d8 72 00 c3")["paths"]), 2)
1127
+ self.assertEqual([call.args[2] for call in condition.call_args_list], ["jb"])
1128
+
1100
1129
  def test_incoming_coverage_counts_straddled_segments_scan_limits_and_contested_starts(self):
1101
1130
  data = bytes.fromhex("e8 01 00 c3 c3 e8 fc ff c3")
1102
1131
  cfg = configuration(data, target=4, controls=[5], segments=[{"name": "code", "start": 0, "end": 6, "evidence": "synthetic segment"}])
@@ -1525,20 +1554,33 @@ class ReporterTests(unittest.TestCase):
1525
1554
  with tempfile.TemporaryDirectory() as folder:
1526
1555
  root = Path(folder); data = bytes.fromhex("b8 01 00 c3")
1527
1556
  (root/"fixture.bin").write_bytes(data)
1528
- cfg = configuration(data, source="fixture.bin", sha256=hashlib.sha256(data).hexdigest())
1557
+ cfg = configuration(data, source="fixture.bin", xxh3=xxhash.xxh3_128_hexdigest(data))
1529
1558
  path = root/"config.json"; path.write_text(json.dumps(cfg))
1530
1559
  args = [*ENGINE, "trace", str(path)]
1531
1560
  result = subprocess.run(args, capture_output=True, text=True, env=ENGINE_ENV)
1532
1561
  self.assertEqual(result.returncode, 0, result.stderr)
1533
1562
  header = json.loads(result.stdout)
1534
- self.assertEqual(header["sourceIdentity"]["size"], 4)
1563
+ self.assertEqual(header["sourceIdentity"], {"size": 4, "xxh3": cfg["xxh3"]})
1535
1564
  self.assertEqual((header["decoder"], header["instructionSemantics"]),
1536
1565
  ("capstone " + capstone.__version__, f"pypcode {pypcode.__version__} (Ghidra SLEIGH x86)"))
1537
- cfg["sha256"] = "0" * 64; path.write_text(json.dumps(cfg))
1566
+ cfg["xxh3"] = "0" * 32; path.write_text(json.dumps(cfg))
1538
1567
  result = subprocess.run(args, capture_output=True, text=True, env=ENGINE_ENV)
1539
1568
  self.assertEqual(result.returncode, 1)
1540
1569
  self.assertIn("baseline", result.stderr)
1541
- cfg["sha256"] = hashlib.sha256(data).hexdigest(); cfg["overlayExports"] = []
1570
+ # A SHA-256, an upper-case or a missing hash is not the standard's form.
1571
+ for value in ("0" * 64, xxhash.xxh3_128_hexdigest(data).upper(), None):
1572
+ with self.subTest(xxh3=value):
1573
+ path.write_text(json.dumps({**cfg, "xxh3": value}))
1574
+ result = subprocess.run(args, capture_output=True, text=True, env=ENGINE_ENV)
1575
+ self.assertEqual(result.returncode, 1)
1576
+ self.assertIn("32 lower-case hex digits", result.stderr)
1577
+ # A protocol 1 hash is refused beside a correct xxh3, so it is never taken as checked.
1578
+ path.write_text(json.dumps({**cfg, "xxh3": xxhash.xxh3_128_hexdigest(data),
1579
+ "sha256": hashlib.sha256(data).hexdigest()}))
1580
+ result = subprocess.run(args, capture_output=True, text=True, env=ENGINE_ENV)
1581
+ self.assertEqual(result.returncode, 1)
1582
+ self.assertIn("sha256 is no longer read", result.stderr)
1583
+ cfg["xxh3"] = xxhash.xxh3_128_hexdigest(data); cfg["overlayExports"] = []
1542
1584
  path.write_text(json.dumps(cfg))
1543
1585
  result = subprocess.run(args, capture_output=True, text=True, env=ENGINE_ENV)
1544
1586
  self.assertEqual(result.returncode, 1)
@@ -1548,15 +1590,15 @@ class ReporterTests(unittest.TestCase):
1548
1590
  with tempfile.TemporaryDirectory() as folder:
1549
1591
  root = Path(folder); data = bytes.fromhex("b8 01 00 c3")
1550
1592
  (root/"fixture.bin").write_bytes(data)
1551
- cfg = configuration(data, source=str(root/"fixture.bin"), sha256=hashlib.sha256(data).hexdigest())
1593
+ cfg = configuration(data, source=str(root/"fixture.bin"), xxh3=xxhash.xxh3_128_hexdigest(data))
1552
1594
  stdin = [*ENGINE, "trace", "-"]
1553
- for protocol, accepted in ((None, False), (0, False), (1, True)):
1595
+ for protocol, accepted in ((None, False), (1, False), (2, True)):
1554
1596
  prepared = dict(cfg) if protocol is None else {**cfg, "preparedProtocol": protocol}
1555
1597
  result = subprocess.run(stdin, input=json.dumps(prepared), capture_output=True, text=True, env=ENGINE_ENV)
1556
1598
  self.assertEqual(result.returncode, 0 if accepted else 1, result.stderr)
1557
1599
  if not accepted:
1558
1600
  self.assertIn("protocol", result.stderr)
1559
- path = root/"config.json"; path.write_text(json.dumps({**cfg, "preparedProtocol": 1}))
1601
+ path = root/"config.json"; path.write_text(json.dumps({**cfg, "preparedProtocol": 2}))
1560
1602
  result = subprocess.run([*ENGINE, "trace", str(path)], capture_output=True, text=True, env=ENGINE_ENV)
1561
1603
  self.assertEqual(result.returncode, 1)
1562
1604
  self.assertIn("set by the reader", result.stderr)