Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def __init__(self, *args, **kwargs):
kwargs["executable"] = "lightningd/lightningd"
utils.LightningNode.__init__(self, *args, **kwargs)

# Avoid socket path name too long on Linux
if os.uname()[0] == 'Linux' and \
len(str(self.lightning_dir / TEST_NETWORK / 'lightning-rpc')) >= 108:
self.daemon.opts['rpc-file'] = '/proc/self/cwd/lightning-rpc'

# This is a recent innovation, and we don't want to nail pyln-testing to this version.
self.daemon.opts['dev-crash-after'] = 3600

Expand Down
2 changes: 2 additions & 0 deletions tests/test_cln_rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def test_rpc_client(node_factory):
l1 = node_factory.get_node()
bin_path = Path.cwd() / "target" / RUST_PROFILE / "examples" / "cln-rpc-getinfo"
rpc_path = Path(l1.daemon.lightning_dir) / TEST_NETWORK / "lightning-rpc"
if len(str(rpc_path)) >= 108 and os.uname()[0] == 'Linux':
rpc_path = Path('/proc/self/cwd') / os.path.relpath(rpc_path)
out = subprocess.check_output([bin_path, rpc_path], stderr=subprocess.STDOUT)
assert(b'0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518' in out)

Expand Down
29 changes: 20 additions & 9 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,12 @@ def test_address(node_factory):

# Now test UNIX domain binding
l1.stop()
l1.daemon.opts['bind-addr'] = os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, "sock")
bind_addr = os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, "sock")
if len(bind_addr) >= 108 and os.uname()[0] == "Linux":
bind_addr = os.path.join('/proc/self/cwd',
os.path.relpath(node_factory.directory, os.path.dirname(bind_addr)),
os.path.relpath(bind_addr, node_factory.directory))
l1.daemon.opts['bind-addr'] = bind_addr
l1.start()

# Test dev-allow-localhost
Expand Down Expand Up @@ -874,12 +879,21 @@ def test_listconfigs_plugins(node_factory, bitcoind, chainparams):
assert [p['active'] for p in plugins if p['name'].endswith('offers')] == [True]


def connect_unix(socket_path: str):
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
sock.connect(socket_path)
except OSError as err:
if err.args[0] == 'AF_UNIX path too long' and os.uname()[0] == 'Linux':
sock.connect(os.path.join('/proc/self/cwd', os.path.relpath(socket_path)))
return sock


def test_multirpc(node_factory):
"""Test that we can do multiple RPC without waiting for response"""
l1 = node_factory.get_node()

sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(l1.rpc.socket_path)
sock = connect_unix(l1.rpc.socket_path)

commands = [
b'{"id":1,"jsonrpc":"2.0","method":"listpeers","params":[]}',
Expand All @@ -905,8 +919,7 @@ def test_multiplexed_rpc(node_factory):
"""Test that we can do multiple RPCs which exit in different orders"""
l1 = node_factory.get_node()

sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(l1.rpc.socket_path)
sock = connect_unix(l1.rpc.socket_path)

# Neighbouring ones may be in or out of order.
commands = [
Expand Down Expand Up @@ -936,8 +949,7 @@ def test_malformed_rpc(node_factory):
"""Test that we get a correct response to malformed RPC commands"""
l1 = node_factory.get_node()

sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(l1.rpc.socket_path)
sock = connect_unix(l1.rpc.socket_path)

# No ID
sock.sendall(b'{"jsonrpc":"2.0","method":"getinfo","params":[]}')
Expand Down Expand Up @@ -2023,8 +2035,7 @@ def test_check_command(node_factory):
host='x', port="abcd")

# FIXME: python wrapper doesn't let us test array params.
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(l1.rpc.socket_path)
sock = connect_unix(l1.rpc.socket_path)

sock.sendall(b'{"id":1, "jsonrpc":"2.0","method":"check","params":["help"]}')
obj, _ = l1.rpc._readobj(sock, b'')
Expand Down
Loading