diff options
Diffstat (limited to 'packages/meshbay-node/tests/test_dispatch_golden.py')
| -rw-r--r-- | packages/meshbay-node/tests/test_dispatch_golden.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_dispatch_golden.py b/packages/meshbay-node/tests/test_dispatch_golden.py index b31b63b..c917208 100644 --- a/packages/meshbay-node/tests/test_dispatch_golden.py +++ b/packages/meshbay-node/tests/test_dispatch_golden.py @@ -144,6 +144,20 @@ def _message_types() -> list[str]: return sorted(names | {"client_diag", "no_such_type"}) +def _odd_types() -> dict[str, dict]: + """A `type` field that is not a string, or no `type` at all. msgpack will + carry any value there, and a dispatch keyed by type has to treat each of + these as the chain of comparisons did — an unhashable one included.""" + return { + "<missing>": {}, + "<none>": {"type": None}, + "<int>": {"type": 7}, + "<list>": {"type": [MNP.PING]}, + "<dict>": {"type": {"t": MNP.PING}}, + "<bytes>": {"type": MNP.PING.encode()}, + } + + def _shapes(keys: list[str]) -> dict[str, dict]: return { "bare": {}, @@ -165,6 +179,10 @@ def _record(keys: list[str]) -> dict: for shape, fields in _shapes(keys).items(): msg = {**fields, "type": mtype, "req_id": REQ_ID} out["dispatch"][f"{mtype} | {state} | {shape}"] = _run(_session(state), msg) + for label, fields in _odd_types().items(): + for state in ("fresh", "challenged", "member", "operator"): + msg = {**fields, "req_id": REQ_ID} + out["dispatch"][f"{label} | {state} | bare"] = _run(_session(state), msg) for op in _admin_ops() + ["no_such_op"]: s = _session("operator") s._admin_ops["the-op"] = {"op": op, "subject": "subject", "nonce": b"\x05" * 32, |