mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-09 08:21:50 +00:00
fix(discord): recover Windows voice opus decoding
This commit is contained in:
parent
bb65bebed7
commit
ea34925002
2 changed files with 60 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
"""Tests for Discord Opus codec loading — must use ctypes.util.find_library."""
|
||||
|
||||
import inspect
|
||||
import types
|
||||
|
||||
|
||||
class TestOpusFindLibrary:
|
||||
|
|
@ -29,12 +30,34 @@ class TestOpusFindLibrary:
|
|||
assert "sys.platform" in source or "darwin" in source, \
|
||||
"Homebrew fallback must be guarded by macOS platform check"
|
||||
|
||||
def test_windows_bundled_discord_opus_dll_is_discovered(self, monkeypatch, tmp_path):
|
||||
"""Native Windows installs should try discord.py's bundled opus DLL."""
|
||||
import plugins.platforms.discord.adapter as adapter
|
||||
|
||||
opus_py = tmp_path / "discord" / "opus.py"
|
||||
bundled = opus_py.parent / "bin" / "libopus-0.x64.dll"
|
||||
bundled.parent.mkdir(parents=True)
|
||||
opus_py.write_text("# fake discord.opus module\n")
|
||||
bundled.write_bytes(b"fake dll")
|
||||
|
||||
discord_stub = types.SimpleNamespace(
|
||||
opus=types.SimpleNamespace(__file__=str(opus_py))
|
||||
)
|
||||
monkeypatch.setattr(adapter.sys, "platform", "win32")
|
||||
monkeypatch.setattr(adapter.struct, "calcsize", lambda _fmt: 8)
|
||||
|
||||
assert adapter._find_discord_windows_bundled_opus(discord_stub) == str(
|
||||
bundled.resolve()
|
||||
)
|
||||
|
||||
def test_opus_decode_error_logged(self):
|
||||
"""Opus decode failure must log the error, not silently return."""
|
||||
from plugins.platforms.discord.adapter import VoiceReceiver
|
||||
source = inspect.getsource(VoiceReceiver._on_packet)
|
||||
assert "logger" in source, \
|
||||
"_on_packet must log Opus decode errors"
|
||||
assert "self._decoders.pop" in source, \
|
||||
"_on_packet must reset the Opus decoder after decode failures"
|
||||
# Must not have bare `except Exception:\n return`
|
||||
lines = source.split("\n")
|
||||
for i, line in enumerate(lines):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue