Address code-review nits for BAD_FCS support

- decode.py: use the GSMTAP_FLAG_BAD_FCS constant instead of a literal
  0x01 in gsmtap_flag_names() (import from ..gsmtap); no behavior change.
- tests: add a DB round-trip test (insert_message with BAD_FCS flag →
  get_messages → decoded.errors) covering the end-to-end path, not just
  the direct decode_sniff_msg call.
This commit is contained in:
catarrh committed 2026-08-26 22:11:29 +03:00
1 parent 66094a0114
commit 79acb3773f
2 files changed
+17 -1

No files matched your search

+14
View File
@@ -1204,6 +1204,20 @@ class TestFileDecoders(unittest.TestCase):
class TestSelectionTracking(unittest.TestCase):
def test_bad_fcs_roundtrip(self):
# GSMTAP BAD_FCS flag stored via insert_message must surface as a
# decode error in the DB → frontend path (not just the direct call).
import tempfile
from simtrace2_pysniff.server.database import Database
from simtrace2_pysniff.gsmtap import GSMTAP_FLAG_BAD_FCS
with tempfile.NamedTemporaryFile(suffix='.db') as tmp:
db = Database(tmp.name)
sid = db.create_session('capture')
db.insert_message(sid, 0.1, 'tpdu', bytes.fromhex('80f2000000'),
GSMTAP_FLAG_BAD_FCS)
msgs = db.get_messages(sid)
self.assertIn('bad FCS (desynced)', msgs[0]['decoded']['errors'])
def test_select_then_read(self):
import tempfile
from simtrace2_pysniff.server.database import Database