py-tests: rename 'announce' to 'wait_for_announce'

Better description of what the option actually does -- if true
waits for the announcement messages to be generated and exchanged.
This commit is contained in:
lisa neigut 2018-12-07 15:27:14 -08:00 committed by neil saitug
parent c420f04d66
commit eab992cecd
7 changed files with 19 additions and 19 deletions

View File

@ -62,7 +62,7 @@ def test_single_payment(node_factory, benchmark):
def test_forward_payment(node_factory, benchmark):
l1, l2, l3 = node_factory.line_graph(3, announce=True)
l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True)
def do_pay(src, dest):
invoice = dest.rpc.invoice(1000, 'invoice-{}'.format(random.random()), 'desc')['bolt11']
@ -72,7 +72,7 @@ def test_forward_payment(node_factory, benchmark):
def test_long_forward_payment(node_factory, benchmark):
nodes = node_factory.line_graph(21, announce=True)
nodes = node_factory.line_graph(21, wait_for_announce=True)
def do_pay(src, dest):
invoice = dest.rpc.invoice(1000, 'invoice-{}'.format(random.random()), 'desc')['bolt11']

View File

@ -1040,7 +1040,7 @@ def setup_multihtlc_test(node_factory, bitcoind):
# 1 failed (CLTV2)
# 2 live (CLTV2)
# 1 live (CLTV3)
nodes = node_factory.line_graph(7, announce=True,
nodes = node_factory.line_graph(7, wait_for_announce=True,
opts={'dev-no-reconnect': None,
'may_reconnect': True})

View File

@ -793,7 +793,7 @@ def test_channel_persistence(node_factory, bitcoind, executor):
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1 for --dev-broadcast-interval")
def test_channel_reenable(node_factory):
l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True}, fundchannel=True, announce=True)
l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True}, fundchannel=True, wait_for_announce=True)
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']))
@ -1351,7 +1351,7 @@ def test_fulfill_incoming_first(node_factory, bitcoind):
'dev-no-reconnect': None,
'disconnect': disconnects,
'cltv-final': 200}],
announce=True)
wait_for_announce=True)
# This succeeds.
l1.rpc.pay(l3.rpc.invoice(200000000, 'test_fulfill_incoming_first', 'desc')['bolt11'])

View File

@ -252,7 +252,7 @@ def test_connect_by_gossip(node_factory, bitcoind):
@unittest.skipIf(not DEVELOPER, "DEVELOPER=1 needed to speed up gossip propagation, would be too long otherwise")
def test_gossip_jsonrpc(node_factory):
l1, l2 = node_factory.line_graph(2, fundchannel=True, announce=False)
l1, l2 = node_factory.line_graph(2, fundchannel=True, wait_for_announce=False)
# Shouldn't send announce signatures until 6 deep.
assert not l1.daemon.is_in_log('peer_out WIRE_ANNOUNCEMENT_SIGNATURES')
@ -872,7 +872,7 @@ def test_node_reannounce(node_factory, bitcoind):
def test_gossipwith(node_factory):
l1, l2 = node_factory.line_graph(2, announce=True)
l1, l2 = node_factory.line_graph(2, wait_for_announce=True)
out = subprocess.run(['devtools/gossipwith',
'--initial-sync',

View File

@ -99,7 +99,7 @@ def test_invoice_weirdstring(node_factory):
def test_invoice_preimage(node_factory):
"""Test explicit invoice 'preimage'.
"""
l1, l2 = node_factory.line_graph(2, announce=True)
l1, l2 = node_factory.line_graph(2, wait_for_announce=True)
# I promise the below number is randomly generated
invoice_preimage = "17b08f669513b7379728fc1abcea5eaf3448bc1eba55a68ca2cd1843409cdc04"

View File

@ -126,7 +126,7 @@ def test_pay_disconnect(node_factory, bitcoind):
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1 for dev_suppress_gossip")
def test_pay_get_error_with_update(node_factory):
"""We should process an update inside a temporary_channel_failure"""
l1, l2, l3 = node_factory.line_graph(3, opts={'log-level': 'io'}, fundchannel=True, announce=True)
l1, l2, l3 = node_factory.line_graph(3, opts={'log-level': 'io'}, fundchannel=True, wait_for_announce=True)
chanid2 = l2.get_channel_scid(l3)
inv = l3.rpc.invoice(123000, 'test_pay_get_error_with_update', 'description')
@ -985,11 +985,11 @@ def test_forward_stats(node_factory, bitcoind):
"""
amount = 10**5
l1, l2, l3 = node_factory.line_graph(3, announce=False)
l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=False)
l4 = node_factory.get_node()
l5 = node_factory.get_node(may_fail=True)
l2.openchannel(l4, 10**6, announce=False)
l2.openchannel(l5, 10**6, announce=True)
l2.openchannel(l4, 10**6, wait_for_announce=False)
l2.openchannel(l5, 10**6, wait_for_announce=True)
bitcoind.generate_block(5)
@ -1054,7 +1054,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
# l1 -> l2 -> l3 -> l4
# l4 ignores htlcs, so they stay.
# l3 will see a reconnect from l4 when l4 restarts.
l1, l2, l3, l4 = node_factory.line_graph(4, announce=True, opts=[{}] * 2 + [{'dev-no-reconnect': None, 'may_reconnect': True}] * 2)
l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True, opts=[{}] * 2 + [{'dev-no-reconnect': None, 'may_reconnect': True}] * 2)
h = l4.rpc.invoice(msatoshi=10**8, label='x', description='desc')['payment_hash']
l4.rpc.dev_ignore_htlcs(id=l3.info['id'], ignore=True)

View File

@ -385,7 +385,7 @@ class LightningNode(object):
self.may_fail = may_fail
self.may_reconnect = may_reconnect
def openchannel(self, remote_node, capacity, addrtype="p2sh-segwit", confirm=True, announce=True, connect=True):
def openchannel(self, remote_node, capacity, addrtype="p2sh-segwit", confirm=True, wait_for_announce=True, connect=True):
addr, wallettxid = self.fundwallet(10 * capacity, addrtype)
if connect and remote_node.info['id'] not in [p['id'] for p in self.rpc.listpeers()['peers']]:
@ -396,13 +396,13 @@ class LightningNode(object):
# Wait for the funding transaction to be in bitcoind's mempool
wait_for(lambda: fundingtx['txid'] in self.bitcoin.rpc.getrawmempool())
if confirm or announce:
if confirm or wait_for_announce:
self.bitcoin.generate_block(1)
if announce:
if wait_for_announce:
self.bitcoin.generate_block(5)
if confirm or announce:
if confirm or wait_for_announce:
self.daemon.wait_for_log(
r'Funding tx {} depth'.format(fundingtx['txid']))
return {'address': addr, 'wallettxid': wallettxid, 'fundingtx': fundingtx}
@ -788,7 +788,7 @@ class NodeFactory(object):
raise
return node
def line_graph(self, num_nodes, fundchannel=True, fundamount=10**6, announce=False, opts=None):
def line_graph(self, num_nodes, fundchannel=True, fundamount=10**6, wait_for_announce=False, opts=None):
""" Create nodes, connect them and optionally fund channels.
"""
nodes = self.get_nodes(num_nodes, opts=opts)
@ -825,7 +825,7 @@ class NodeFactory(object):
src.daemon.wait_for_log(r'Received channel_update for channel {scid}\(.\) now ACTIVE'.format(scid=scid))
scids.append(scid)
if not announce:
if not wait_for_announce:
return nodes
bitcoin.generate_block(5)