noise: Initial version of the noise chat plugin

Based on the WhatSat idea by @joostjager, this plugin implements a simple chat
protocol based on top of `createonion` and `sendonion`.
This commit is contained in:
Christian Decker
2019-11-14 18:35:19 +01:00
parent 1c1b8fe431
commit ac49e8bd07
3 changed files with 214 additions and 0 deletions

54
noise/test_chat.py Normal file
View File

@@ -0,0 +1,54 @@
from pyln.testing.fixtures import *
from pyln.testing.utils import wait_for
from pprint import pprint
plugin = os.path.join(os.path.dirname(__file__), 'noise.py')
def test_sendmsg(node_factory, executor):
opts = [{'plugin': plugin}, {}, {'plugin': plugin}]
l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True, opts=opts)
recv = executor.submit(l3.rpc.recvmsg)
l1.rpc.sendmsg(l3.info['id'], "Hello world!")
# This one is tailing the incoming messages
m1 = recv.result(10)
# This one should get the same result:
m2 = l3.rpc.recvmsg(last_id=-1)
# They should be the same :-)
assert(m1 == m2)
def test_sendmsg_retry(node_factory, executor):
opts = [{'plugin': plugin}, {}, {'fee-base': 10000}, {'plugin': plugin}]
l1, l2, l3, l4 = node_factory.line_graph(4, opts=opts)
l5 = node_factory.get_node()
l2.openchannel(l5, 10**6)
l5.openchannel(l4, 10**6)
def gossip_synced(nodes):
for a, b in zip(nodes[:-1], nodes[1:]):
if a.rpc.listchannels() != b.rpc.listchannels():
return False
return True
wait_for(lambda: gossip_synced([l1, l2, l3, l4, l5]))
# Now stop l5 so the first attempt will fail.
l5.stop()
recv = executor.submit(l4.rpc.recvmsg)
send = executor.submit(l1.rpc.sendmsg, l4.info['id'], "Hello world!")
l1.daemon.wait_for_log(r'Retrying delivery')
sres = send.result(10)
assert(sres['attempt'] == 2)
pprint(sres)
print(recv.result(10))
msg = l4.rpc.recvmsg(last_id=-1)