pytest: use absolute paths for plugin arguments.

We're going to change this in the next patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-08-03 14:40:40 +09:30
parent c24573b0d2
commit 4fcd94a091
3 changed files with 35 additions and 32 deletions

View File

@@ -3,7 +3,7 @@ from flaky import flaky
from lightning import RpcError from lightning import RpcError
from utils import only_one, sync_blockheight, wait_for, DEVELOPER, TIMEOUT, VALGRIND, SLOW_MACHINE from utils import only_one, sync_blockheight, wait_for, DEVELOPER, TIMEOUT, VALGRIND, SLOW_MACHINE
import os
import queue import queue
import pytest import pytest
import re import re
@@ -1131,8 +1131,8 @@ def test_onchain_multihtlc_our_unilateral(node_factory, bitcoind):
# In fact, they'll fail them with WIRE_TEMPORARY_NODE_FAILURE. # In fact, they'll fail them with WIRE_TEMPORARY_NODE_FAILURE.
# TODO Remove our reliance on HTLCs failing on startup and the need for # TODO Remove our reliance on HTLCs failing on startup and the need for
# this plugin # this plugin
nodes[0].daemon.opts['plugin'] = 'tests/plugins/fail_htlcs.py' nodes[0].daemon.opts['plugin'] = os.path.join(os.getcwd(), 'tests/plugins/fail_htlcs.py')
nodes[-1].daemon.opts['plugin'] = 'tests/plugins/fail_htlcs.py' nodes[-1].daemon.opts['plugin'] = os.path.join(os.getcwd(), 'tests/plugins/fail_htlcs.py')
nodes[0].restart() nodes[0].restart()
nodes[-1].restart() nodes[-1].restart()
@@ -1223,8 +1223,8 @@ def test_onchain_multihtlc_their_unilateral(node_factory, bitcoind):
# In fact, they'll fail them with WIRE_TEMPORARY_NODE_FAILURE. # In fact, they'll fail them with WIRE_TEMPORARY_NODE_FAILURE.
# TODO Remove our reliance on HTLCs failing on startup and the need for # TODO Remove our reliance on HTLCs failing on startup and the need for
# this plugin # this plugin
nodes[0].daemon.opts['plugin'] = 'tests/plugins/fail_htlcs.py' nodes[0].daemon.opts['plugin'] = os.path.join(os.getcwd(), 'tests/plugins/fail_htlcs.py')
nodes[-1].daemon.opts['plugin'] = 'tests/plugins/fail_htlcs.py' nodes[-1].daemon.opts['plugin'] = os.path.join(os.getcwd(), 'tests/plugins/fail_htlcs.py')
nodes[0].restart() nodes[0].restart()
nodes[-1].restart() nodes[-1].restart()

View File

