Skip to content

Commit eeb2b0e

Browse files
tests: more e2e tests
1 parent baac41b commit eeb2b0e

11 files changed

+1198
-23
lines changed

tests/e2e_tests/test_blocks.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import re
2+
3+
4+
def test_blocks(subtensor):
5+
"""
6+
Tests:
7+
- Get current block
8+
- Get block hash
9+
- Wait for block
10+
"""
11+
12+
block = subtensor.get_current_block()
13+
14+
assert block == subtensor.block
15+
16+
block_hash = subtensor.get_block_hash(block)
17+
18+
assert re.match("0x[a-z0-9]{64}", block_hash)
19+
20+
subtensor.wait_for_block(block + 10)
21+
22+
assert subtensor.get_current_block() == block + 10

tests/e2e_tests/test_commit_reveal_v3.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
5353
), "Unable to enable commit reveal on the subnet"
5454

5555
# Verify commit_reveal was enabled
56-
assert subtensor.get_subnet_hyperparameters(
57-
netuid=netuid,
58-
).commit_reveal_weights_enabled, "Failed to enable commit/reveal"
56+
assert subtensor.commit_reveal_enabled(netuid), "Failed to enable commit/reveal"
5957
logging.console.info("Commit reveal enabled")
6058

6159
# Change the weights rate limit on the subnet

tests/e2e_tests/test_commit_weights.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ async def test_commit_and_reveal_weights_legacy(local_chain, subtensor, alice_wa
4545
netuid,
4646
), "Unable to enable commit reveal on the subnet"
4747

48-
assert subtensor.get_subnet_hyperparameters(
49-
netuid=netuid,
50-
).commit_reveal_weights_enabled, "Failed to enable commit/reveal"
48+
assert subtensor.commit_reveal_enabled(netuid), "Failed to enable commit/reveal"
5149

5250
assert (
5351
subtensor.get_subnet_hyperparameters(netuid=netuid).commit_reveal_period == 1
@@ -114,11 +112,9 @@ async def test_commit_and_reveal_weights_legacy(local_chain, subtensor, alice_wa
114112
assert commit_block > 0, f"Invalid block number: {commit_block}"
115113

116114
# Query the WeightCommitRevealInterval storage map
117-
reveal_periods = subtensor.query_module(
118-
module="SubtensorModule", name="RevealPeriodEpochs", params=[netuid]
119-
)
120-
periods = reveal_periods
121-
assert periods > 0, "Invalid RevealPeriodEpochs"
115+
assert (
116+
subtensor.get_subnet_reveal_period_epochs(netuid) > 0
117+
), "Invalid RevealPeriodEpochs"
122118

123119
# Wait until the reveal block range
124120
await wait_epoch(subtensor, netuid)
@@ -187,9 +183,7 @@ async def test_commit_weights_uses_next_nonce(local_chain, subtensor, alice_wall
187183
netuid,
188184
), "Unable to enable commit reveal on the subnet"
189185

190-
assert subtensor.get_subnet_hyperparameters(
191-
netuid=netuid,
192-
).commit_reveal_weights_enabled, "Failed to enable commit/reveal"
186+
assert subtensor.commit_reveal_enabled(netuid), "Failed to enable commit/reveal"
193187

194188
assert (
195189
subtensor.get_subnet_hyperparameters(netuid=netuid).commit_reveal_period == 1

0 commit comments

Comments
 (0)