Skip to content

Commit 630dda1

Browse files
author
Roman
committed
add one more e2e test for get_metagraph_info with field_indices argument
1 parent 0bc61a5 commit 630dda1

File tree

1 file changed

+229
-0
lines changed

1 file changed

+229
-0
lines changed

tests/e2e_tests/test_metagraph.py

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import time
55

66
from bittensor.core.chain_data.metagraph_info import MetagraphInfo
7+
from bittensor.core.chain_data import SelectiveMetagraphIndex
78
from bittensor.utils.balance import Balance
89
from bittensor.utils.btlogging import logging
910
from tests.e2e_tests.utils.e2e_test_utils import wait_to_start_call
@@ -434,6 +435,234 @@ def test_metagraph_info(subtensor, alice_wallet, bob_wallet):
434435
assert metagraph_info is None
435436

436437

438+
def test_metagraph_info_with_indexes(subtensor, alice_wallet, bob_wallet):
439+
"""
440+
Tests:
441+
- Check MetagraphInfo
442+
- Register Neuron
443+
- Register Subnet
444+
- Check MetagraphInfo is updated
445+
"""
446+
447+
alice_subnet_netuid = subtensor.get_total_subnets() # 2
448+
subtensor.register_subnet(alice_wallet, True, True)
449+
450+
field_indices = [
451+
SelectiveMetagraphIndex.Name,
452+
SelectiveMetagraphIndex.Active,
453+
SelectiveMetagraphIndex.OwnerHotkey,
454+
SelectiveMetagraphIndex.OwnerColdkey,
455+
SelectiveMetagraphIndex.Axons,
456+
]
457+
458+
metagraph_info = subtensor.get_metagraph_info(
459+
netuid=alice_subnet_netuid, field_indices=field_indices
460+
)
461+
462+
assert metagraph_info == MetagraphInfo(
463+
netuid=alice_subnet_netuid,
464+
name="omron",
465+
owner_hotkey=alice_wallet.hotkey.ss58_address,
466+
owner_coldkey=alice_wallet.coldkey.ss58_address,
467+
active=(True,),
468+
axons=(
469+
{
470+
"block": 0,
471+
"ip": 0,
472+
"ip_type": 0,
473+
"placeholder1": 0,
474+
"placeholder2": 0,
475+
"port": 0,
476+
"protocol": 0,
477+
"version": 0,
478+
},
479+
),
480+
symbol=None,
481+
identity=None,
482+
network_registered_at=None,
483+
block=None,
484+
tempo=None,
485+
last_step=None,
486+
blocks_since_last_step=None,
487+
subnet_emission=None,
488+
alpha_in=None,
489+
alpha_out=None,
490+
tao_in=None,
491+
alpha_out_emission=None,
492+
alpha_in_emission=None,
493+
tao_in_emission=None,
494+
pending_alpha_emission=None,
495+
pending_root_emission=None,
496+
subnet_volume=None,
497+
moving_price=None,
498+
rho=None,
499+
kappa=None,
500+
min_allowed_weights=None,
501+
max_weights_limit=None,
502+
weights_version=None,
503+
weights_rate_limit=None,
504+
activity_cutoff=None,
505+
max_validators=None,
506+
num_uids=None,
507+
max_uids=None,
508+
burn=None,
509+
difficulty=None,
510+
registration_allowed=None,
511+
pow_registration_allowed=None,
512+
immunity_period=None,
513+
min_difficulty=None,
514+
max_difficulty=None,
515+
min_burn=None,
516+
max_burn=None,
517+
adjustment_alpha=None,
518+
adjustment_interval=None,
519+
target_regs_per_interval=None,
520+
max_regs_per_block=None,
521+
serving_rate_limit=None,
522+
commit_reveal_weights_enabled=None,
523+
commit_reveal_period=None,
524+
liquid_alpha_enabled=None,
525+
alpha_high=None,
526+
alpha_low=None,
527+
bonds_moving_avg=None,
528+
hotkeys=None,
529+
coldkeys=None,
530+
identities=None,
531+
validator_permit=None,
532+
pruning_score=None,
533+
last_update=None,
534+
emission=None,
535+
dividends=None,
536+
incentives=None,
537+
consensus=None,
538+
trust=None,
539+
rank=None,
540+
block_at_registration=None,
541+
alpha_stake=None,
542+
tao_stake=None,
543+
total_stake=None,
544+
tao_dividends_per_hotkey=None,
545+
alpha_dividends_per_hotkey=None,
546+
)
547+
548+
assert wait_to_start_call(subtensor, alice_wallet, alice_subnet_netuid)
549+
550+
assert subtensor.burned_register(
551+
bob_wallet,
552+
netuid=alice_subnet_netuid,
553+
wait_for_inclusion=True,
554+
wait_for_finalization=True,
555+
)
556+
557+
fields = [
558+
SelectiveMetagraphIndex.Name,
559+
SelectiveMetagraphIndex.Active,
560+
SelectiveMetagraphIndex.OwnerHotkey,
561+
SelectiveMetagraphIndex.OwnerColdkey,
562+
SelectiveMetagraphIndex.Axons,
563+
]
564+
565+
metagraph_info = subtensor.get_metagraph_info(
566+
netuid=alice_subnet_netuid, field_indices=fields
567+
)
568+
569+
assert metagraph_info == MetagraphInfo(
570+
netuid=alice_subnet_netuid,
571+
name="omron",
572+
owner_hotkey=alice_wallet.hotkey.ss58_address,
573+
owner_coldkey=alice_wallet.coldkey.ss58_address,
574+
active=(True, True),
575+
axons=(
576+
{
577+
"block": 0,
578+
"ip": 0,
579+
"ip_type": 0,
580+
"placeholder1": 0,
581+
"placeholder2": 0,
582+
"port": 0,
583+
"protocol": 0,
584+
"version": 0,
585+
},
586+
{
587+
"block": 0,
588+
"ip": 0,
589+
"ip_type": 0,
590+
"placeholder1": 0,
591+
"placeholder2": 0,
592+
"port": 0,
593+
"protocol": 0,
594+
"version": 0,
595+
},
596+
),
597+
symbol=None,
598+
identity=None,
599+
network_registered_at=None,
600+
block=None,
601+
tempo=None,
602+
last_step=None,
603+
blocks_since_last_step=None,
604+
subnet_emission=None,
605+
alpha_in=None,
606+
alpha_out=None,
607+
tao_in=None,
608+
alpha_out_emission=None,
609+
alpha_in_emission=None,
610+
tao_in_emission=None,
611+
pending_alpha_emission=None,
612+
pending_root_emission=None,
613+
subnet_volume=None,
614+
moving_price=None,
615+
rho=None,
616+
kappa=None,
617+
min_allowed_weights=None,
618+
max_weights_limit=None,
619+
weights_version=None,
620+
weights_rate_limit=None,
621+
activity_cutoff=None,
622+
max_validators=None,
623+
num_uids=None,
624+
max_uids=None,
625+
burn=None,
626+
difficulty=None,
627+
registration_allowed=None,
628+
pow_registration_allowed=None,
629+
immunity_period=None,
630+
min_difficulty=None,
631+
max_difficulty=None,
632+
min_burn=None,
633+
max_burn=None,
634+
adjustment_alpha=None,
635+
adjustment_interval=None,
636+
target_regs_per_interval=None,
637+
max_regs_per_block=None,
638+
serving_rate_limit=None,
639+
commit_reveal_weights_enabled=None,
640+
commit_reveal_period=None,
641+
liquid_alpha_enabled=None,
642+
alpha_high=None,
643+
alpha_low=None,
644+
bonds_moving_avg=None,
645+
hotkeys=None,
646+
coldkeys=None,
647+
identities=None,
648+
validator_permit=None,
649+
pruning_score=None,
650+
last_update=None,
651+
emission=None,
652+
dividends=None,
653+
incentives=None,
654+
consensus=None,
655+
trust=None,
656+
rank=None,
657+
block_at_registration=None,
658+
alpha_stake=None,
659+
tao_stake=None,
660+
total_stake=None,
661+
tao_dividends_per_hotkey=None,
662+
alpha_dividends_per_hotkey=None,
663+
)
664+
665+
437666
def test_blocks(subtensor):
438667
"""
439668
Tests:

0 commit comments

Comments
 (0)