@@ -6,6 +6,7 @@ from utils import DEVELOPER, wait_for, only_one, sync_blockheight, SLOW_MACHINE,
import copy import copy
import concurrent.futures import concurrent.futures
import os
import pytest import pytest
import random import random
import re import re
@@ -1378,7 +1379,7 @@ def test_htlcs_cltv_only_difference(node_factory, bitcoind):
# TODO Remove our reliance on HTLCs failing on startup and the need for # TODO Remove our reliance on HTLCs failing on startup and the need for
# this plugin # this plugin
l4.daemon.opts['plugin'] = 'tests/plugins/fail_htlcs.py' l4.daemon.opts['plugin'] = os.path.join(os.getcwd(), 'tests/plugins/fail_htlcs.py')
# Restarting tail node will stop it ignoring HTLCs (it will actually # Restarting tail node will stop it ignoring HTLCs (it will actually
# fail them immediately). # fail them immediately).
@@ -2052,7 +2053,7 @@ def test_channel_spendable(node_factory, bitcoind):
"""Test that spendable_msat is accurate""" """Test that spendable_msat is accurate"""
sats = 10**6 sats = 10**6
l1, l2 = node_factory.line_graph(2, fundamount=sats, wait_for_announce=True, l1, l2 = node_factory.line_graph(2, fundamount=sats, wait_for_announce=True,
opts={'plugin': 'tests/plugins/hold_invoice.py', 'holdtime': str(TIMEOUT / 2)}) opts={'plugin': os.path.join(os.getcwd(), 'tests/plugins/hold_invoice.py'), 'holdtime': str(TIMEOUT / 2)})
payment_hash = l2.rpc.invoice('any', 'inv', 'for testing')['payment_hash'] payment_hash = l2.rpc.invoice('any', 'inv', 'for testing')['payment_hash']
@@ -2105,7 +2106,7 @@ def test_channel_spendable_large(node_factory, bitcoind):
# This is almost the max allowable spend. # This is almost the max allowable spend.
sats = 4294967 sats = 4294967
l1, l2 = node_factory.line_graph(2, fundamount=sats, wait_for_announce=True, l1, l2 = node_factory.line_graph(2, fundamount=sats, wait_for_announce=True,
opts={'plugin': 'tests/plugins/hold_invoice.py', 'holdtime': str(TIMEOUT / 2)}) opts={'plugin': os.path.join(os.getcwd(), 'tests/plugins/hold_invoice.py'), 'holdtime': str(TIMEOUT / 2)})
payment_hash = l2.rpc.invoice('any', 'inv', 'for testing')['payment_hash'] payment_hash = l2.rpc.invoice('any', 'inv', 'for testing')['payment_hash']

View File

