Skip to content
Merged
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
2 changes: 1 addition & 1 deletion openvalidators/dendrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def resync(self, metagraph: "bt.metagraph.Metagraph"):
for index, dendrite in enumerate(self.dendrites):
current_uid_axon_info = metagraph_uids_axons_state.pop(dendrite.uid)

if dendrite.axon_info.hotkey != current_uid_axon_info.hotkey:
if dendrite.axon_info != current_uid_axon_info:
self.dendrites[index] = bt.text_prompting(
axon=current_uid_axon_info,
keypair=dendrite.keypair,
Expand Down
14 changes: 12 additions & 2 deletions tests/test_dendrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,32 @@ def setUp(self):
mock_metagraph = MagicMock(spec=bt.metagraph)
mock_metagraph.uids = torch.tensor(range(0, 1024))
mock_metagraph.axons = [
MagicMock(spec=bt.axon_info, hotkey=str(num), ip="0.0.0.0/0", port=12345) for num in range(0, 1024)
bt.axon_info(
version=0,
ip="0.0.0.0/0",
port=12345,
ip_type=0,
hotkey=str(num),
coldkey=str(num)
) for num in range(0, 1024)
]

self.metagraph = mock_metagraph
self.keypair = "test"

def test_resync_uid_change(self):
def test_resync_uid_modified_metagraph(self):
# Arrange: Creates Async dendrite pool and modifies the metagraph by changing the axon_info at defined index
dendrite_pool = AsyncDendritePool(keypair=self.keypair, metagraph=self.metagraph)

# Modify the hotkey of the first axon of the metagraph
index = 0
modified_metagraph = copy.deepcopy(self.metagraph)
modified_metagraph.axons[index].hotkey = "hotkey-test"

# Act: Resync the dendrite pool with the modified metagraph
dendrite_pool.resync(modified_metagraph)

# Assert: The dendrite pool hotkeys should be the same as the modified metagraph hotkeys after resync
dendrite_hot_keys = list(map(lambda dendrite: dendrite.axon_info.hotkey, dendrite_pool.dendrites))
new_metagraph_hot_keys = list(map(lambda axon: axon.hotkey, modified_metagraph.axons))

Expand Down