Browse Source

Remove nonstandard scripts from test suite

Fixes #477. Removes nonstandard script support
from 0.19+ bitcoind configuration for regtest and
changes scripts in test_wallet and test_tx_creation
to make them standard.
master
Adam Gibson 6 years ago
parent
commit
71a37c02f6
No known key found for this signature in database
GPG Key ID: 141001A1AF77F20B
  1. 4
      conftest.py
  2. 3
      jmclient/test/test_tx_creation.py
  3. 15
      jmclient/test/test_wallet.py

4
conftest.py

@ -113,10 +113,6 @@ def setup(request):
#start up regtest blockchain #start up regtest blockchain
bitcoin_args = ["-regtest", "-daemon", "-conf=" + bitcoin_conf] bitcoin_args = ["-regtest", "-daemon", "-conf=" + bitcoin_conf]
#for bitcoin-core >= 0.19
if not (bitcoind_version[0] == 0 and bitcoind_version[1] < 19):
bitcoin_args += ['-acceptnonstdtxn']
btc_proc = subprocess.call([bitcoin_path + "bitcoind"] + bitcoin_args) btc_proc = subprocess.call([bitcoin_path + "bitcoind"] + bitcoin_args)
time.sleep(4) time.sleep(4)
#generate blocks; segwit activates around block 500-600 #generate blocks; segwit activates around block 500-600

3
jmclient/test/test_tx_creation.py

@ -41,7 +41,8 @@ def test_create_p2sh_output_tx(setup_tx_creation, nw, wallet_structures,
wallet_service = w['wallet'] wallet_service = w['wallet']
ins_full = wallet_service.select_utxos(0, amount) ins_full = wallet_service.select_utxos(0, amount)
script = bitcoin.mk_multisig_script(pubs, k) script = bitcoin.mk_multisig_script(pubs, k)
output_addr = bitcoin.script_to_address(script, vbyte=196) output_addr = bitcoin.p2sh_scriptaddr(bitcoin.safe_from_hex(script),
magicbyte=196)
txid = make_sign_and_push(ins_full, txid = make_sign_and_push(ins_full,
wallet_service, wallet_service,
amount, amount,

15
jmclient/test/test_wallet.py

@ -302,8 +302,10 @@ def test_signing_imported(setup_wallet, wif, keytype, type_check):
MIXDEPTH = 0 MIXDEPTH = 0
path = wallet.import_private_key(MIXDEPTH, wif, keytype) path = wallet.import_private_key(MIXDEPTH, wif, keytype)
utxo = fund_wallet_addr(wallet, wallet.get_address_from_path(path)) utxo = fund_wallet_addr(wallet, wallet.get_address_from_path(path))
tx = btc.deserialize(btc.mktx(['{}:{}'.format(hexlify(utxo[0]).decode('ascii'), utxo[1])], # The dummy output is constructed as an unspendable p2sh:
['00'*17 + ':' + str(10**8 - 9000)])) tx = btc.deserialize(btc.mktx(['{}:{}'.format(
hexlify(utxo[0]).decode('ascii'), utxo[1])],
[btc.p2sh_scriptaddr(b"\x00",magicbyte=196) + ':' + str(10**8 - 9000)]))
script = wallet.get_script_from_path(path) script = wallet.get_script_from_path(path)
tx = wallet.sign_tx(tx, {0: (script, 10**8)}) tx = wallet.sign_tx(tx, {0: (script, 10**8)})
type_check(tx) type_check(tx)
@ -322,11 +324,10 @@ def test_signing_simple(setup_wallet, wallet_cls, type_check):
wallet_cls.initialize(storage, get_network()) wallet_cls.initialize(storage, get_network())
wallet = wallet_cls(storage) wallet = wallet_cls(storage)
utxo = fund_wallet_addr(wallet, wallet.get_internal_addr(0)) utxo = fund_wallet_addr(wallet, wallet.get_internal_addr(0))
# The dummy output is of length 25 bytes, because, for SegwitWallet, we else # The dummy output is constructed as an unspendable p2sh:
# trigger the tx-size-small DOS limit in Bitcoin Core (82 bytes is the tx = btc.deserialize(btc.mktx(['{}:{}'.format(
# smallest "normal" transaction size (non-segwit size, ie no witness) hexlify(utxo[0]).decode('ascii'), utxo[1])],
tx = btc.deserialize(btc.mktx(['{}:{}'.format(hexlify(utxo[0]).decode('ascii'), [btc.p2sh_scriptaddr(b"\x00",magicbyte=196) + ':' + str(10**8 - 9000)]))
utxo[1])], ['00'*25 + ':' + str(10**8 - 9000)]))
script = wallet.get_script(0, 1, 0) script = wallet.get_script(0, 1, 0)
tx = wallet.sign_tx(tx, {0: (script, 10**8)}) tx = wallet.sign_tx(tx, {0: (script, 10**8)})
type_check(tx) type_check(tx)

Loading…
Cancel
Save