From 71a37c02f6450921a6f1d4ca1c385b10809c9a8f Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Mon, 10 Feb 2020 16:35:55 +0000 Subject: [PATCH] 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. --- conftest.py | 4 ---- jmclient/test/test_tx_creation.py | 3 ++- jmclient/test/test_wallet.py | 15 ++++++++------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/conftest.py b/conftest.py index 0102d13..19de3e7 100644 --- a/conftest.py +++ b/conftest.py @@ -113,10 +113,6 @@ def setup(request): #start up regtest blockchain 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) time.sleep(4) #generate blocks; segwit activates around block 500-600 diff --git a/jmclient/test/test_tx_creation.py b/jmclient/test/test_tx_creation.py index 5f61237..8b1a4b5 100644 --- a/jmclient/test/test_tx_creation.py +++ b/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'] ins_full = wallet_service.select_utxos(0, amount) 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, wallet_service, amount, diff --git a/jmclient/test/test_wallet.py b/jmclient/test/test_wallet.py index 173f926..7b2c852 100644 --- a/jmclient/test/test_wallet.py +++ b/jmclient/test/test_wallet.py @@ -302,8 +302,10 @@ def test_signing_imported(setup_wallet, wif, keytype, type_check): MIXDEPTH = 0 path = wallet.import_private_key(MIXDEPTH, wif, keytype) utxo = fund_wallet_addr(wallet, wallet.get_address_from_path(path)) - tx = btc.deserialize(btc.mktx(['{}:{}'.format(hexlify(utxo[0]).decode('ascii'), utxo[1])], - ['00'*17 + ':' + str(10**8 - 9000)])) + # The dummy output is constructed as an unspendable p2sh: + 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) tx = wallet.sign_tx(tx, {0: (script, 10**8)}) type_check(tx) @@ -322,11 +324,10 @@ def test_signing_simple(setup_wallet, wallet_cls, type_check): wallet_cls.initialize(storage, get_network()) wallet = wallet_cls(storage) utxo = fund_wallet_addr(wallet, wallet.get_internal_addr(0)) - # The dummy output is of length 25 bytes, because, for SegwitWallet, we else - # trigger the tx-size-small DOS limit in Bitcoin Core (82 bytes is the - # smallest "normal" transaction size (non-segwit size, ie no witness) - tx = btc.deserialize(btc.mktx(['{}:{}'.format(hexlify(utxo[0]).decode('ascii'), - utxo[1])], ['00'*25 + ':' + str(10**8 - 9000)])) + # The dummy output is constructed as an unspendable p2sh: + 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(0, 1, 0) tx = wallet.sign_tx(tx, {0: (script, 10**8)}) type_check(tx)