Skip to content
This repository was archived by the owner on Jul 10, 2026. It is now read-only.

Commit 3103583

Browse files
committed
fix flaky assert
1 parent 4ec2d37 commit 3103583

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

tests/e2e_tests/test_axon.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import time
33

4+
import netaddr
45
import pytest
56

67
from bittensor.utils import networking
@@ -52,7 +53,6 @@ def test_axon(subtensor, templates, alice_wallet):
5253
# Refresh the metagraph
5354
metagraph = subtensor.metagraphs.metagraph(alice_sn.netuid)
5455
updated_axon = metagraph.axons[0]
55-
external_ip = networking.get_external_ip()
5656

5757
# Assert updated attributes
5858
assert len(metagraph.axons) == 1, (
@@ -63,13 +63,9 @@ def test_axon(subtensor, templates, alice_wallet):
6363
f"Expected 1 neuron, but got {len(metagraph.neurons)}"
6464
)
6565

66-
assert updated_axon.ip == external_ip, (
67-
f"Expected IP {external_ip}, but got {updated_axon.ip}"
68-
)
69-
70-
assert updated_axon.ip_type == networking.ip_version(external_ip), (
71-
f"Expected IP type {networking.ip_version(external_ip)}, but got {updated_axon.ip_type}"
72-
)
66+
assert updated_axon.ip != "0.0.0.0", f"Axon IP was not updated: {updated_axon.ip}"
67+
assert netaddr.IPAddress(updated_axon.ip).is_global()
68+
assert updated_axon.ip_type == networking.ip_version(updated_axon.ip)
7369

7470
assert updated_axon.port == 8091, f"Expected port 8091, but got {updated_axon.port}"
7571

@@ -124,7 +120,6 @@ async def test_axon_async(async_subtensor, templates, alice_wallet):
124120
# Refresh the metagraph
125121
metagraph = await async_subtensor.metagraphs.metagraph(alice_sn.netuid)
126122
updated_axon = metagraph.axons[0]
127-
external_ip = networking.get_external_ip()
128123

129124
# Assert updated attributes
130125
assert len(metagraph.axons) == 1, (
@@ -135,13 +130,9 @@ async def test_axon_async(async_subtensor, templates, alice_wallet):
135130
f"Expected 1 neuron, but got {len(metagraph.neurons)}"
136131
)
137132

138-
assert updated_axon.ip == external_ip, (
139-
f"Expected IP {external_ip}, but got {updated_axon.ip}"
140-
)
141-
142-
assert updated_axon.ip_type == networking.ip_version(external_ip), (
143-
f"Expected IP type {networking.ip_version(external_ip)}, but got {updated_axon.ip_type}"
144-
)
133+
assert updated_axon.ip != "0.0.0.0", f"Axon IP was not updated: {updated_axon.ip}"
134+
assert netaddr.IPAddress(updated_axon.ip).is_global()
135+
assert updated_axon.ip_type == networking.ip_version(updated_axon.ip)
145136

146137
assert updated_axon.port == 8091, f"Expected port 8091, but got {updated_axon.port}"
147138

0 commit comments

Comments
 (0)