-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests/e2e tests staging #1943
Tests/e2e tests staging #1943
Changes from 45 commits
2e7dc06
1229ebb
0eb3ea9
3d5010b
0115dfe
81973e6
6fc3c61
0030051
2cc072f
62b5bb9
6e42709
4e30ef9
273cedc
168cb5f
b030a64
49e8ea0
1c1bef0
0fab75a
6db7eed
5ce8fc1
e98d832
2070fe5
ef6562e
3a7bb39
ca63c9d
0a167c8
6bb5a9b
499214d
f3c9548
1e0b1b2
28abbf3
c0296f0
5c1b2fb
fba8795
a6a05b7
e8ad9c9
17896c3
347288f
afddb48
029c4b6
70169f5
0be6e7d
0d11bfe
4fc7ddc
95f5948
cc6a13c
98e43ff
c56bf7e
9d638a3
b00067b
3f76665
f9555d2
01ade63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from bittensor.commands.root import RootSetBoostCommand, RootSetWeightsCommand | ||
from bittensor.commands.stake import StakeCommand | ||
from bittensor.commands.unstake import UnStakeCommand | ||
from bittensor.commands.network import RegisterSubnetworkCommand | ||
from bittensor.commands.register import RegisterCommand | ||
from ...utils import new_wallet, sudo_call_set_network_limit | ||
import bittensor | ||
|
||
|
||
# we can't test it now since the root network weights can't be set | ||
# Test case to set weights for root network | ||
def test_root_get_set_weights(local_chain, capsys): | ||
(wallet, exec_command) = new_wallet("//Alice", "//Bob") | ||
assert sudo_call_set_network_limit(local_chain, wallet) | ||
|
||
assert not local_chain.query("SubtensorModule", "NetworksAdded", [1]).serialize() | ||
|
||
exec_command(RegisterSubnetworkCommand, ["s", "create"]) | ||
exec_command(RegisterSubnetworkCommand, ["s", "create"]) | ||
exec_command(RegisterSubnetworkCommand, ["s", "create"]) | ||
assert local_chain.query("SubtensorModule", "NetworksAdded", [1]).serialize() | ||
|
||
# assert ( | ||
# local_chain.query("SubtensorModule", "Uids", [1, wallet.hotkey.ss58_address]) | ||
# == None | ||
# ) | ||
|
||
# exec_command(RegisterCommand, ["subnets", "register", "--netuid", "0"]) | ||
|
||
# can not set weights for root network. update needed from python implementation | ||
# netuids = "1,2,4" | ||
# weights = "0.1,0.3,0.6" | ||
# exec_command( | ||
# RootSetWeightsCommand, | ||
# ["root", "weights", "--netuids", netuids, "--weights", weights], | ||
# ) | ||
|
||
# weights = local_chain.query_map( | ||
# "SubtensorModule", "Weights", [wallet.hotkey.ss58_address] | ||
# ) | ||
|
||
# netuid = "1" | ||
# increase = "0.01" | ||
|
||
# exec_command( | ||
# RootSetBoostCommand, | ||
# ["root", "boost", "--netuid", netuid, "--increase", increase], | ||
# ) | ||
|
||
# weights = local_chain.query("SubtensorModule", "Weights", [1]) | ||
# assert weights == 1 | ||
|
||
# captured = capsys.readouterr() | ||
# lines = captured.out.splitlines() | ||
|
||
# for line in lines: | ||
# bittensor.logging.info(line) | ||
|
||
# assert len(lines) == 4 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from bittensor.commands.delegates import ListDelegatesCommand | ||
from bittensor.commands.root import RootRegisterCommand | ||
from bittensor.commands.delegates import SetTakeCommand | ||
from ...utils import new_wallet | ||
|
||
|
||
# delegate seems hard code the network config | ||
def test_root_delegate_list(local_chain, capsys): | ||
(wallet, exec_command) = new_wallet("//Alice", "//Bob") | ||
|
||
# 1200 hardcoded block gap | ||
exec_command( | ||
ListDelegatesCommand, | ||
["root", "list_delegates"], | ||
) | ||
|
||
captured = capsys.readouterr() | ||
lines = captured.out.splitlines() | ||
|
||
# the command print too many lines | ||
assert len(lines) > 200 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
from bittensor.commands.delegates import DelegateStakeCommand, DelegateUnstakeCommand | ||
from bittensor.commands.stake import StakeCommand | ||
from bittensor.commands.delegates import SetTakeCommand | ||
from bittensor.commands.network import RegisterSubnetworkCommand | ||
from bittensor.commands.register import RegisterCommand | ||
|
||
from ...utils import ( | ||
new_wallet, | ||
call_add_proposal, | ||
sudo_call_set_network_limit, | ||
sudo_call_set_target_stakes_per_interval, | ||
) | ||
|
||
|
||
# delegate seems hard code the network config | ||
def test_root_delegate_stake(local_chain, capsys): | ||
(wallet, exec_command) = new_wallet("//Alice", "//Bob") | ||
|
||
stakes = local_chain.query( | ||
"SubtensorModule", | ||
"Stake", | ||
[wallet.hotkey.ss58_address, wallet.coldkey.ss58_address], | ||
) | ||
assert stakes == 0 | ||
|
||
assert sudo_call_set_network_limit(local_chain, wallet) | ||
assert sudo_call_set_target_stakes_per_interval(local_chain, wallet) | ||
|
||
exec_command(RegisterSubnetworkCommand, ["s", "create"]) | ||
exec_command(RegisterCommand, ["s", "register", "--neduid", "1"]) | ||
|
||
stake_amount = 2 | ||
exec_command(StakeCommand, ["stake", "add", "--amount", str(stake_amount)]) | ||
|
||
stakes = local_chain.query( | ||
"SubtensorModule", | ||
"Stake", | ||
[wallet.hotkey.ss58_address, wallet.coldkey.ss58_address], | ||
) | ||
|
||
assert stakes > 1_000_000_000 | ||
|
||
delegates = local_chain.query( | ||
"SubtensorModule", | ||
"Delegates", | ||
[wallet.hotkey.ss58_address], | ||
) | ||
|
||
assert delegates == 11796 | ||
|
||
# stake 1 TAO | ||
# exec_command( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of these commented out blocks? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to add and reduce stake There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand, but the code is commented out... Meaning the test doesn't actually add or reduce stake, and test that stake is added or reduced. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, will just keep it in my local branch |
||
# DelegateStakeCommand, | ||
# [ | ||
# "root", | ||
# "delegate", | ||
# "--delegate_ss58key", | ||
# wallet.hotkey.ss58_address, | ||
# "--amount", | ||
# "1", | ||
# ], | ||
# ) | ||
|
||
# new_stakes = local_chain.query( | ||
# "SubtensorModule", | ||
# "Stake", | ||
# [wallet.hotkey.ss58_address, wallet.coldkey.ss58_address], | ||
# ) | ||
|
||
# tolerance = 10000 | ||
|
||
# assert ( | ||
# stakes.serialize() + 1_000_000_000 - tolerance | ||
# < new_stakes.serialize() | ||
# < stakes.serialize() + 1_000_000_000 + tolerance | ||
# ) | ||
|
||
# unstake 1 TAO | ||
# exec_command( | ||
# DelegateUnstakeCommand, | ||
# [ | ||
# "root", | ||
# "delegate", | ||
# "--delegate_ss58key", | ||
# wallet.hotkey.ss58_address, | ||
# "--amount", | ||
# "1", | ||
# ], | ||
# ) | ||
|
||
# stakes = local_chain.query( | ||
# "SubtensorModule", | ||
# "Stake", | ||
# [wallet.hotkey.ss58_address, wallet.coldkey.ss58_address], | ||
# ) | ||
|
||
# assert ( | ||
# stakes.serialize() + 1_000_000_000 - tolerance | ||
# < new_stakes.serialize() | ||
# < stakes.serialize() + 1_000_000_000 + tolerance | ||
# ) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from bittensor.commands.root import RootSetWeightsCommand, RootGetWeightsCommand | ||
from bittensor.commands.network import RegisterSubnetworkCommand | ||
from ...utils import new_wallet, sudo_call_set_network_limit | ||
|
||
|
||
# we can't test it now since the root network weights can't be set | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this test run correctly? Maybe we write this test when the command is updated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The extrinsic in subtensor side is updated. From @distributedstatemachine , I know cortex team will change accordingly. |
||
# Test case to set weights for root network and get the weights | ||
def test_root_get_set_weights(local_chain, capsys): | ||
(wallet, exec_command) = new_wallet("//Alice", "//Bob") | ||
assert sudo_call_set_network_limit(local_chain, wallet) | ||
assert not local_chain.query("SubtensorModule", "NetworksAdded", [1]).serialize() | ||
|
||
exec_command(RegisterSubnetworkCommand, ["s", "create"]) | ||
exec_command(RegisterSubnetworkCommand, ["s", "create"]) | ||
exec_command(RegisterSubnetworkCommand, ["s", "create"]) | ||
|
||
assert local_chain.query("SubtensorModule", "NetworksAdded", [1]).serialize() | ||
assert local_chain.query("SubtensorModule", "NetworksAdded", [2]).serialize() | ||
assert local_chain.query("SubtensorModule", "NetworksAdded", [4]).serialize() | ||
|
||
netuids = "1,2,4" | ||
weights = "0.1,0.3,0.6" | ||
|
||
# this command need update, should set the netuid. subtensor not accept the weight set for root network | ||
exec_command( | ||
RootSetWeightsCommand, | ||
["root", "weights", "--netuids", netuids, "--weights", weights], | ||
) | ||
|
||
weights = local_chain.query("SubtensorModule", "Weights", [1, 0]) | ||
|
||
exec_command( | ||
RootGetWeightsCommand, | ||
["root", "get_weights"], | ||
) | ||
|
||
captured = capsys.readouterr() | ||
lines = captured.out.splitlines() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from bittensor.commands.root import RootList | ||
from ...utils import new_wallet | ||
from bittensor.commands.network import RegisterSubnetworkCommand | ||
import bittensor | ||
|
||
|
||
# test case to list the root network | ||
def test_root_list(local_chain, capsys): | ||
(wallet, exec_command) = new_wallet("//Alice", "//Bob") | ||
|
||
exec_command(RootList, ["root", "list"]) | ||
captured = capsys.readouterr() | ||
lines = captured.out.split("\n") | ||
|
||
assert len(lines) >= 4 | ||
bittensor.logging.info(lines) | ||
|
||
# assert "Root Network" in lines[0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these lines commented out? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I mentioned in the description, we always get the extra output about bittensor version. so just commented out, can add them back after version is aligned. |
||
# assert "UID NAME ADDRESS STAKE" in lines[1] | ||
|
||
exec_command(RegisterSubnetworkCommand, ["s", "create"]) | ||
|
||
exec_command(RootList, ["root", "list"]) | ||
captured = capsys.readouterr() | ||
lines = captured.out.splitlines() | ||
|
||
assert len(lines) >= 4 | ||
# assert "Root Network" in lines[0] | ||
# assert "UID NAME ADDRESS STAKE" in lines[1] | ||
# assert "1" in lines[2] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from bittensor.commands.delegates import NominateCommand | ||
from bittensor.commands.stake import StakeCommand | ||
from bittensor.commands.delegates import SetTakeCommand | ||
from bittensor.commands.network import RegisterSubnetworkCommand | ||
from bittensor.commands.register import RegisterCommand | ||
|
||
from ...utils import ( | ||
new_wallet, | ||
call_add_proposal, | ||
sudo_call_set_network_limit, | ||
sudo_call_set_target_stakes_per_interval, | ||
) | ||
|
||
|
||
# delegate seems hard code the network config | ||
def test_root_nominate(local_chain, capsys): | ||
(wallet, exec_command) = new_wallet("//Alice", "//Bob") | ||
|
||
delegates = local_chain.query( | ||
"SubtensorModule", | ||
"Delegates", | ||
[wallet.hotkey.ss58_address], | ||
) | ||
|
||
assert delegates == 11796 | ||
|
||
assert sudo_call_set_network_limit(local_chain, wallet) | ||
assert sudo_call_set_target_stakes_per_interval(local_chain, wallet) | ||
|
||
exec_command(RegisterSubnetworkCommand, ["s", "create"]) | ||
exec_command(RegisterCommand, ["s", "register", "--neduid", "1"]) | ||
|
||
exec_command( | ||
NominateCommand, | ||
[ | ||
"root", | ||
"nominate", | ||
], | ||
) | ||
|
||
delegates = local_chain.query( | ||
"SubtensorModule", | ||
"Delegates", | ||
[wallet.hotkey.ss58_address], | ||
) | ||
|
||
assert delegates == 11796 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we cant test this right now, should we remove it until we can properly test it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls keep it in the repo. I need some time to try, then know what's the correct parameter and how to check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you keep this in a separate branch? There is no need to push this in while its still under development and not ready to go out to the public. Every test we run on the Bittensor side actually tests what it is supposed to test. This will add tests that don't actually test what they claim to test, and we will be required to "remember" that X or Y test is incomplete, giving us holes in what bugs and issues can go unnoticed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will remove it.