Browse Source

Old tests deleted

philemon 10 years ago
parent
commit
9d6c3223a8
5 changed files with 1 additions and 292 deletions
  1. 0 0
      mmgen/tests/__init__.py
  2. 0 92
      mmgen/tests/bitcoin.py
  3. 0 114
      mmgen/tests/mnemonic.py
  4. 0 86
      mmgen/tests/test.py
  5. 1 0
      setup.py

+ 0 - 0
mmgen/tests/__init__.py


+ 0 - 92
mmgen/tests/bitcoin.py

@@ -1,92 +0,0 @@
-#!/usr/bin/env python
-#
-# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
-# Copyright (C) 2013 by philemon <mmgen-py@yandex.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-"""
-bitcoin.py:  Test suite for mmgen.bitcoin module
-"""
-
-import mmgen.bitcoin as b
-from   mmgen.util import msg
-from   mmgen.tests.test import *
-from   binascii import hexlify
-import sys
-
-def keyconv_compare_randloop(loops, quiet=False):
-	for i in range(1,int(loops)+1):
-
-
-		wif = _numtowif_rand(quiet=True)
-
-		if not quiet: sys.stderr.write("-- %s --\n" % i)
-		ret = keyconv_compare(wif,quiet)
-		if ret == False: sys.exit(9)
-
-		if quiet:
-			sys.stderr.write("\riteration: %i " % i)
-
-	if quiet:
-		sys.stderr.write("\r%s iterations completed\n" % i)
-	else:
-		print "%s iterations completed" % i
-
-def keyconv_compare(wif,quiet=False):
-	do_msg = nomsg if quiet else msg
-	do_msg("WIF:               %s" % wif)
-	from subprocess import Popen, PIPE
-	try:
-		p = Popen(["keyconv", wif], stdout=PIPE)
-	except:
-		print "Error with execution of keyconv"
-		sys.exit(3)
-	kc_addr = dict([j.split() for j in p.stdout.readlines()])['Address:']
-	addr = b.privnum2addr(b.wiftonum(wif))
-	do_msg("Address (mmgen):   %s" % addr)
-	do_msg("Address (keyconv): %s" % kc_addr)
-	if (kc_addr != addr):
-		print "'keyconv' addr differs from internally-generated addr!"
-		print "WIF:      %s" % wif
-		print "keyconv:  %s" % kc_addr
-		print "internal: %s" % addr
-		return False
-	else:
-		return True
-
-def _do_hextowif(hex_in,quiet=False):
-	do_msg = nomsg if quiet else msg
-	do_msg("Input:        %s" % hex_in)
-	wif = b.numtowif(int(hex_in,16))
-	do_msg("WIF encoded:  %s" % wif)
-	wif_dec = b.wiftohex(wif)
-	do_msg("WIF decoded:  %s" % wif_dec)
-	if hex_in != wif_dec:
-		print "ERROR!  Decoded data doesn't match original data"
-		sys.exit(9)
-	return wif
-
-def _numtowif_rand(quiet=False):
-	r_hex = hexlify(get_random(32))
-
-	return _do_hextowif(r_hex,quiet)
-
-
-tests = {
-	"keyconv_compare":          ['wif [str]','quiet [bool=False]'],
-	"keyconv_compare_randloop": ['iterations [int]','quiet [bool=False]'],
-}
-
-args = process_test_args(sys.argv, tests)
-eval(sys.argv[1])(*args)

+ 0 - 114
mmgen/tests/mnemonic.py

@@ -1,114 +0,0 @@
-#!/usr/bin/env python
-#
-# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
-# Copyright (C) 2013 by philemon <mmgen-py@yandex.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-"""
-mnemonic.py:  Test suite for mmgen.mnemonic module
-"""
-
-from test import *
-
-import sys
-from binascii import hexlify
-
-from mmgen.mnemonic import *
-from mmgen.mn_electrum  import electrum_words as el
-from mmgen.mn_tirosh    import tirosh_words   as tl
-
-def do_random_tests(n):
-	r = get_random(n)
-	em = get_mnemonic_from_seed(r,el.strip().split("\n"),
-			"electrum",print_info=False)
-	tm = get_mnemonic_from_seed(r,tl.strip().split("\n"),
-			"tirosh",print_info=False)
-
-	print "Seed:     %s (%s bits)" % (hexlify(r),len(r)*8)
-	print "Electrum: %s" % " ".join(em)
-	print "Tirosh:   %s" % " ".join(tm)
-
-
-def hextobaseN_test(num_in,base,wl,quiet=False):
-	do_msg = nomsg if quiet else msg
-	do_msg("Input:         %s" % num_in)
-	num_enc = "".join(hextobaseN(base,num_in,wl,len(num_in)*2))
-	do_msg("Encoded value: %s" % num_enc)
-	num_dec = baseNtohex(base,num_enc,wl)
-	do_msg("Decoded value: %s" % num_dec)
-	test_equality(num_in,num_dec,wl,quiet)
-	return num_enc,num_dec
-
-
-def baseNtohex_test(num_in,base,wl,quiet=False):
-	do_msg = nomsg if quiet else msg
-	do_msg("Input:         %s" % num_in)
-	num_enc = baseNtohex(base,list(num_in),wl)
-	do_msg("Encoded value: %s" % num_enc)
-	num_dec = "".join(hextobaseN(base,num_enc,wl,len(num_enc)*2))
-	do_msg("Decoded value: %s" % num_dec)
-	test_equality(num_in,num_dec,wl,quiet)
-	return num_enc,num_dec
-
-
-def random128(): do_random_tests(16)
-def random192(): do_random_tests(24)
-def random256(): do_random_tests(32)
-def random512(): do_random_tests(64)
-def electrum():  check_wordlist(el,"electrum")
-def electrum_print():  print "%s" % el.strip()
-def tirosh():    check_wordlist(tl,"tirosh")
-def tirosh_print():  print "%s" % tl.strip()
-
-def base10tohex(num,quiet=False):
-	enc,dec = baseNtohex_test(num,10,"0123456789",quiet)
-	print "Decimal:           %s" % num
-	print "Hex (encoded):     %s" % enc
-	print "Decimal (recoded): %s" % dec.lstrip("0")
-
-def hextobase10(num,quiet=False):
-	enc,dec= hextobaseN_test(num,10,"0123456789",quiet)
-	print "Hex:               %s" % num
-	print "Decimal (encoded): %s" % enc.lstrip("0")
-	print "Hex (recoded):     %s" % dec
-
-def base8tohex(num,quiet=False):
-	enc,dec = baseNtohex_test(num,8,"01234567",quiet)
-	print "Octal:           %s" % num
-	print "Hex (encoded):   %s" % enc
-	print "Octal (recoded): %s" % "0" + dec.lstrip("0")
-
-def hextobase8(num,quiet=False):
-	enc,dec = hextobaseN_test(num,8,"01234567",quiet)
-	print "Hex:           %s" % num
-	print "Octal:         %s" % "0" + enc.lstrip("0")
-	print "Hex (recoded): %s" % dec
-
-tests = {
-	"random128":      [],
-	"random192":      [],
-	"random256":      [],
-	"random512":      [],
-	"electrum":       [],
-	"tirosh":         [],
-	"electrum_print": [],
-	"tirosh_print":   [],
-	"base10tohex":    ['base10num [int]','quiet [bool=False]'],
-	"hextobase10":    ['hexnum [str]',   'quiet [bool=False]'],
-	"base8tohex":     ['base8num [int]', 'quiet [bool=False]'],
-	"hextobase8":     ['hexnum [str]',   'quiet [bool=False]'],
-}
-
-args = process_test_args(sys.argv, tests)
-eval(sys.argv[1])(*args)

+ 0 - 86
mmgen/tests/test.py

@@ -1,86 +0,0 @@
-#!/usr/bin/env python
-#
-# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
-# Copyright (C) 2013 by philemon <mmgen-py@yandex.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-"""
-test.py:  Shared routines for mmgen test suite
-"""
-
-import sys
-
-def msg(s): print s
-def nomsg(s): pass
-
-def test_equality(num_in,num_out,wl,quiet=False):
-
-	do_msg = nomsg if quiet else msg
-
-	if num_in != num_out:
-		do_msg("WARNING! Recoded number doesn't match input stringwise!")
-		do_msg("Input:  %s" % num_in)
-		do_msg("Output: %s" % num_out)
-
-	i = num_in.lstrip(wl[0])
-	o = num_out.lstrip(wl[0])
-
-	if i != o:
-		print "ERROR! Recoded number doesn't match input numerically!"
-		sys.exit(9)
-
-
-def get_random(length):
-	from Crypto import Random
-	return Random.new().read(length)
-
-def process_test_args(argv, tests):
-	if (len(argv) == 1):
-		print "Usage: %s <test>" % argv[0].split("/")[-1]
-		ls = "\n   "
-		print "Available tests:%s%s" % (ls,ls.join(sorted(tests.keys())))
-		sys.exit(1)
-	elif argv[1] not in tests:
-		print "'%s': no such test" % argv[1]
-		sys.exit(2)
-	else:
-		cargs = tests[argv[1]]
-		uargs = argv[2:]
-		if len(uargs) > len(cargs):
-			print "Too many arguments\nUsage: %s(%s)" % \
-				(argv[1], ", ".join(cargs))
-			sys.exit()
-
-		for i in range(len(cargs)):
-			try:    uarg = uargs[i]
-			except: uarg = None
-
-			cname,ctype_arg = cargs[i].split()
-			c = ctype_arg[1:-1].split("=")[0:]
-			ctype,cdflt = c[0],c[1:]
-
-			if uarg == None and not cdflt:
-				print "Usage: %s(%s)" % \
-					(argv[1], ", ".join(cargs))
-				sys.exit()
-
-#		print "%-10s %-7s %s" % (uarg, cargs[i], carg)
-
-			if uarg:
-				try: eval(ctype + "('" + uarg + "')")
-				except:
-					print "'%s' Invalid argument (%s required)" % (uarg, ctype)
-					sys.exit()
-
-		return uargs

+ 1 - 0
setup.py

@@ -72,6 +72,7 @@ setup(
 			'test.__init__',
 			'test.__init__',
 			'test.test',
 			'test.test',
 			'test.tooltest',
 			'test.tooltest',
+			'test.gentest',
 		],
 		],
 		scripts=[
 		scripts=[
 			'mmgen-addrgen',
 			'mmgen-addrgen',