From 60ce9f32fed1c3a8a509aeb264a5e772dabdfd8d Mon Sep 17 00:00:00 2001 From: highlander Date: Tue, 8 Sep 2026 14:32:18 -0600 Subject: [PATCH] test: validate power-cycle storage stamps for both firmware products --- tests/test_storage_version_gate.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_storage_version_gate.py b/tests/test_storage_version_gate.py index 9c133a6d..c00823fc 100644 --- a/tests/test_storage_version_gate.py +++ b/tests/test_storage_version_gate.py @@ -998,6 +998,8 @@ def _create_wallet(self): label=LABEL, language="english") c.init_device() self.assertTrue(c.features.initialized) + from keepkeylib import messages_pb2 as proto + self.bitcoin_only = c.call(proto.GetCoinTable()).num_coins == 2 addr = c.get_address("Bitcoin", BIP44_ADDRESS_N) finally: c.close() @@ -1063,6 +1065,8 @@ def test_reboot_preserves_the_wallet(self): # only record which branch the author was standing on. declared = _define(_read_source("include/keepkey/firmware/storage.h"), "STORAGE_VERSION") + if self.bitcoin_only: + declared += STORAGE_VERSION_BTC_ONLY_BASE self.assertEqual( declared, self.emu.read_u32(off, OFF_VERSION), "the firmware committed a storage version other than the %d its " @@ -1189,6 +1193,24 @@ def test_bitcoin_only_band_refuses_without_wiping(self): wallet comes back once the stamp is the multi-chain one again. """ addr, off = self._create_wallet() + if self.bitcoin_only: + # This product must read its own band; the full-product branch below + # must refuse the same band while preserving its bytes. + declared = _define(_read_source("include/keepkey/firmware/storage.h"), + "STORAGE_VERSION") + self.assertEqual(STORAGE_VERSION_BTC_ONLY_BASE + declared, + self.emu.read_u32(off, OFF_VERSION)) + before = self.emu.image() + self.emu.boot() + c = self.emu.client(self.method, pin=PIN) + try: + c.init_device() + self.assertTrue(c.features.initialized) + self.assertEqual(before, self.emu.image()) + self.assertEqual(addr, c.get_address("Bitcoin", BIP44_ADDRESS_N)) + finally: + c.close() + return self.assertLess( self.emu.read_u32(off, OFF_VERSION), STORAGE_VERSION_BTC_ONLY_BASE, "this emulator already stamps its wallets into the bitcoin-only "