2014-02-04 15:12:52 +00:00
|
|
|
import unittest
|
|
|
|
import common
|
|
|
|
import time
|
|
|
|
from trezorlib import tools
|
|
|
|
|
2014-02-21 06:28:56 +00:00
|
|
|
class TestBip32Speed(common.TrezorTest):
|
2014-02-04 15:12:52 +00:00
|
|
|
def test_public_ckd(self):
|
2014-02-17 00:54:54 +00:00
|
|
|
self.setup_mnemonic_nopin_nopassphrase()
|
2014-02-04 15:12:52 +00:00
|
|
|
|
2014-02-13 15:50:16 +00:00
|
|
|
self.client.get_address('Bitcoin', []) # to compute root node via BIP39
|
2014-02-11 20:03:17 +00:00
|
|
|
|
2014-02-04 15:12:52 +00:00
|
|
|
for depth in range(8):
|
|
|
|
start = time.time()
|
|
|
|
self.client.get_address('Bitcoin', range(depth))
|
|
|
|
delay = time.time() - start
|
2014-02-21 06:28:56 +00:00
|
|
|
expected = (depth + 1) * 0.26
|
2014-02-04 15:12:52 +00:00
|
|
|
print "DEPTH", depth, "EXPECTED DELAY", expected, "REAL DELAY", delay
|
|
|
|
self.assertLessEqual(delay, expected)
|
|
|
|
|
|
|
|
def test_private_ckd(self):
|
2014-02-17 00:54:54 +00:00
|
|
|
self.setup_mnemonic_nopin_nopassphrase()
|
2014-02-04 15:12:52 +00:00
|
|
|
|
2014-02-13 15:50:16 +00:00
|
|
|
self.client.get_address('Bitcoin', []) # to compute root node via BIP39
|
2014-02-11 20:03:17 +00:00
|
|
|
|
2014-02-04 15:12:52 +00:00
|
|
|
for depth in range(8):
|
|
|
|
start = time.time()
|
|
|
|
self.client.get_address('Bitcoin', range(-depth, 0))
|
|
|
|
delay = time.time() - start
|
2014-02-21 06:28:56 +00:00
|
|
|
expected = (depth + 1) * 0.26
|
2014-02-04 15:12:52 +00:00
|
|
|
print "DEPTH", depth, "EXPECTED DELAY", expected, "REAL DELAY", delay
|
|
|
|
self.assertLessEqual(delay, expected)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|