mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
pytest: test passing utf8 into and out of plugin JSON.
We should be able to pass UTF-8 strings to and from plugins without python turning them into JSON-\u escapes. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
00f3a84af2
commit
5f437de771
2 changed files with 33 additions and 0 deletions
14
tests/plugins/utf8.py
Executable file
14
tests/plugins/utf8.py
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
from lightning import Plugin
|
||||
|
||||
|
||||
plugin = Plugin()
|
||||
|
||||
|
||||
@plugin.method("utf8")
|
||||
def echo(plugin, utf8):
|
||||
assert '\\u' not in utf8
|
||||
return {'utf8': utf8}
|
||||
|
||||
|
||||
plugin.run()
|
|
@ -188,3 +188,22 @@ def test_async_rpcmethod(node_factory, executor):
|
|||
l1.rpc.asyncflush(42)
|
||||
|
||||
assert [r.result() for r in results] == [42] * len(results)
|
||||
|
||||
|
||||
@pytest.mark.xfail(strict=True)
|
||||
def test_utf8_passthrough(node_factory, executor):
|
||||
l1 = node_factory.get_node(options={'plugin': 'tests/plugins/utf8.py',
|
||||
'log-level': 'io'})
|
||||
|
||||
# This works because Python unmangles.
|
||||
res = l1.rpc.call('utf8', ['ナンセンス 1杯'])
|
||||
assert '\\u' not in res['utf8']
|
||||
assert res['utf8'] == 'ナンセンス 1杯'
|
||||
|
||||
# Now, try native.
|
||||
out = subprocess.check_output(['cli/lightning-cli',
|
||||
'--lightning-dir={}'
|
||||
.format(l1.daemon.lightning_dir),
|
||||
'utf8', 'ナンセンス 1杯']).decode('utf-8')
|
||||
assert '\\u' not in out
|
||||
assert out == '{"utf8": "ナンセンス 1杯"}\n'
|
||||
|
|
Loading…
Add table
Reference in a new issue