mmgen-wallet/test/objtest_py_d/ot_btc_testnet.py
The MMGen Project c3f185e8b0
eliminate use of global vars g.proto, g.coin, g.rpc and others
This patch eliminates nearly all the global variables that changed during the
execution of scripts.  With a few minor exceptions, global vars are now used
only during initialization or reserved for cfg file / cmdline options and other
unchanging values.

The result is a code base that's much more maintainable and extensible and less
error-prone.  The autosigning code, which supports signing of transactions for
multiple protocols and networks, has been greatly simplified.

Doing away with globals required many changes throughout the code base, and
other related (and not so related) changes and cleanups were made along the
way, resulting in an enormous patch.

Additional code changes include:

    - tx.py: complete reorganization of TX classes and use of nesting

    - protocol.py: separation of Regtest and Testnet into distinct subclasses
      with separate address and transaction files and file extensions

    - new module help.py for the help notes, loaded on demand

    - addr.py: rewrite of the address file label parsing code

    - tx.py,tw.py: use of generators to create formatted text

User-visible changes include:

    - importing of addresses for tokens not yet in the user's tracking wallet
      is now performed with the `--token-addr` option instead of `--token`

Testing:

    Testing this patch requires a full run of the test suite as described on the
    Test-Suite wiki page.
2020-05-28 09:53:34 +00:00

69 lines
2.3 KiB
Python
Executable file

#!/usr/bin/env python3
#
# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
# Copyright (C)2013-2020 The MMGen Project <mmgen@tuta.io>
"""
test.objtest_py_d.ot_btc_testnet: BTC testnet test vectors for MMGen data objects
"""
from mmgen.obj import *
from .ot_common import *
from mmgen.protocol import init_proto
proto = init_proto('btc',network='testnet')
tests = {
'CoinAddr': {
'bad': (
{'addr':1, 'proto':proto},
{'addr':'x', 'proto':proto},
{'addr':'я', 'proto':proto},
),
'good': (
{'addr':'n2FgXPKwuFkCXF946EnoxWJDWF2VwQ6q8J', 'proto':proto},
{'addr':'2MspvWFjBbkv2wzQGqhxJUYPCk3Y2jMaxLN','proto':proto},
),
},
'WifKey': {
'bad': (
{'proto':proto, 'wif':1},
{'proto':proto, 'wif':[]},
{'proto':proto, 'wif':'\0'},
{'proto':proto, 'wif':'\1'},
{'proto':proto, 'wif':'я'},
{'proto':proto, 'wif':'g'},
{'proto':proto, 'wif':'gg'},
{'proto':proto, 'wif':'FF'},
{'proto':proto, 'wif':'f00'},
{'proto':proto, 'wif':r16.hex()},
{'proto':proto, 'wif':'2MspvWFjBbkv2wzQGqhxJUYPCk3Y2jMaxLN'},
),
'good': (
{'proto':proto, 'wif':'93HsQEpH75ibaUJYi3QwwiQxnkW4dUuYFPXZxcbcKds7XrqHkY6', 'ret_idx':1},
{'proto':proto, 'wif':'cMsqcmDYZP1LdKgqRh9L4ZRU9br28yvdmTPwW2YQwVSN9aQiMAoR', 'ret_idx':1},
)
},
'PrivKey': {
'bad': (
{'proto':proto, 'wif':1},
{'proto':proto, 'wif':'1'},
{'proto':proto, 'wif':'5KXEpVzjWreTcQoG5hX357s1969MUKNLuSfcszF6yu84kpsNZKb'},
{'proto':proto, 's':r32,'wif':'5KXEpVzjWreTcQoG5hX357s1969MUKNLuSfcszF6yu84kpsNZKb'},
{'proto':proto, 'pubkey_type':'std'},
{'proto':proto, 's':r32},
{'proto':proto, 's':r32,'compressed':'yes'},
{'proto':proto, 's':r32,'compressed':'yes','pubkey_type':'std'},
{'proto':proto, 's':r32,'compressed':True,'pubkey_type':'nonstd'},
{'proto':proto, 's':r32+b'x','compressed':True,'pubkey_type':'std'}
),
'good': (
{'proto':proto, 'wif':'93HsQEpH75ibaUJYi3QwwiQxnkW4dUuYFPXZxcbcKds7XrqHkY6',
'ret':'e0aef965b905a2fedf907151df8e0a6bac832aa697801c51f58bd2ecb4fd381c'},
{'proto':proto, 'wif':'cMsqcmDYZP1LdKgqRh9L4ZRU9br28yvdmTPwW2YQwVSN9aQiMAoR',
'ret':'08d0ed83b64b68d56fa064be48e2385060ed205be2b1e63cd56d218038c3a05f'},
{'proto':proto, 's':r32,'compressed':False,'pubkey_type':'std','ret':r32.hex()},
{'proto':proto, 's':r32,'compressed':True,'pubkey_type':'std','ret':r32.hex()}
),
},
}