Skip to content
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

Fix async test #2095

Merged
merged 6 commits into from
Jul 5, 2024
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
6 changes: 3 additions & 3 deletions bittensor/utils/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,10 @@ async def _get_block_with_retry(
Exception: If the block hash is None.
ValueError: If the difficulty is None.
"""
block_number, difficulty_ = await asyncio.gather(
subtensor.get_current_block(), subtensor.difficulty(netuid=netuid)
block_number = await subtensor.get_current_block()
difficulty = (
1_000_000 if netuid == -1 else await subtensor.difficulty(netuid=netuid)
)
difficulty = 1_000_000 if netuid == -1 else difficulty_

block_hash = await subtensor.get_block_hash(block_number)
if block_hash is None:
Expand Down
1 change: 1 addition & 0 deletions bittensor/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def __init__(
self.config.wallet.path = path or self.config.wallet.get(
"path", bittensor.defaults.wallet.path
)
self.config.wallet.path = self.config.wallet.path.strip("'")

self.name = self.config.wallet.name
self.path = self.config.wallet.path
Expand Down
7 changes: 4 additions & 3 deletions tests/e2e_tests/multistep/test_emissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
"""


@pytest.mark.skip(
"an investigation into the behavior of the async implementation of `wait_interval` is required"
)
@pytest.mark.asyncio
async def test_emissions(local_chain):
# Register root as Alice - the subnet owner and validator
Expand All @@ -70,6 +67,10 @@ async def test_emissions(local_chain):
],
)

subtensor = bittensor.subtensor(network="ws://localhost:9945")
# assert 1 neuron are in network
assert len(await subtensor.neurons(netuid=1)) == 1

# Register Bob as neuron to the subnet
await bob_exec_command(
RegisterCommand,
Expand Down
5 changes: 5 additions & 0 deletions tests/e2e_tests/subcommands/hyperparams/test_liquid_alpha.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import asyncio

import pytest

import bittensor
Expand Down Expand Up @@ -70,6 +72,9 @@ async def test_liquid_alpha_enabled(local_chain, capsys):
wait_for_finalization=True,
)
assert result is False

await asyncio.sleep(10)

output = capsys.readouterr().out
assert (
"❌ Failed: Subtensor returned `LiquidAlphaDisabled (Module)` error. This means: \n`Attempting to set alpha high/low while disabled`"
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e_tests/subcommands/wallet/test_faucet.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import asyncio

import pytest

import bittensor
Expand All @@ -12,10 +14,6 @@
)


@pytest.mark.skip(
"error appears here https://github.com/opentensor/bittensor/blob/merge-async/bittensor/utils/async_substrate.py#L637"
)
@pytest.mark.parametrize("local_chain", [False], indirect=True)
@pytest.mark.asyncio
async def test_faucet(local_chain):
# Register root as Alice
Expand Down Expand Up @@ -82,6 +80,8 @@ async def test_faucet(local_chain):
except Exception as e:
logging.warning(f"Unexpected exception occurred on faucet: {e}")

await asyncio.sleep(10)

subtensor = bittensor.subtensor(network="ws://localhost:9945")
new_wallet_balance = await subtensor.get_balance(keypair.ss58_address)
# verify balance increase
Expand Down