Skip to content

Commit 06fdca4

Browse files
committed
pytest: use l1/l2 naming and get_nodes() where appropriate.
Replace non-standard node variable names (n, n2, node, ln) with l1/l2 across test_plugin.py and test_misc.py. Convert four tests in test_connection.py to use get_nodes() instead of consecutive get_node() calls with identical options (slightly faster). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1365083 commit 06fdca4

3 files changed

Lines changed: 181 additions & 185 deletions

File tree

tests/test_connection.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ def test_connect_standard_addr(node_factory):
257257

258258

259259
def test_reconnect_channel_peers(node_factory, executor):
260-
l1 = node_factory.get_node(may_reconnect=True)
261-
l2 = node_factory.get_node(may_reconnect=True)
260+
l1, l2 = node_factory.get_nodes(2, {'may_reconnect': True})
262261
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
263262

264263
l1.fundchannel(l2, 10**6)
@@ -1202,8 +1201,7 @@ def test_funding_push(node_factory, bitcoind, chainparams):
12021201
# We track balances, to verify that accounting is ok.
12031202
coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
12041203

1205-
l1 = node_factory.get_node(options={'plugin': coin_mvt_plugin})
1206-
l2 = node_factory.get_node(options={'plugin': coin_mvt_plugin})
1204+
l1, l2 = node_factory.get_nodes(2, {'plugin': coin_mvt_plugin})
12071205

12081206
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
12091207

@@ -2677,8 +2675,7 @@ def test_update_fee_reconnect(node_factory, bitcoind):
26772675

26782676

26792677
def test_multiple_channels(node_factory):
2680-
l1 = node_factory.get_node()
2681-
l2 = node_factory.get_node()
2678+
l1, l2 = node_factory.get_nodes(2)
26822679

26832680
ret = l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
26842681
assert ret['id'] == l2.info['id']
@@ -2705,8 +2702,7 @@ def test_multiple_channels(node_factory):
27052702
@pytest.mark.openchannel('v1')
27062703
@pytest.mark.openchannel('v2')
27072704
def test_forget_channel(node_factory):
2708-
l1 = node_factory.get_node()
2709-
l2 = node_factory.get_node()
2705+
l1, l2 = node_factory.get_nodes(2)
27102706
l1.fundwallet(10**6)
27112707
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
27122708
l1.rpc.fundchannel(l2.info['id'], 10**5)

tests/test_misc.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2868,11 +2868,11 @@ def test_new_node_is_mainnet(node_factory):
28682868

28692869

28702870
def test_unicode_rpc(node_factory, executor, bitcoind):
2871-
node = node_factory.get_node()
2871+
l1 = node_factory.get_node()
28722872
desc = "Some candy 🍬 and a nice glass of milk 🥛."
28732873

2874-
node.rpc.invoice(amount_msat=42, label=desc, description=desc)
2875-
invoices = node.rpc.listinvoices()['invoices']
2874+
l1.rpc.invoice(amount_msat=42, label=desc, description=desc)
2875+
invoices = l1.rpc.listinvoices()['invoices']
28762876
assert(len(invoices) == 1)
28772877
assert(invoices[0]['description'] == desc)
28782878
assert(invoices[0]['label'] == desc)
@@ -2897,43 +2897,43 @@ def test_unix_socket_path_length(node_factory, bitcoind, directory, executor, db
28972897

28982898

28992899
def test_waitblockheight(node_factory, executor, bitcoind):
2900-
node = node_factory.get_node()
2900+
l1 = node_factory.get_node()
29012901

2902-
sync_blockheight(bitcoind, [node])
2902+
sync_blockheight(bitcoind, [l1])
29032903

2904-
blockheight = node.rpc.getinfo()['blockheight']
2904+
blockheight = l1.rpc.getinfo()['blockheight']
29052905

29062906
# Should succeed without waiting.
2907-
node.rpc.waitblockheight(blockheight - 2)
2908-
node.rpc.waitblockheight(blockheight - 1)
2909-
node.rpc.waitblockheight(blockheight)
2907+
l1.rpc.waitblockheight(blockheight - 2)
2908+
l1.rpc.waitblockheight(blockheight - 1)
2909+
l1.rpc.waitblockheight(blockheight)
29102910

29112911
# Developer mode polls bitcoind every second, so 60 seconds is plenty.
29122912
time = 60
29132913

29142914
# Should not succeed yet.
2915-
fut2 = executor.submit(node.rpc.waitblockheight, blockheight + 2, time)
2916-
fut1 = executor.submit(node.rpc.waitblockheight, blockheight + 1, time)
2915+
fut2 = executor.submit(l1.rpc.waitblockheight, blockheight + 2, time)
2916+
fut1 = executor.submit(l1.rpc.waitblockheight, blockheight + 1, time)
29172917
assert not fut1.done()
29182918
assert not fut2.done()
29192919

29202920
# Should take about ~1second and time out.
29212921
with pytest.raises(RpcError):
2922-
node.rpc.waitblockheight(blockheight + 2, 1)
2922+
l1.rpc.waitblockheight(blockheight + 2, 1)
29232923

29242924
# Others should still not be done.
29252925
assert not fut1.done()
29262926
assert not fut2.done()
29272927

29282928
# Trigger just one more block.
29292929
bitcoind.generate_block(1)
2930-
sync_blockheight(bitcoind, [node])
2930+
sync_blockheight(bitcoind, [l1])
29312931
fut1.result(5)
29322932
assert not fut2.done()
29332933

29342934
# Trigger two blocks.
29352935
bitcoind.generate_block(1)
2936-
sync_blockheight(bitcoind, [node])
2936+
sync_blockheight(bitcoind, [l1])
29372937
fut2.result(5)
29382938

29392939

0 commit comments

Comments
 (0)