fix hammer test, enforce default hr unit

This commit is contained in:
John-Paul Compagnone
2025-01-02 17:41:43 -05:00
committed by Brett Rowan
parent 9ee52f77f9
commit 5236e02af2
2 changed files with 4 additions and 3 deletions

View File

@@ -229,7 +229,7 @@ class BlackMiner(StockFirmware):
hashrate = boards[1].get(f"chain_rate{i}") hashrate = boards[1].get(f"chain_rate{i}")
if hashrate: if hashrate:
hashboard.hashrate = self.algo.hashrate( hashboard.hashrate = self.algo.hashrate(
rate=float(hashrate), unit=self.algo.unit.GH rate=float(hashrate), unit=self.algo.unit.MH
).into(self.algo.unit.default) ).into(self.algo.unit.default)
chips = boards[1].get(f"chain_acn{i}") chips = boards[1].get(f"chain_acn{i}")
@@ -358,7 +358,7 @@ class BlackMiner(StockFirmware):
try: try:
expected_rate = rpc_stats["STATS"][1].get("total_rateideal") expected_rate = rpc_stats["STATS"][1].get("total_rateideal")
if expected_rate is None: if expected_rate is None:
return self.sticker_hashrate return self.sticker_hashrate.into(self.algo.unit.default)
try: try:
rate_unit = rpc_stats["STATS"][1]["rate_unit"] rate_unit = rpc_stats["STATS"][1]["rate_unit"]
except KeyError: except KeyError:

View File

@@ -6,6 +6,7 @@ from unittest.mock import patch
from pyasic import APIError, MinerData from pyasic import APIError, MinerData
from pyasic.data import Fan, HashBoard from pyasic.data import Fan, HashBoard
from pyasic.device.algorithm.hashrate.unit.scrypt import ScryptUnit
from pyasic.miners.hammer import HammerD10 from pyasic.miners.hammer import HammerD10
POOLS = [ POOLS = [
@@ -398,6 +399,6 @@ class TestHammerMiners(unittest.IsolatedAsyncioTestCase):
self.assertEqual(result.api_ver, "3.1") self.assertEqual(result.api_ver, "3.1")
self.assertEqual(result.fw_ver, "2023-05-28 17-20-35 CST") self.assertEqual(result.fw_ver, "2023-05-28 17-20-35 CST")
self.assertEqual(result.hostname, "Hammer") self.assertEqual(result.hostname, "Hammer")
self.assertEqual(round(result.hashrate), 4686) self.assertEqual(round(result.hashrate.into(ScryptUnit.MH)), 4686)
self.assertEqual(result.fans, [Fan(speed=4650), Fan(speed=4500)]) self.assertEqual(result.fans, [Fan(speed=4650), Fan(speed=4500)])
self.assertEqual(result.total_chips, result.expected_chips) self.assertEqual(result.total_chips, result.expected_chips)