Skip to content
Open
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
1 change: 1 addition & 0 deletions src/python_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
/// netuid (int): Subnet identifier.
/// subnet_reveal_period_epochs (int): Number of epochs to wait before decryption.
/// block_time (float, optional): Block time in seconds (default = 12.0).
/// hotkey (bytes): The hotkey of a neuron-committer is represented as public_key bytes
///
/// Returns:
/// Tuple[bytes, int]: A tuple containing:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_all_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def test_get_encrypted_commit():
current_block = 100
netuid = 1
subnet_reveal_period_epochs = 2
block_time = 12
hotkey = bytes([1, 2, 3])

encrypted, round_ = btcr.get_encrypted_commit(
uids,
Expand All @@ -52,6 +54,8 @@ def test_get_encrypted_commit():
current_block,
netuid,
subnet_reveal_period_epochs,
block_time,
hotkey
)
assert isinstance(encrypted, bytes)
assert isinstance(round_, int)
9 changes: 7 additions & 2 deletions tests/test_commit_reveal.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def test_get_encrypted_commits():
netuid = 1
reveal_period = 2
block_time = 12
hotkey = bytes([1, 2, 3])

start_time = int(time.time())
ct_pybytes, reveal_round = get_encrypted_commit(
Expand All @@ -27,6 +28,7 @@ def test_get_encrypted_commits():
netuid,
reveal_period,
block_time,
hotkey,
)

# Basic checks
Expand Down Expand Up @@ -54,6 +56,7 @@ def test_generate_commit_success():
netuid = 100
subnet_reveal_period_epochs = 2
block_time = 12
hotkey = bytes([1, 2, 3])

start_time = int(time.time())
ct_pybytes, reveal_round = get_encrypted_commit(
Expand All @@ -65,6 +68,7 @@ def test_generate_commit_success():
netuid,
subnet_reveal_period_epochs,
block_time,
hotkey,
)

assert ct_pybytes is not None and len(ct_pybytes) > 0, (
Expand Down Expand Up @@ -101,8 +105,7 @@ def test_generate_commit_success():
)


@pytest.mark.asyncio
async def test_generate_commit_various_tempos():
def test_generate_commit_various_tempos():
NETUID = 1
CURRENT_BLOCK = 100_000
SUBNET_REVEAL_PERIOD_EPOCHS = 1
Expand All @@ -112,6 +115,7 @@ async def test_generate_commit_various_tempos():
uids = [0]
values = [100]
version_key = 1
hotkey = bytes([1, 2, 3])

for tempo in TEMPOS:
start_time = int(time.time())
Expand All @@ -125,6 +129,7 @@ async def test_generate_commit_various_tempos():
NETUID,
SUBNET_REVEAL_PERIOD_EPOCHS,
BLOCK_TIME,
hotkey
)

assert len(ct_pybytes) > 0, f"Ciphertext is empty for tempo {tempo}"
Expand Down
Loading