|
@@ -36,6 +36,7 @@ opts_data = {
|
|
'usage':'[options] [tests]',
|
|
'usage':'[options] [tests]',
|
|
'options': """
|
|
'options': """
|
|
-h, --help Print this help message
|
|
-h, --help Print this help message
|
|
|
|
+-f, --fast Speed up execution by reducing rounds on some tests
|
|
-l, --list List available tests
|
|
-l, --list List available tests
|
|
-n, --names Print command names instead of descriptions
|
|
-n, --names Print command names instead of descriptions
|
|
-q, --quiet Produce quieter output
|
|
-q, --quiet Produce quieter output
|
|
@@ -293,32 +294,23 @@ class UnitTests(object):
|
|
msg('OK')
|
|
msg('OK')
|
|
|
|
|
|
def collisions():
|
|
def collisions():
|
|
- msg_r('Testing Seed ID collisions ({} subseed pairs)...'.format(59344))
|
|
|
|
- seed_bin = bytes.fromhex('deadbeef' * 8)
|
|
|
|
- seed = Seed(seed_bin)
|
|
|
|
|
|
+ ss_count,ltr,last_sid,collisions_chk = (
|
|
|
|
+ (SubSeedIdxRange.max_idx,'S','2788F26B',470),
|
|
|
|
+ (49509,'L','8D1FE500',2)
|
|
|
|
+ )[bool(opt.fast)]
|
|
|
|
|
|
- subseed = seed.subseed('29429s')
|
|
|
|
- assert subseed.sid == 'AE4C5E39', subseed.sid
|
|
|
|
- assert subseed.nonce == 1, subseed.nonce
|
|
|
|
|
|
+ last_idx = str(ss_count) + ltr
|
|
|
|
|
|
- subseed = seed.subseed('59344')
|
|
|
|
- assert subseed.sid == 'FC4AD16F', subseed.sid
|
|
|
|
- assert subseed.nonce == 1, subseed.nonce
|
|
|
|
-
|
|
|
|
- subseed2 = seed.subseed_by_seed_id('FC4AD16F')
|
|
|
|
- assert subseed.pformat() == subseed2.pformat()
|
|
|
|
-
|
|
|
|
- msg('OK')
|
|
|
|
-
|
|
|
|
- def count_collisions():
|
|
|
|
- msg_r('Counting Seed ID collisions ({} subseed pairs)...'.format(SubSeedIdxRange.max_idx))
|
|
|
|
|
|
+ msg_r('Testing Seed ID collisions ({} subseed pairs)...'.format(ss_count))
|
|
|
|
|
|
seed_bin = bytes.fromhex('12abcdef' * 8)
|
|
seed_bin = bytes.fromhex('12abcdef' * 8)
|
|
seed = Seed(seed_bin)
|
|
seed = Seed(seed_bin)
|
|
|
|
|
|
- seed.gen_subseeds(SubSeedIdxRange.max_idx)
|
|
|
|
|
|
+ seed.gen_subseeds(ss_count)
|
|
ss = seed.subseeds
|
|
ss = seed.subseeds
|
|
|
|
|
|
|
|
+ assert seed.subseed(last_idx).sid == last_sid, seed.subseed(last_idx).sid
|
|
|
|
+
|
|
for sid in ss['long']:
|
|
for sid in ss['long']:
|
|
# msg(sid)
|
|
# msg(sid)
|
|
assert sid not in ss['short']
|
|
assert sid not in ss['short']
|
|
@@ -328,14 +320,13 @@ class UnitTests(object):
|
|
for sid in ss[k]:
|
|
for sid in ss[k]:
|
|
collisions += ss[k][sid][1]
|
|
collisions += ss[k][sid][1]
|
|
|
|
|
|
- assert collisions == 470, collisions
|
|
|
|
|
|
+ assert collisions == collisions_chk, collisions
|
|
msg_r('({} collisions) '.format(collisions))
|
|
msg_r('({} collisions) '.format(collisions))
|
|
msg('OK')
|
|
msg('OK')
|
|
|
|
|
|
basic_ops()
|
|
basic_ops()
|
|
defaults_and_limits()
|
|
defaults_and_limits()
|
|
collisions()
|
|
collisions()
|
|
- count_collisions()
|
|
|
|
|
|
|
|
return True
|
|
return True
|
|
|
|
|