implement --fast option for unit tests
This commit is contained in:
parent
338cb77199
commit
eca3007ed1
2 changed files with 12 additions and 21 deletions
|
|
@ -79,7 +79,7 @@ do
|
||||||
gentest_py="$python $gentest_py"
|
gentest_py="$python $gentest_py"
|
||||||
mmgen_tool="$python $mmgen_tool"
|
mmgen_tool="$python $mmgen_tool"
|
||||||
mmgen_keygen="$python $mmgen_keygen" ;&
|
mmgen_keygen="$python $mmgen_keygen" ;&
|
||||||
f) rounds=10 rounds_min=3 rounds_mid=25 rounds_max=50 monero_addrs='3,23' ;;
|
f) rounds=10 rounds_min=3 rounds_mid=25 rounds_max=50 monero_addrs='3,23' unit_tests_py+=" --fast" ;;
|
||||||
i) INSTALL=1 ;;
|
i) INSTALL=1 ;;
|
||||||
I) INSTALL_ONLY=1 ;;
|
I) INSTALL_ONLY=1 ;;
|
||||||
l) echo -e "Default tests:\n $dfl_tests"
|
l) echo -e "Default tests:\n $dfl_tests"
|
||||||
|
|
|
||||||
|
|
@ -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))
|
ss_count,ltr,last_sid,collisions_chk = (
|
||||||
seed_bin = bytes.fromhex('deadbeef' * 8)
|
(SubSeedIdxRange.max_idx,'S','2788F26B',470),
|
||||||
seed = Seed(seed_bin)
|
(49509,'L','8D1FE500',2)
|
||||||
|
)[bool(opt.fast)]
|
||||||
|
|
||||||
subseed = seed.subseed('29429s')
|
last_idx = str(ss_count) + ltr
|
||||||
assert subseed.sid == 'AE4C5E39', subseed.sid
|
|
||||||
assert subseed.nonce == 1, subseed.nonce
|
|
||||||
|
|
||||||
subseed = seed.subseed('59344')
|
msg_r('Testing Seed ID collisions ({} subseed pairs)...'.format(ss_count))
|
||||||
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))
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue