Browse Source

lightningd: test for weird aliases.

Test has inverted conditions to make it "pass", we fix as we go.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
a077c3defb
  1. 30
      tests/test_lightningd.py
  2. 4
      tests/utils.py

30
tests/test_lightningd.py

@ -2102,6 +2102,36 @@ class LightningDTests(BaseLightningDTests):
assert [c['active'] for c in l2.rpc.listchannels()['channels']] == [True, True]
assert [c['public'] for c in l2.rpc.listchannels()['channels']] == [True, True]
def test_gossip_weirdalias(self):
weird_name = '\t \n \" \n \r \n \\'
l1 = self.node_factory.get_node(options=['--alias={}'
.format(weird_name)])
weird_name_json = json.encoder.JSONEncoder().encode(weird_name)[1:-1].replace('\\', '\\\\')
aliasline = l1.daemon.is_in_log('Server started with public key .* alias')
# FIXME: alias needs json escaping.
assert weird_name_json not in str(aliasline)
normal_name = 'Normal name'
l2 = self.node_factory.get_node(options=['--alias={}'
.format(normal_name)])
assert l2.daemon.is_in_log('Server started with public key .* alias {}'
.format(normal_name))
l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])
self.fund_channel(l2, l1, 10**6)
bitcoind.rpc.generate(6)
# They should gossip together.
l1.daemon.wait_for_log('Received node_announcement for node {}'
.format(l2.info['id']))
l2.daemon.wait_for_log('Received node_announcement for node {}'
.format(l1.info['id']))
node = l1.rpc.listnodes(l1.info['id'])['nodes'][0]
# FIXME: We get this wrong!
assert not node['alias'] == weird_name
node = l2.rpc.listnodes(l1.info['id'])['nodes'][0]
assert not node['alias'] == weird_name
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1 for --dev-broadcast-interval")
def test_gossip_pruning(self):
""" Create channel and see it being updated in time before pruning

4
tests/utils.py

@ -116,10 +116,10 @@ class TailableProc(object):
for l in self.logs[start:]:
if ex.search(l):
logging.debug("Found '%s' in logs", regex)
return True
return l
logging.debug("Did not find '%s' in logs", regex)
return False
return None
def wait_for_logs(self, regexs, timeout=60):
"""Look for `regexs` in the logs.

Loading…
Cancel
Save