Automated, pexpect-based test suite: 'test/test.py'
Linux-only, due to pexpect module dependencies.
This commit is contained in:
parent
1ce8a6c2fd
commit
9bdfa13c20
28 changed files with 1130 additions and 113 deletions
2
MANIFEST
2
MANIFEST
|
|
@ -1,5 +1,4 @@
|
|||
# file GENERATED by distutils, do NOT edit
|
||||
__init__.py
|
||||
mmgen-addrgen
|
||||
mmgen-addrimport
|
||||
mmgen-keygen
|
||||
|
|
@ -50,3 +49,4 @@ mmgen/tests/__init__.py
|
|||
mmgen/tests/bitcoin.py
|
||||
mmgen/tests/mnemonic.py
|
||||
mmgen/tests/test.py
|
||||
test/test.py
|
||||
|
|
|
|||
|
|
@ -21,5 +21,5 @@ mmgen-addrgen: Generate a series or range of addresses from an MMGen
|
|||
deterministic wallet
|
||||
"""
|
||||
|
||||
import mmgen.main
|
||||
mmgen.main.main("addrgen")
|
||||
from mmgen.main import launch
|
||||
launch("addrgen")
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@
|
|||
mmgen-addrimport: Import addresses into a MMGen bitcoind watching wallet
|
||||
"""
|
||||
|
||||
import mmgen.main
|
||||
mmgen.main.main("addrimport")
|
||||
from mmgen.main import launch
|
||||
launch("addrimport")
|
||||
|
|
|
|||
|
|
@ -21,5 +21,5 @@ mmgen-keygen: Generate a series or range of keys from an MMGen deterministic
|
|||
wallet
|
||||
"""
|
||||
|
||||
import mmgen.main
|
||||
mmgen.main.main("keygen")
|
||||
from mmgen.main import launch
|
||||
launch("keygen")
|
||||
|
|
|
|||
|
|
@ -21,5 +21,5 @@ mmgen-passchg: Change an MMGen deterministic wallet's passphrase, label or
|
|||
hash preset
|
||||
"""
|
||||
|
||||
import mmgen.main
|
||||
mmgen.main.main("passchg")
|
||||
from mmgen.main import launch
|
||||
launch("passchg")
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@
|
|||
mmgen-pywallet: Dump contents of a bitcoind wallet to file
|
||||
"""
|
||||
|
||||
import mmgen.main
|
||||
mmgen.main.main("pywallet")
|
||||
from mmgen.main import launch
|
||||
launch("pywallet")
|
||||
|
|
|
|||
|
|
@ -21,5 +21,5 @@ mmgen-tool: Perform various Bitcoin-related operations.
|
|||
Part of the MMGen suite
|
||||
"""
|
||||
|
||||
import mmgen.main
|
||||
mmgen.main.main("tool")
|
||||
from mmgen.main import launch
|
||||
launch("tool")
|
||||
|
|
|
|||
|
|
@ -21,5 +21,5 @@ mmgen-txcreate: Create a Bitcoin transaction from MMGen- or non-MMGen inputs
|
|||
to MMGen- or non-MMGen outputs
|
||||
"""
|
||||
|
||||
import mmgen.main
|
||||
mmgen.main.main("txcreate")
|
||||
from mmgen.main import launch
|
||||
launch("txcreate")
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@
|
|||
mmgen-txsend: Broadcast a transaction signed by 'mmgen-txsign' to the network
|
||||
"""
|
||||
|
||||
import mmgen.main
|
||||
mmgen.main.main("txsend")
|
||||
from mmgen.main import launch
|
||||
launch("txsend")
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@
|
|||
mmgen-txsign: Sign a transaction generated by 'mmgen-txcreate'
|
||||
"""
|
||||
|
||||
import mmgen.main
|
||||
mmgen.main.main("txsign")
|
||||
from mmgen.main import launch
|
||||
launch("txsign")
|
||||
|
|
|
|||
|
|
@ -21,5 +21,5 @@ mmgen-walletchk: Check integrity of an MMGen deterministic wallet, display
|
|||
information about it and export it to various formats
|
||||
"""
|
||||
|
||||
import mmgen.main
|
||||
mmgen.main.main("walletchk")
|
||||
from mmgen.main import launch
|
||||
launch("walletchk")
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@
|
|||
mmgen-walletgen: Generate an MMGen deterministic wallet
|
||||
"""
|
||||
|
||||
import mmgen.main
|
||||
mmgen.main.main("walletgen")
|
||||
from mmgen.main import launch
|
||||
launch("walletgen")
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ def parse_opts(argv,help_data):
|
|||
print "cmd args: %s" % repr(args)
|
||||
|
||||
for l in (
|
||||
('outdir', 'export_incog_hidden'),
|
||||
('from_incog_hidden','from_incog','from_seed','from_mnemonic','from_brain'),
|
||||
('export_incog','export_incog_hex','export_incog_hidden','export_mnemonic',
|
||||
'export_seed'),
|
||||
|
|
@ -64,15 +63,14 @@ def parse_opts(argv,help_data):
|
|||
# check_opts() doesn't touch opts[]
|
||||
if not check_opts(opts,long_opts): sys.exit(1)
|
||||
|
||||
# If unset, set these to default values in mmgen.config:
|
||||
# If unset, set these to default values in mmgen.config (g):
|
||||
for v in g.dfl_vars:
|
||||
if v in opts: typeconvert_override_var(opts,v)
|
||||
else: opts[v] = eval("g."+v)
|
||||
else: opts[v] = g.__dict__[v]
|
||||
|
||||
# Opposite of above: if set, override the default values in mmgen.config:
|
||||
if 'no_keyconv' in opts: g.no_keyconv = opts['no_keyconv']
|
||||
if 'verbose' in opts: g.verbose = opts['verbose']
|
||||
if 'quiet' in opts: g.quiet = opts['quiet']
|
||||
# Opposite of above: if set, override the default values in mmgen.config (g):
|
||||
for k in 'no_keyconv','verbose','quiet':
|
||||
if k in opts: g.__dict__[k] = opts[k]
|
||||
|
||||
if g.debug: print "opts after typeconvert: %s" % opts
|
||||
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ faster address generation.
|
|||
|
||||
def test_for_keyconv():
|
||||
|
||||
from subprocess import Popen, PIPE
|
||||
from subprocess import check_output,STDOUT
|
||||
try:
|
||||
p = Popen([g.keyconv_exec, '-h'], stdout=PIPE, stderr=PIPE)
|
||||
check_output([g.keyconv_exec, '-G'],stderr=STDOUT)
|
||||
except:
|
||||
msg(addrmsgs['no_keyconv_msg'])
|
||||
return False
|
||||
|
|
@ -66,15 +66,14 @@ def generate_addrs(seed, addrnums, opts, seed_id=""):
|
|||
from mmgen.bitcoin import privnum2addr
|
||||
keyconv = False
|
||||
else:
|
||||
from subprocess import Popen, PIPE
|
||||
from subprocess import check_output
|
||||
keyconv = "keyconv"
|
||||
|
||||
fmt = "num sec wif addr" if 'ka' in opts['gen_what'] else (
|
||||
"num sec wif" if 'k' in opts['gen_what'] else "num addr")
|
||||
ai_attrs = ("num,sec,wif,addr") if 'ka' in opts['gen_what'] else (
|
||||
("num,sec,wif") if 'k' in opts['gen_what'] else ("num,addr"))
|
||||
|
||||
from collections import namedtuple
|
||||
addrinfo = namedtuple("addrinfo",fmt)
|
||||
addrinfo_args = "%s" % ",".join(fmt.split())
|
||||
addrinfo = namedtuple("addrinfo",ai_attrs.split(","))
|
||||
|
||||
addrnums = sorted(set(addrnums)) # don't trust the calling function
|
||||
t_addrs,num,pos,out = len(addrnums),0,0,[]
|
||||
|
|
@ -100,11 +99,13 @@ def generate_addrs(seed, addrnums, opts, seed_id=""):
|
|||
sec = sha256(sha256(seed).digest()).hexdigest()
|
||||
wif = numtowif(int(sec,16))
|
||||
|
||||
if 'a' in opts['gen_what']: addr = \
|
||||
Popen([keyconv, wif], stdout=PIPE).stdout.readline().split()[1] \
|
||||
if keyconv else privnum2addr(int(sec,16))
|
||||
if 'a' in opts['gen_what']:
|
||||
if keyconv:
|
||||
addr = check_output([keyconv, wif]).split()[1]
|
||||
else:
|
||||
addr = privnum2addr(int(sec,16))
|
||||
|
||||
out.append(eval("addrinfo("+addrinfo_args+")"))
|
||||
out.append(addrinfo(*eval(ai_attrs)))
|
||||
|
||||
m = w[0] if t_addrs == 1 else w[0]+w[1]
|
||||
if seed_id:
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ min_screen_width = 80
|
|||
max_tx_comment_len = 72
|
||||
|
||||
from decimal import Decimal
|
||||
tx_fee = Decimal("0.0001")
|
||||
tx_fee = Decimal("0.00005")
|
||||
max_tx_fee = Decimal("0.01")
|
||||
|
||||
proj_name = "MMGen"
|
||||
|
|
@ -70,10 +70,11 @@ http_timeout = 30
|
|||
|
||||
keyconv_exec = "keyconv"
|
||||
|
||||
from os import getenv
|
||||
debug = getenv("MMGEN_DEBUG")
|
||||
no_license = getenv("MMGEN_NOLICENSE")
|
||||
bogus_wallet_data = getenv("MMGEN_BOGUS_WALLET_DATA")
|
||||
# returns None if env var unset
|
||||
debug = os.getenv("MMGEN_DEBUG")
|
||||
no_license = os.getenv("MMGEN_NOLICENSE")
|
||||
bogus_wallet_data = os.getenv("MMGEN_BOGUS_WALLET_DATA")
|
||||
disable_hold_protect = os.getenv("MMGEN_DISABLE_HOLD_PROTECT")
|
||||
|
||||
mins_per_block = 8.5
|
||||
passwd_max_tries = 5
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ def get_random_data_from_user(uchars):
|
|||
|
||||
for i in range(uchars):
|
||||
key_data += get_char(immed_chars="ALL",prehold_protect=pp)
|
||||
if i == 0: pp = False
|
||||
pp = False
|
||||
msg_r("\r" + prompt % (uchars - i - 1))
|
||||
now = time.time()
|
||||
time_data.append(now - saved_time)
|
||||
|
|
|
|||
|
|
@ -32,19 +32,18 @@ def launch_txsign(): import mmgen.main_txsign
|
|||
def launch_walletchk(): import mmgen.main_walletchk
|
||||
def launch_walletgen(): import mmgen.main_walletgen
|
||||
|
||||
def main(progname):
|
||||
def launch(what):
|
||||
try: import termios
|
||||
except: eval("launch_"+progname+"()") # Windows
|
||||
except: globals()["launch_"+what]() # Windows
|
||||
else:
|
||||
import sys
|
||||
import sys,atexit
|
||||
fd = sys.stdin.fileno()
|
||||
old = termios.tcgetattr(fd)
|
||||
try: eval("launch_"+progname+"()")
|
||||
def at_exit():
|
||||
termios.tcsetattr(fd, termios.TCSADRAIN, old)
|
||||
atexit.register(at_exit)
|
||||
try: globals()["launch_"+what]()
|
||||
except KeyboardInterrupt:
|
||||
sys.stderr.write("\nUser interrupt\n")
|
||||
termios.tcsetattr(fd, termios.TCSADRAIN, old)
|
||||
sys.exit(1)
|
||||
except EOFError:
|
||||
sys.stderr.write("\nEnd of file\n")
|
||||
termios.tcsetattr(fd, termios.TCSADRAIN, old)
|
||||
sys.exit(1)
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ if 'a' in opts['gen_what']:
|
|||
qmsg("Record it to a safe location.")
|
||||
|
||||
if 'k' in opts['gen_what'] and keypress_confirm("Encrypt key list?"):
|
||||
addr_data_str = mmgen_encrypt(addr_data_str,"key list","",opts)
|
||||
addr_data_str = mmgen_encrypt(addr_data_str,"new key list","",opts)
|
||||
enc_ext = "." + g.mmenc_ext
|
||||
else: enc_ext = ""
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""
|
||||
mmgen-addrimport: Import addresses into a MMGen bitcoind watching wallet
|
||||
mmgen-addrimport: Import addresses into a MMGen bitcoind tracking wallet
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
|
@ -29,7 +29,7 @@ from mmgen.tx import connect_to_bitcoind,parse_addrfile,parse_keyaddr_file
|
|||
help_data = {
|
||||
'prog_name': g.prog_name,
|
||||
'desc': """Import addresses (both {pnm} and non-{pnm}) into a bitcoind
|
||||
watching wallet""".format(pnm=g.proj_name),
|
||||
tracking wallet""".format(pnm=g.proj_name),
|
||||
'usage':"[opts] [mmgen address file]",
|
||||
'options': """
|
||||
-h, --help Print this help message
|
||||
|
|
@ -38,6 +38,10 @@ help_data = {
|
|||
-q, --quiet Suppress warnings
|
||||
-r, --rescan Rescan the blockchain. Required if address to import is
|
||||
on the blockchain and has a balance. Rescanning is slow.
|
||||
""",
|
||||
'notes': """\n
|
||||
This command can also be used to update the comment fields of addresses already
|
||||
in the tracking wallet.
|
||||
"""
|
||||
}
|
||||
|
||||
|
|
@ -78,14 +82,16 @@ g.http_timeout = 3600
|
|||
c = connect_to_bitcoind()
|
||||
|
||||
m = """
|
||||
WARNING: You've chosen the '--rescan' option. Rescanning the block chain is
|
||||
necessary only if an address you're importing is already on the block chain
|
||||
and has a balance. Note that the rescanning process is very slow (>30 min.
|
||||
for each imported address on a low-powered computer).
|
||||
WARNING: You've chosen the '--rescan' option. Rescanning the blockchain is
|
||||
necessary only if an address you're importing is already on the blockchain,
|
||||
has a balance and is not already in your tracking wallet. Note that the
|
||||
rescanning process is very slow (>30 min. for each imported address on a
|
||||
low-powered computer).
|
||||
""".strip() if "rescan" in opts else """
|
||||
WARNING: If any of the addresses you're importing is already on the block chain
|
||||
and has a balance, you must exit the program now and rerun it using the
|
||||
'--rescan' option. Otherwise you may ignore this message and continue.
|
||||
WARNING: If any of the addresses you're importing is already on the blockchain,
|
||||
has a balance and is not already in your tracking wallet, you must exit the
|
||||
program now and rerun it using the '--rescan' option. Otherwise you may ignore
|
||||
this message and continue.
|
||||
""".strip()
|
||||
|
||||
if g.quiet: m = ""
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue