@@ -818,7 +818,12 @@ def test_address(node_factory):
818
818
819
819
# Now test UNIX domain binding
820
820
l1 .stop ()
821
- l1 .daemon .opts ['bind-addr' ] = os .path .join (l1 .daemon .lightning_dir , TEST_NETWORK , "sock" )
821
+ bind_addr = os .path .join (l1 .daemon .lightning_dir , TEST_NETWORK , "sock" )
822
+ if len (bind_addr ) >= 108 and os .uname ()[0 ] == "Linux" :
823
+ bind_addr = os .path .join ('/proc/self/cwd' ,
824
+ os .path .relpath (node_factory .directory , os .path .dirname (bind_addr )),
825
+ os .path .relpath (bind_addr , node_factory .directory ))
826
+ l1 .daemon .opts ['bind-addr' ] = bind_addr
822
827
l1 .start ()
823
828
824
829
# Test dev-allow-localhost
@@ -874,12 +879,21 @@ def test_listconfigs_plugins(node_factory, bitcoind, chainparams):
874
879
assert [p ['active' ] for p in plugins if p ['name' ].endswith ('offers' )] == [True ]
875
880
876
881
882
+ def connect_unix (socket_path : str ):
883
+ sock = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
884
+ try :
885
+ sock .connect (socket_path )
886
+ except OSError as err :
887
+ if err .args [0 ] == 'AF_UNIX path too long' and os .uname ()[0 ] == 'Linux' :
888
+ sock .connect (os .path .join ('/proc/self/cwd' , os .path .relpath (socket_path )))
889
+ return sock
890
+
891
+
877
892
def test_multirpc (node_factory ):
878
893
"""Test that we can do multiple RPC without waiting for response"""
879
894
l1 = node_factory .get_node ()
880
895
881
- sock = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
882
- sock .connect (l1 .rpc .socket_path )
896
+ sock = connect_unix (l1 .rpc .socket_path )
883
897
884
898
commands = [
885
899
b'{"id":1,"jsonrpc":"2.0","method":"listpeers","params":[]}' ,
@@ -905,8 +919,7 @@ def test_multiplexed_rpc(node_factory):
905
919
"""Test that we can do multiple RPCs which exit in different orders"""
906
920
l1 = node_factory .get_node ()
907
921
908
- sock = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
909
- sock .connect (l1 .rpc .socket_path )
922
+ sock = connect_unix (l1 .rpc .socket_path )
910
923
911
924
# Neighbouring ones may be in or out of order.
912
925
commands = [
@@ -936,8 +949,7 @@ def test_malformed_rpc(node_factory):
936
949
"""Test that we get a correct response to malformed RPC commands"""
937
950
l1 = node_factory .get_node ()
938
951
939
- sock = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
940
- sock .connect (l1 .rpc .socket_path )
952
+ sock = connect_unix (l1 .rpc .socket_path )
941
953
942
954
# No ID
943
955
sock .sendall (b'{"jsonrpc":"2.0","method":"getinfo","params":[]}' )
@@ -2023,8 +2035,7 @@ def test_check_command(node_factory):
2023
2035
host = 'x' , port = "abcd" )
2024
2036
2025
2037
# FIXME: python wrapper doesn't let us test array params.
2026
- sock = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
2027
- sock .connect (l1 .rpc .socket_path )
2038
+ sock = connect_unix (l1 .rpc .socket_path )
2028
2039
2029
2040
sock .sendall (b'{"id":1, "jsonrpc":"2.0","method":"check","params":["help"]}' )
2030
2041
obj , _ = l1 .rpc ._readobj (sock , b'' )
0 commit comments