2016-11-06 16:04:25 +00:00
|
|
|
from common import *
|
2016-11-06 11:38:33 +00:00
|
|
|
|
|
|
|
from trezor.crypto import random
|
|
|
|
|
2016-11-06 16:04:25 +00:00
|
|
|
from trezor import config
|
|
|
|
|
2016-11-06 11:38:33 +00:00
|
|
|
class TestConfig(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_set_get(self):
|
|
|
|
config.wipe()
|
|
|
|
for _ in range(128):
|
|
|
|
appid, key = random.uniform(256), random.uniform(256)
|
|
|
|
value = random.bytes(128)
|
|
|
|
config.set(appid, key, value)
|
|
|
|
value2 = config.get(appid, key)
|
|
|
|
self.assertEqual(value, value2)
|
|
|
|
|
|
|
|
def test_get_default(self):
|
|
|
|
config.wipe()
|
|
|
|
for _ in range(128):
|
|
|
|
appid, key = random.uniform(256), random.uniform(256)
|
|
|
|
value = random.bytes(128)
|
|
|
|
value2 = config.get(appid, key, value)
|
|
|
|
self.assertEqual(value, value2)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|