Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 10 additions & 5 deletions miners/gpu_fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@
try:
import torch
import torch.cuda
HAS_TORCH = True
except ImportError:
print("ERROR: PyTorch with CUDA support required. Install: pip install torch")
sys.exit(1)
HAS_TORCH = False

if not torch.cuda.is_available():
print("ERROR: No CUDA-capable GPU detected.")
sys.exit(1)
def check_requirements():
if not HAS_TORCH:
print("ERROR: PyTorch with CUDA support required. Install: pip install torch")
sys.exit(1)
if not torch.cuda.is_available():
print("ERROR: No CUDA-capable GPU detected.")
sys.exit(1)


# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -789,6 +793,7 @@ def cross_validate_gpu(device: torch.device) -> ChannelResult:

def run_gpu_fingerprint(device_index: int = 0, samples: int = 200, epoch_salt: str = "") -> GPUFingerprint:
"""Run all GPU fingerprint channels and return results."""
check_requirements()
device = torch.device(f"cuda:{device_index}")

# GPU info
Expand Down
4 changes: 2 additions & 2 deletions setup_miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
MINER_ARTIFACTS = {
"Linux": {
"url": "https://raw.githubusercontent.com/Scottcjn/Rustchain/main/miners/linux/rustchain_linux_miner.py",
"sha256": "4afd5aea552cc5b68364b39fa37cdc93d1d406ec295670969e1a9c4164babb15",
"sha256": "c7af612bb2630d5fe6576bb132bdeb7a00ba0be042ec168887ab767a1f16c9f9",
},
"Darwin": {
"url": "https://raw.githubusercontent.com/Scottcjn/Rustchain/main/miners/macos/rustchain_mac_miner_v2.5.py",
"sha256": "163fafcf751d8fbd41bf936facaeb366c042f467fa34b79f2c4c0a45472ef70f",
},
"Windows": {
"url": "https://raw.githubusercontent.com/Scottcjn/Rustchain/main/miners/windows/rustchain_windows_miner.py",
"sha256": "5b69ebc210e4e8e32975b711dcb1ca08e07b731ddfe4f9f2f9a7e68c1e246a9d",
"sha256": "7f663904031e5a4202be416682fd16ab51af2e96664d6db1567f716d8625f8e1",
},
}

Expand Down
14 changes: 9 additions & 5 deletions tests/test_tx_handler_error_redaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def _client_for_exploding_pool():
return app.test_client()


import os
os.environ["RC_ADMIN_KEY"] = "test_admin_key_for_tests"
ADMIN_HEADERS = {"X-Admin-Key": "test_admin_key_for_tests"}

def _assert_redacted(response):
assert response.status_code == 500
assert response.get_json() == {"error": "internal_error"}
Expand All @@ -56,22 +60,22 @@ def _assert_redacted(response):

def test_tx_status_redacts_internal_exception_details():
with _client_for_exploding_pool() as client:
_assert_redacted(client.get("/tx/status/hash_1"))
_assert_redacted(client.get("/tx/status/hash_1", headers=ADMIN_HEADERS))


def test_tx_pending_redacts_internal_exception_details():
with _client_for_exploding_pool() as client:
_assert_redacted(client.get("/tx/pending"))
_assert_redacted(client.get("/tx/pending", headers=ADMIN_HEADERS))


def test_wallet_balance_redacts_internal_exception_details():
with _client_for_exploding_pool() as client:
_assert_redacted(client.get("/wallet/alice/balance"))
_assert_redacted(client.get("/wallet/alice/balance", headers=ADMIN_HEADERS))


def test_wallet_nonce_redacts_internal_exception_details():
with _client_for_exploding_pool() as client:
_assert_redacted(client.get("/wallet/alice/nonce"))
_assert_redacted(client.get("/wallet/alice/nonce", headers=ADMIN_HEADERS))


def test_wallet_history_redacts_internal_exception_details(monkeypatch):
Expand All @@ -83,4 +87,4 @@ def raise_connect_error(*args, **kwargs):
monkeypatch.setattr(tx_handler.sqlite3, "connect", raise_connect_error)

with _client_for_exploding_pool() as client:
_assert_redacted(client.get("/wallet/alice/history"))
_assert_redacted(client.get("/wallet/alice/history", headers=ADMIN_HEADERS))
7 changes: 5 additions & 2 deletions tests/test_tx_handler_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def app_context(monkeypatch):
monkeypatch.setenv("RC_ADMIN_KEY", admin_key)

db_fd, db_path = tempfile.mkstemp()
os.close(db_fd)
app = Flask(__name__)
app.config['TESTING'] = True

Expand All @@ -50,8 +51,10 @@ def app_context(monkeypatch):
client.environ_base['HTTP_X_ADMIN_KEY'] = admin_key
yield client

os.close(db_fd)
os.unlink(db_path)
try:
os.unlink(db_path)
except PermissionError:
pass

def test_pending_default_limit(app_context):
"""Scenario: Default parameters (no query string) - Expect 100 (from logic)"""
Expand Down
Loading