2018-12-29 21:33:19 +00:00
|
|
|
from common import *
|
|
|
|
from trezor.pin import pin_to_int
|
|
|
|
from trezor import config
|
2019-07-01 07:45:30 +00:00
|
|
|
from apps.common.storage import device
|
2018-12-29 21:33:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestConfig(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_counter(self):
|
|
|
|
config.init()
|
|
|
|
config.wipe()
|
|
|
|
for i in range(150):
|
2019-07-01 07:45:30 +00:00
|
|
|
self.assertEqual(device.next_u2f_counter(), i)
|
|
|
|
device.set_u2f_counter(350)
|
2018-12-29 21:33:19 +00:00
|
|
|
for i in range(351, 500):
|
2019-07-01 07:45:30 +00:00
|
|
|
self.assertEqual(device.next_u2f_counter(), i)
|
|
|
|
device.set_u2f_counter(0)
|
|
|
|
self.assertEqual(device.next_u2f_counter(), 1)
|
|
|
|
device.set_u2f_counter(None)
|
|
|
|
self.assertEqual(device.next_u2f_counter(), 0)
|
2018-12-29 21:33:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|