Skip to content
Open
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
47 changes: 35 additions & 12 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4815,31 +4815,54 @@ def test_networkevents(node_factory, executor):
'reason': f'All addresses failed: 127.0.0.1:{l1.port}: Cryptographic handshake: peer closed connection (wrong key?). '}]

# Connect failed because no listener
with pytest.raises(RpcError, match="Connection establishment: Connection refused."):
with pytest.raises(
RpcError,
match=r"Connection establishment: (Connection refused|Bad file descriptor)."):
l1.rpc.connect(l2.info['id'], 'localhost', 1)

nevents = l1.rpc.listnetworkevents(start=5)['networkevents']
del only_one(nevents)['timestamp']
del only_one(nevents)['duration_nsec']

assert nevents == [{'created_index': 5,
'peer_id': l2.info['id'],
'type': 'connect_fail',
'connect_attempted': True,
'reason': f'All addresses failed: 127.0.0.1:1: Connection establishment: Connection refused. '}]
assert len(nevents) == 1

event = only_one(nevents)

assert event['created_index'] == 5
assert event['peer_id'] == l2.info['id']
assert event['type'] == 'connect_fail'
assert event['connect_attempted'] is True

assert re.search(
r"All addresses failed: 127\.0\.0\.1:1: Connection establishment: "
r"(Connection refused|Bad file descriptor)\. ",
event['reason']
)

# Connect failed because unreachable
with pytest.raises(RpcError, match="Connection establishment: Connection timed out."):
with pytest.raises(
RpcError,
match=r"Connection establishment: (Connection timed out|Bad file descriptor)."):
l1.rpc.connect(l2.info['id'], '1.1.1.1', 8081)

nevents = l1.rpc.listnetworkevents(start=6)['networkevents']
del only_one(nevents)['timestamp']
del only_one(nevents)['duration_nsec']

assert nevents == [{'created_index': 6,
'peer_id': l2.info['id'],
'type': 'connect_fail',
'connect_attempted': True,
'reason': f'All addresses failed: 1.1.1.1:8081: Connection establishment: Connection timed out. '}]
assert len(nevents) == 1

event = only_one(nevents)

assert event['created_index'] == 6
assert event['peer_id'] == l2.info['id']
assert event['type'] == 'connect_fail'
assert event['connect_attempted'] is True

assert re.search(
r"All addresses failed: 1\.1\.1\.1:8081: Connection establishment: "
r"(Connection timed out|Bad file descriptor)\. ",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After applying patch: rustyrussell/ccan#128

This error becomes "Connection establishment: Operation timed out" on mac, so the test should become

(Connection timed out|Operation timed out)

event['reason']
)
# Connect failed because it doesn't advertize any addresses.
with pytest.raises(RpcError, match="Unable to connect, no address known for peer"):
l2.rpc.connect(l1.info['id'])
Expand Down