Skip to content

Commit 8554c05

Browse files
committed
fix(eos): make test_updateauth's SLIP48 golden hash version-aware for the waits_count loop-bound fix
keepkey-firmware@0f4dafcca fixed eos_hashAuthorization()'s waits[] serialization loop, which was bounded by accounts_count instead of waits_count -- for an authorization with accounts_count=1, waits_count=0 (this test's SLIP48/is_slip48=True case: 1 account, 0 waits), the old code hashed one uninitialized/stale waits[] slot the message never populated. This test's golden hash was captured against that bug. Independently confirmed the new value both ways: - Code: the two loop bounds only diverge when accounts_count != waits_count. This test's is_slip48=False case has accounts_count == waits_count == 1, so both bounds agree and its hash (line 561) is correctly unchanged -- exactly matching which of the two assertions here actually failed. - Build: reproduced the new hash independently against a from-scratch local build of current alpha, matching CI's value exactly. The fix ships starting in firmware 7.16.0 (current alpha). This suite also runs against pinned older releases -- the RC18 compatibility job pins 7.15.0, which still has the old behavior -- so a single hardcoded hash cannot be correct for both. Branches on the firmware version under test, following the same semver comparison common.py's requires_firmware() already uses, rather than picking one release's answer and breaking the other's compatibility job. This test never actually ran in CI until now -- keepkey-firmware's secret-scan was silently skipping the entire build/test graph on every PR (see keepkey-firmware#583) -- so nobody caught that the fix, landed and merged weeks ago, needed this golden value updated to match.
1 parent d9ab7fd commit 8554c05

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

tests/test_msg_eos_signtx.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,24 @@ def test_updateauth(self):
568568
num_actions=1),
569569
[self.action_updateauth(True)])
570570

571-
self.assertEqual(binascii.hexlify(res.hash), "fb936ef1be4bda680d93bd10b6d062357d8dd7272038a706dc0d61a91f39c5ee")
571+
# This authorization has accounts_count=1, waits_count=0 -- exactly
572+
# the case keepkey-firmware@0f4dafcca's eos_hashAuthorization() fix
573+
# changed, by correcting the waits[] serialization loop bound from
574+
# accounts_count to waits_count. That fix ships starting in 7.16.0;
575+
# this suite also runs against pinned older releases (e.g. 7.15.0,
576+
# see the RC18 compatibility job) that still have the old behavior,
577+
# so the expected hash must follow the firmware under test rather
578+
# than assume the fix is always present.
579+
import semver
580+
self.client.init_device()
581+
fw_version = "%s.%s.%s" % (self.client.features.major_version,
582+
self.client.features.minor_version,
583+
self.client.features.patch_version)
584+
if semver.VersionInfo.parse(fw_version) >= semver.VersionInfo.parse("7.16.0"):
585+
expected_hash = "5938294e65cf9e8b5dd5f2b204503b4825f277e6f4a2d5ab7a55a31065a23af1"
586+
else:
587+
expected_hash = "fb936ef1be4bda680d93bd10b6d062357d8dd7272038a706dc0d61a91f39c5ee"
588+
self.assertEqual(binascii.hexlify(res.hash), expected_hash)
572589

573590
def test_deleteauth(self):
574591
self.requires_fullFeature()

0 commit comments

Comments
 (0)