Skip to content

Commit 5b37b44

Browse files
author
Roman
committed
fix and improve test
1 parent 8ac6605 commit 5b37b44

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

tests/e2e_tests/test_stake_fee.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async def test_stake_fee_api(local_chain, subtensor, alice_wallet, bob_wallet):
1919
netuid = 2
2020
root_netuid = 0
2121
stake_amount = Balance.from_tao(100) # 100 TAO
22-
min_stake_fee = Balance.from_rao(50_000)
22+
min_stake_fee = Balance.from_tao(0.299076829)
2323

2424
# Register subnet as Alice
2525
assert subtensor.register_subnet(alice_wallet), "Unable to register the subnet"
@@ -33,21 +33,19 @@ async def test_stake_fee_api(local_chain, subtensor, alice_wallet, bob_wallet):
3333
hotkey_ss58=alice_wallet.hotkey.ss58_address,
3434
)
3535
assert isinstance(stake_fee_0, Balance), "Stake fee should be a Balance object"
36-
assert stake_fee_0 >= min_stake_fee, (
36+
assert stake_fee_0 == min_stake_fee, (
3737
"Stake fee should be greater than the minimum stake fee"
3838
)
3939

4040
# Test unstake fee
41-
stake_fee_1 = subtensor.get_unstake_fee(
41+
unstake_fee_root = subtensor.get_unstake_fee(
4242
amount=stake_amount,
4343
netuid=root_netuid,
4444
coldkey_ss58=alice_wallet.coldkeypub.ss58_address,
4545
hotkey_ss58=bob_wallet.hotkey.ss58_address,
4646
)
47-
assert isinstance(stake_fee_1, Balance), "Stake fee should be a Balance object"
48-
assert stake_fee_1 >= min_stake_fee, (
49-
"Stake fee should be greater than the minimum stake fee"
50-
)
47+
assert isinstance(unstake_fee_root, Balance), "Stake fee should be a Balance object"
48+
assert unstake_fee_root == 0, "Root unstake fee should be 0."
5149

5250
# Test various stake movement scenarios
5351
movement_scenarios = [
@@ -59,6 +57,7 @@ async def test_stake_fee_api(local_chain, subtensor, alice_wallet, bob_wallet):
5957
"dest_netuid": netuid,
6058
"dest_hotkey": alice_wallet.hotkey.ss58_address,
6159
"dest_coldkey": alice_wallet.coldkeypub.ss58_address,
60+
"stake_fee": min_stake_fee,
6261
},
6362
# Move between hotkeys on root
6463
{
@@ -68,15 +67,27 @@ async def test_stake_fee_api(local_chain, subtensor, alice_wallet, bob_wallet):
6867
"dest_netuid": root_netuid,
6968
"dest_hotkey": bob_wallet.hotkey.ss58_address,
7069
"dest_coldkey": alice_wallet.coldkeypub.ss58_address,
70+
"stake_fee": 0,
7171
},
72-
# Move between coldkeys
72+
# Move between coldkeys on root
7373
{
7474
"origin_netuid": root_netuid,
7575
"origin_hotkey": bob_wallet.hotkey.ss58_address,
7676
"origin_coldkey": alice_wallet.coldkeypub.ss58_address,
7777
"dest_netuid": root_netuid,
7878
"dest_hotkey": bob_wallet.hotkey.ss58_address,
7979
"dest_coldkey": bob_wallet.coldkeypub.ss58_address,
80+
"stake_fee": 0,
81+
},
82+
# Move between coldkeys on non-root
83+
{
84+
"origin_netuid": netuid,
85+
"origin_hotkey": bob_wallet.hotkey.ss58_address,
86+
"origin_coldkey": alice_wallet.coldkeypub.ss58_address,
87+
"dest_netuid": netuid,
88+
"dest_hotkey": bob_wallet.hotkey.ss58_address,
89+
"dest_coldkey": bob_wallet.coldkeypub.ss58_address,
90+
"stake_fee": min_stake_fee,
8091
},
8192
]
8293

@@ -91,7 +102,7 @@ async def test_stake_fee_api(local_chain, subtensor, alice_wallet, bob_wallet):
91102
destination_coldkey_ss58=scenario["dest_coldkey"],
92103
)
93104
assert isinstance(stake_fee, Balance), "Stake fee should be a Balance object"
94-
assert stake_fee >= min_stake_fee, (
105+
assert stake_fee >= scenario["stake_fee"], (
95106
"Stake fee should be greater than the minimum stake fee"
96107
)
97108

0 commit comments

Comments
 (0)