elo-node 0.4.7__tar.gz → 0.4.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {elo_node-0.4.7 → elo_node-0.4.8}/PKG-INFO +1 -1
- {elo_node-0.4.7 → elo_node-0.4.8}/elo/__init__.py +1 -1
- {elo_node-0.4.7 → elo_node-0.4.8}/elo/node.py +11 -15
- {elo_node-0.4.7 → elo_node-0.4.8}/elo_node.egg-info/PKG-INFO +1 -1
- {elo_node-0.4.7 → elo_node-0.4.8}/pyproject.toml +1 -1
- {elo_node-0.4.7 → elo_node-0.4.8}/tests/test_unit.py +14 -1
- {elo_node-0.4.7 → elo_node-0.4.8}/README.md +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo/__main__.py +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo/security.py +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo/transport/__init__.py +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo/transport/protocol.py +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo/transport/routing.py +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo/transport/tcp.py +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo/transport/tracker.py +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo/types.py +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo_node.egg-info/SOURCES.txt +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo_node.egg-info/dependency_links.txt +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo_node.egg-info/entry_points.txt +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo_node.egg-info/requires.txt +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/elo_node.egg-info/top_level.txt +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/setup.cfg +0 -0
- {elo_node-0.4.7 → elo_node-0.4.8}/tests/test_security.py +0 -0
|
@@ -78,7 +78,7 @@ class Node:
|
|
|
78
78
|
peers: list[str] | None = None,
|
|
79
79
|
tracker: str = "public",
|
|
80
80
|
allowlist: list[str] | None = None,
|
|
81
|
-
version: str = "0.4.
|
|
81
|
+
version: str = "0.4.8",
|
|
82
82
|
identity: EphemeralIdentity | None = None,
|
|
83
83
|
verify_peers: bool = True,
|
|
84
84
|
heartbeat_interval_s: int = 30,
|
|
@@ -247,17 +247,17 @@ class Node:
|
|
|
247
247
|
if addr.startswith(target_node[:12] + "@"):
|
|
248
248
|
peer = addr
|
|
249
249
|
break
|
|
250
|
-
|
|
250
|
+
if not peer:
|
|
251
|
+
# Bug fix: target_node especificado mas offline —
|
|
252
|
+
# NÃO fazer find_peer_for(capability) que acharia o tracker.
|
|
253
|
+
# Vai direto pra relay-via-tracker.
|
|
254
|
+
return await self.send_task_via_tracker(
|
|
255
|
+
"", target_node, capability, payload, ttl_s=ttl_s
|
|
256
|
+
)
|
|
257
|
+
else:
|
|
251
258
|
peer = self._routing.find_peer_for(capability)
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if not peer:
|
|
255
|
-
peer = await self._query_capability(capability, ttl=5, timeout=5)
|
|
256
|
-
if peer:
|
|
257
|
-
hello = hello_msg(self._node_id, self._tracker.get_public_caps(),
|
|
258
|
-
list(self._routing.local_interests),
|
|
259
|
-
self._tracker.visibility, self._version)
|
|
260
|
-
peer = await self._tcp.connect_to_peer(peer, hello_payload=hello)
|
|
259
|
+
if not peer:
|
|
260
|
+
peer = await self._query_capability(capability, ttl=5, timeout=5)
|
|
261
261
|
|
|
262
262
|
if peer:
|
|
263
263
|
try:
|
|
@@ -266,10 +266,6 @@ class Node:
|
|
|
266
266
|
except Exception as e:
|
|
267
267
|
return Result.make_error(task_id, "SEND_ERROR", str(e))
|
|
268
268
|
|
|
269
|
-
# Bug 2: Fallback via tracker antes de desistir
|
|
270
|
-
if not peer:
|
|
271
|
-
return await self.send_task_via_tracker("", target_node, capability, payload, ttl_s=ttl_s)
|
|
272
|
-
|
|
273
269
|
return Result.make_error(task_id, "NO_PEER", f"No peer for: {capability}")
|
|
274
270
|
|
|
275
271
|
async def send_task_async(self, target_node: str, capability: str,
|
|
@@ -136,7 +136,7 @@ class TestNodeConstruction:
|
|
|
136
136
|
node = Node("test-node")
|
|
137
137
|
assert node._name == "test-node"
|
|
138
138
|
assert node._port == 7878
|
|
139
|
-
assert node._version == "0.4.
|
|
139
|
+
assert node._version == "0.4.8"
|
|
140
140
|
assert node.connected is False
|
|
141
141
|
assert node.node_id is not None
|
|
142
142
|
assert len(node.node_id) > 20
|
|
@@ -148,6 +148,19 @@ class TestNodeConstruction:
|
|
|
148
148
|
assert node._port == 9000
|
|
149
149
|
assert node.tracker_visibility == "private"
|
|
150
150
|
|
|
151
|
+
@pytest.mark.asyncio
|
|
152
|
+
async def test_send_task_to_offline_target_returns_error(self):
|
|
153
|
+
"""send_task with offline target_node must return error, not route to tracker."""
|
|
154
|
+
node = Node("test-a", port=0)
|
|
155
|
+
await node.connect()
|
|
156
|
+
await node.register(agents=["echo"])
|
|
157
|
+
|
|
158
|
+
# Target node_id that won't match any connected peer address
|
|
159
|
+
result = await node.send_task("nonexistent-node-id-42", "echo", {"msg": "hello"})
|
|
160
|
+
|
|
161
|
+
assert result.status == "error"
|
|
162
|
+
await node.disconnect()
|
|
163
|
+
|
|
151
164
|
|
|
152
165
|
# ── TestNodeLifecycle ──────────────────────────────────────
|
|
153
166
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|