@@ -19,7 +19,7 @@ def test_option_passthrough(node_factory):
First attempts without the plugin and then with the plugin. First attempts without the plugin and then with the plugin.
""" """
plugin_path = 'contrib/plugins/helloworld.py' plugin_path = os.path.join(os.getcwd(), 'contrib/plugins/helloworld.py')
help_out = subprocess.check_output([ help_out = subprocess.check_output([
'lightningd/lightningd', 'lightningd/lightningd',
@@ -43,7 +43,7 @@ def test_option_passthrough(node_factory):
def test_millisatoshi_passthrough(node_factory): def test_millisatoshi_passthrough(node_factory):
""" Ensure that Millisatoshi arguments and return work. """ Ensure that Millisatoshi arguments and return work.
""" """
plugin_path = 'tests/plugins/millisatoshis.py' plugin_path = os.path.join(os.getcwd(), 'tests/plugins/millisatoshis.py')
n = node_factory.get_node(options={'plugin': plugin_path, 'log-level': 'io'}) n = node_factory.get_node(options={'plugin': plugin_path, 'log-level': 'io'})
# By keyword # By keyword
@@ -64,7 +64,7 @@ def test_rpc_passthrough(node_factory):
then try to call it. then try to call it.
""" """
plugin_path = 'contrib/plugins/helloworld.py' plugin_path = os.path.join(os.getcwd(), 'contrib/plugins/helloworld.py')
n = node_factory.get_node(options={'plugin': plugin_path, 'greeting': 'Ciao'}) n = node_factory.get_node(options={'plugin': plugin_path, 'greeting': 'Ciao'})
# Make sure that the 'hello' command that the helloworld.py plugin # Make sure that the 'hello' command that the helloworld.py plugin
@@ -87,7 +87,7 @@ def test_rpc_passthrough(node_factory):
def test_plugin_dir(node_factory): def test_plugin_dir(node_factory):
"""--plugin-dir works""" """--plugin-dir works"""
plugin_dir = 'contrib/plugins' plugin_dir = os.path.join(os.getcwd(), 'contrib/plugins')
node_factory.get_node(options={'plugin-dir': plugin_dir, 'greeting': 'Mars'}) node_factory.get_node(options={'plugin-dir': plugin_dir, 'greeting': 'Mars'})
@@ -154,7 +154,7 @@ def test_plugin_command(node_factory):
def test_plugin_disable(node_factory): def test_plugin_disable(node_factory):
"""--disable-plugin works""" """--disable-plugin works"""
plugin_dir = 'contrib/plugins' plugin_dir = os.path.join(os.getcwd(), 'contrib/plugins')
# We need plugin-dir before disable-plugin! # We need plugin-dir before disable-plugin!
n = node_factory.get_node(options=OrderedDict([('plugin-dir', plugin_dir), n = node_factory.get_node(options=OrderedDict([('plugin-dir', plugin_dir),
('disable-plugin', ('disable-plugin',
@@ -179,7 +179,7 @@ def test_plugin_hook(node_factory, executor):
complete the payment. complete the payment.
""" """
l1, l2 = node_factory.line_graph(2, opts={'plugin': 'contrib/plugins/helloworld.py'}) l1, l2 = node_factory.line_graph(2, opts={'plugin': os.path.join(os.getcwd(), 'contrib/plugins/helloworld.py')})
start_time = time.time() start_time = time.time()
f = executor.submit(l1.pay, l2, 100000) f = executor.submit(l1.pay, l2, 100000)
l2.daemon.wait_for_log(r'on_htlc_accepted called') l2.daemon.wait_for_log(r'on_htlc_accepted called')
@@ -194,7 +194,7 @@ def test_plugin_hook(node_factory, executor):
def test_plugin_connect_notifications(node_factory): def test_plugin_connect_notifications(node_factory):
""" test 'connect' and 'disconnect' notifications """ test 'connect' and 'disconnect' notifications
""" """
l1, l2 = node_factory.get_nodes(2, opts={'plugin': 'contrib/plugins/helloworld.py'}) l1, l2 = node_factory.get_nodes(2, opts={'plugin': os.path.join(os.getcwd(), 'contrib/plugins/helloworld.py')})
l1.connect(l2) l1.connect(l2)
l1.daemon.wait_for_log(r'Received connect event') l1.daemon.wait_for_log(r'Received connect event')
@@ -207,8 +207,8 @@ def test_plugin_connect_notifications(node_factory):
def test_failing_plugins(): def test_failing_plugins():
fail_plugins = [ fail_plugins = [
'contrib/plugins/fail/failtimeout.py', os.path.join(os.getcwd(), 'contrib/plugins/fail/failtimeout.py'),
'contrib/plugins/fail/doesnotexist.py', os.path.join(os.getcwd(), 'contrib/plugins/fail/doesnotexist.py'),
] ]
for p in fail_plugins: for p in fail_plugins:
@@ -240,7 +240,7 @@ def test_plugin_connected_hook(node_factory):
l1 is configured to accept connections from l2, but not from l3. l1 is configured to accept connections from l2, but not from l3.
""" """
opts = [{'plugin': 'tests/plugins/reject.py'}, {}, {}] opts = [{'plugin': os.path.join(os.getcwd(), 'tests/plugins/reject.py')}, {}, {}]
l1, l2, l3 = node_factory.get_nodes(3, opts=opts) l1, l2, l3 = node_factory.get_nodes(3, opts=opts)
l1.rpc.reject(l3.info['id']) l1.rpc.reject(l3.info['id'])
@@ -269,7 +269,7 @@ def test_async_rpcmethod(node_factory, executor):
It works in conjunction with the `asynctest` plugin which stashes It works in conjunction with the `asynctest` plugin which stashes
requests and then resolves all of them on the fifth call. requests and then resolves all of them on the fifth call.
""" """
l1 = node_factory.get_node(options={'plugin': 'tests/plugins/asynctest.py'}) l1 = node_factory.get_node(options={'plugin': os.path.join(os.getcwd(), 'tests/plugins/asynctest.py')})
results = [] results = []
for i in range(10): for i in range(10):
@@ -290,7 +290,7 @@ def test_async_rpcmethod(node_factory, executor):
def test_db_hook(node_factory, executor): def test_db_hook(node_factory, executor):
"""This tests the db hook.""" """This tests the db hook."""
dbfile = os.path.join(node_factory.directory, "dblog.sqlite3") dbfile = os.path.join(node_factory.directory, "dblog.sqlite3")
l1 = node_factory.get_node(options={'plugin': 'tests/plugins/dblog.py', l1 = node_factory.get_node(options={'plugin': os.path.join(os.getcwd(), 'tests/plugins/dblog.py'),
'dblog-file': dbfile}) 'dblog-file': dbfile})
# It should see the db being created, and sometime later actually get # It should see the db being created, and sometime later actually get
@@ -313,7 +313,7 @@ def test_db_hook(node_factory, executor):
def test_utf8_passthrough(node_factory, executor): def test_utf8_passthrough(node_factory, executor):
l1 = node_factory.get_node(options={'plugin': 'tests/plugins/utf8.py', l1 = node_factory.get_node(options={'plugin': os.path.join(os.getcwd(), 'tests/plugins/utf8.py'),
'log-level': 'io'}) 'log-level': 'io'})
# This works because Python unmangles. # This works because Python unmangles.
@@ -333,7 +333,7 @@ def test_utf8_passthrough(node_factory, executor):
def test_invoice_payment_hook(node_factory): def test_invoice_payment_hook(node_factory):
""" l1 uses the reject-payment plugin to reject invoices with odd preimages. """ l1 uses the reject-payment plugin to reject invoices with odd preimages.
""" """
opts = [{}, {'plugin': 'tests/plugins/reject_some_invoices.py'}] opts = [{}, {'plugin': os.path.join(os.getcwd(), 'tests/plugins/reject_some_invoices.py')}]
l1, l2 = node_factory.line_graph(2, opts=opts) l1, l2 = node_factory.line_graph(2, opts=opts)
# This one works # This one works
@@ -360,7 +360,7 @@ def test_invoice_payment_hook(node_factory):
def test_invoice_payment_hook_hold(node_factory): def test_invoice_payment_hook_hold(node_factory):
""" l1 uses the hold_invoice plugin to delay invoice payment. """ l1 uses the hold_invoice plugin to delay invoice payment.
""" """
opts = [{}, {'plugin': 'tests/plugins/hold_invoice.py', 'holdtime': TIMEOUT / 2}] opts = [{}, {'plugin': os.path.join(os.getcwd(), 'tests/plugins/hold_invoice.py'), 'holdtime': TIMEOUT / 2}]
l1, l2 = node_factory.line_graph(2, opts=opts) l1, l2 = node_factory.line_graph(2, opts=opts)
inv1 = l2.rpc.invoice(123000, 'label', 'description', preimage='1' * 64) inv1 = l2.rpc.invoice(123000, 'label', 'description', preimage='1' * 64)
@@ -370,7 +370,7 @@ def test_invoice_payment_hook_hold(node_factory):
def test_openchannel_hook(node_factory, bitcoind): def test_openchannel_hook(node_factory, bitcoind):
""" l2 uses the reject_odd_funding_amounts plugin to reject some openings. """ l2 uses the reject_odd_funding_amounts plugin to reject some openings.
""" """
opts = [{}, {'plugin': 'tests/plugins/reject_odd_funding_amounts.py'}] opts = [{}, {'plugin': os.path.join(os.getcwd(), 'tests/plugins/reject_odd_funding_amounts.py')}]
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts) l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts)
# Get some funds. # Get some funds.
@@ -418,7 +418,7 @@ def test_htlc_accepted_hook_fail(node_factory):
""" """
l1, l2, l3 = node_factory.line_graph(3, opts=[ l1, l2, l3 = node_factory.line_graph(3, opts=[
{}, {},
{'plugin': 'tests/plugins/fail_htlcs.py'}, {'plugin': os.path.join(os.getcwd(), 'tests/plugins/fail_htlcs.py')},
{} {}
], wait_for_announce=True) ], wait_for_announce=True)
@@ -449,7 +449,7 @@ def test_htlc_accepted_hook_resolve(node_factory):
""" """
l1, l2, l3 = node_factory.line_graph(3, opts=[ l1, l2, l3 = node_factory.line_graph(3, opts=[
{}, {},
{'plugin': 'tests/plugins/shortcircuit.py'}, {'plugin': os.path.join(os.getcwd(), 'tests/plugins/shortcircuit.py')},
{} {}
], wait_for_announce=True) ], wait_for_announce=True)
@@ -466,7 +466,8 @@ def test_htlc_accepted_hook_direct_restart(node_factory, executor):
""" """
l1, l2 = node_factory.line_graph(2, opts=[ l1, l2 = node_factory.line_graph(2, opts=[
{'may_reconnect': True}, {'may_reconnect': True},
{'may_reconnect': True, 'plugin': 'tests/plugins/hold_htlcs.py'} {'may_reconnect': True,
'plugin': os.path.join(os.getcwd(), 'tests/plugins/hold_htlcs.py')}
]) ])
i1 = l2.rpc.invoice(msatoshi=1000, label="direct", description="desc")['bolt11'] i1 = l2.rpc.invoice(msatoshi=1000, label="direct", description="desc")['bolt11']
@@ -483,7 +484,8 @@ def test_htlc_accepted_hook_forward_restart(node_factory, executor):
""" """
l1, l2, l3 = node_factory.line_graph(3, opts=[ l1, l2, l3 = node_factory.line_graph(3, opts=[
{'may_reconnect': True}, {'may_reconnect': True},
{'may_reconnect': True, 'plugin': 'tests/plugins/hold_htlcs.py'}, {'may_reconnect': True,
'plugin': os.path.join(os.getcwd(), 'tests/plugins/hold_htlcs.py')},
{'may_reconnect': True}, {'may_reconnect': True},
], wait_for_announce=True) ], wait_for_announce=True)
@@ -512,7 +514,7 @@ def test_htlc_accepted_hook_forward_restart(node_factory, executor):
def test_warning_notification(node_factory): def test_warning_notification(node_factory):
""" test 'warning' notifications """ test 'warning' notifications
""" """
l1 = node_factory.get_node(options={'plugin': 'tests/plugins/pretend_badlog.py'}, allow_broken_log=True) l1 = node_factory.get_node(options={'plugin': os.path.join(os.getcwd(), 'tests/plugins/pretend_badlog.py')}, allow_broken_log=True)
# 1. test 'warn' level # 1. test 'warn' level
event = "Test warning notification(for unusual event)" event = "Test warning notification(for unusual event)"
@@ -544,7 +546,7 @@ def test_invoice_payment_notification(node_factory):
""" """
Test the 'invoice_payment' notification Test the 'invoice_payment' notification
""" """
opts = [{}, {"plugin": "contrib/plugins/helloworld.py"}] opts = [{}, {"plugin": os.path.join(os.getcwd(), "contrib/plugins/helloworld.py")}]
l1, l2 = node_factory.line_graph(2, opts=opts) l1, l2 = node_factory.line_graph(2, opts=opts)
msats = 12345 msats = 12345
@@ -562,7 +564,7 @@ def test_channel_opened_notification(node_factory):
""" """
Test the 'channel_opened' notification sent at channel funding success. Test the 'channel_opened' notification sent at channel funding success.
""" """
opts = [{}, {"plugin": "tests/plugins/misc_notifications.py"}] opts = [{}, {"plugin": os.path.join(os.getcwd(), "tests/plugins/misc_notifications.py")}]
amount = 10**6 amount = 10**6
l1, l2 = node_factory.line_graph(2, fundchannel=True, fundamount=amount, l1, l2 = node_factory.line_graph(2, fundchannel=True, fundamount=amount,
opts=opts) opts=opts)
@@ -580,7 +582,7 @@ def test_forward_event_notification(node_factory, bitcoind, executor):
l1, l2, l3 = node_factory.line_graph(3, opts=[ l1, l2, l3 = node_factory.line_graph(3, opts=[
{}, {},
{'plugin': 'tests/plugins/forward_payment_status.py'}, {'plugin': os.path.join(os.getcwd(), 'tests/plugins/forward_payment_status.py')},
{} {}
], wait_for_announce=True) ], wait_for_announce=True)
l4 = node_factory.get_node() l4 = node_factory.get_node()