mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
storage/tests: test non-existing key
This commit is contained in:
parent
252d069a66
commit
2aa49fda96
@ -130,8 +130,12 @@ class Storage:
|
||||
# public fields can be read from an unlocked device
|
||||
raise RuntimeError("Storage locked")
|
||||
if consts.is_app_public(app):
|
||||
return self.nc.get(key)
|
||||
return self._get_encrypted(key)
|
||||
value = self.nc.get(key)
|
||||
else:
|
||||
value = self._get_encrypted(key)
|
||||
if value is False:
|
||||
raise RuntimeError("Failed to find key in storage.")
|
||||
return value
|
||||
|
||||
def set(self, key: int, val: bytes) -> bool:
|
||||
app = key >> 8
|
||||
@ -153,7 +157,7 @@ class Storage:
|
||||
app = key >> 8
|
||||
self._check_lock(app)
|
||||
|
||||
current = self.get(key)
|
||||
current = self.nc.get(key)
|
||||
if current is False:
|
||||
self.set_counter(key, 0)
|
||||
return 0
|
||||
|
@ -83,6 +83,13 @@ def test_invalid_key():
|
||||
s.set(0xFFFF, b"Hello")
|
||||
|
||||
|
||||
def test_non_existing_key():
|
||||
sc, sp = common.init()
|
||||
for s in (sc, sp):
|
||||
with pytest.raises(RuntimeError):
|
||||
s.get(0xABCD)
|
||||
|
||||
|
||||
def test_chacha_strings():
|
||||
sc, sp = common.init(unlock=True)
|
||||
for s in (sc, sp):
|
||||
|
Loading…
Reference in New Issue
Block a user