diff options
Diffstat (limited to 'qa')
-rwxr-xr-x | qa/pull-tester/rpc-tests.py | 55 | ||||
-rw-r--r-- | qa/pull-tester/run-bitcoind-for-test.sh.in | 36 | ||||
-rwxr-xr-x | qa/rpc-tests/maxuploadtarget.py | 39 | ||||
-rwxr-xr-x | qa/rpc-tests/mempool_limit.py | 6 | ||||
-rwxr-xr-x | qa/rpc-tests/mempool_packages.py | 4 | ||||
-rwxr-xr-x | qa/rpc-tests/prioritise_transaction.py | 2 | ||||
-rwxr-xr-x | qa/rpc-tests/pruning.py | 50 | ||||
-rwxr-xr-x | qa/rpc-tests/replace-by-fee.py | 2 | ||||
-rwxr-xr-x | qa/rpc-tests/segwit.py | 20 | ||||
-rwxr-xr-x | qa/rpc-tests/smartfees.py | 6 | ||||
-rwxr-xr-x | qa/rpc-tests/test_framework/test_framework.py | 11 | ||||
-rw-r--r-- | qa/rpc-tests/test_framework/util.py | 24 |
12 files changed, 101 insertions, 154 deletions
diff --git a/qa/pull-tester/rpc-tests.py b/qa/pull-tester/rpc-tests.py index 58bd00fdfc..736d416e51 100755 --- a/qa/pull-tester/rpc-tests.py +++ b/qa/pull-tester/rpc-tests.py @@ -100,78 +100,87 @@ if ENABLE_ZMQ: testScripts = [ # longest test should go first, to favor running tests in parallel - 'p2p-fullblocktest.py', + 'wallet-hd.py', 'walletbackup.py', - 'bip68-112-113-p2p.py', + # vv Tests less than 5m vv + 'p2p-fullblocktest.py', + 'fundrawtransaction.py', + 'p2p-compactblocks.py', + 'segwit.py', + # vv Tests less than 2m vv 'wallet.py', 'wallet-accounts.py', - 'wallet-hd.py', + 'p2p-segwit.py', 'wallet-dump.py', 'listtransactions.py', + # vv Tests less than 60s vv + 'sendheaders.py', + 'zapwallettxes.py', + 'importmulti.py', + 'mempool_limit.py', + 'merkle_blocks.py', 'receivedby.py', + 'abandonconflict.py', + 'bip68-112-113-p2p.py', + 'rawtransactions.py', + 'reindex.py', + # vv Tests less than 30s vv 'mempool_resurrect_test.py', 'txn_doublespend.py --mineblock', - 'p2p-segwit.py', - 'segwit.py', 'txn_clone.py', 'getchaintips.py', - 'rawtransactions.py', 'rest.py', 'mempool_spendcoinbase.py', 'mempool_reorg.py', - 'mempool_limit.py', 'httpbasics.py', 'multi_rpc.py', - 'zapwallettxes.py', 'proxy_test.py', - 'merkle_blocks.py', - 'fundrawtransaction.py', 'signrawtransactions.py', 'nodehandling.py', - 'reindex.py', 'decodescript.py', 'blockchain.py', 'disablewallet.py', - 'sendheaders.py', 'keypool.py', 'p2p-mempool.py', 'prioritise_transaction.py', 'invalidblockrequest.py', 'invalidtxrequest.py', - 'abandonconflict.py', 'p2p-versionbits-warning.py', 'preciousblock.py', 'importprunedfunds.py', 'signmessages.py', - 'p2p-compactblocks.py', 'nulldummy.py', - 'importmulti.py', ] if ENABLE_ZMQ: testScripts.append('zmq_test.py') testScriptsExt = [ + 'pruning.py', + # vv Tests less than 20m vv + 'smartfees.py', + # vv Tests less than 5m vv + 'maxuploadtarget.py', + 'mempool_packages.py', + # vv Tests less than 2m vv + 'bip68-sequence.py', + 'getblocktemplate_longpoll.py', + # vv Tests less than 60s vv 'bip9-softforks.py', + 'p2p-feefilter.py', + 'rpcbind_test.py', + # vv Tests less than 30s vv 'bip65-cltv.py', 'bip65-cltv-p2p.py', - 'bip68-sequence.py', 'bipdersig-p2p.py', 'bipdersig.py', - 'getblocktemplate_longpoll.py', 'getblocktemplate_proposals.py', 'txn_doublespend.py', 'txn_clone.py --mineblock', 'forknotify.py', 'invalidateblock.py', - 'rpcbind_test.py', - 'smartfees.py', 'maxblocksinflight.py', 'p2p-acceptblock.py', - 'mempool_packages.py', - 'maxuploadtarget.py', 'replace-by-fee.py', - 'p2p-feefilter.py', - 'pruning.py', # leave pruning last as it takes a REALLY long time ] diff --git a/qa/pull-tester/run-bitcoind-for-test.sh.in b/qa/pull-tester/run-bitcoind-for-test.sh.in deleted file mode 100644 index 14ae08e4e5..0000000000 --- a/qa/pull-tester/run-bitcoind-for-test.sh.in +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# Copyright (c) 2013-2014 The Bitcoin Core developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. -# -DATADIR="@abs_top_builddir@/.bitcoin" -rm -rf "$DATADIR" -mkdir -p "$DATADIR"/regtest -touch "$DATADIR/regtest/debug.log" -tail -q -n 1 -F "$DATADIR/regtest/debug.log" | grep -m 1 -q "Done loading" & -WAITER=$! -PORT=`expr 10000 + $$ % 55536` -"@abs_top_builddir@/src/bitcoind@EXEEXT@" -connect=0.0.0.0 -datadir="$DATADIR" -rpcuser=user -rpcpassword=pass -listen -keypool=3 -debug -debug=net -logtimestamps -checkmempool=0 -relaypriority=0 -port=$PORT -whitelist=127.0.0.1 -regtest -rpcport=`expr $PORT + 1` & -BITCOIND=$! - -#Install a watchdog. -(sleep 10 && kill -0 $WAITER 2>/dev/null && kill -9 $BITCOIND $$)& -wait $WAITER - -if [ -n "$TIMEOUT" ]; then - timeout "$TIMEOUT"s "$@" $PORT - RETURN=$? -else - "$@" $PORT - RETURN=$? -fi - -(sleep 15 && kill -0 $BITCOIND 2>/dev/null && kill -9 $BITCOIND $$)& -kill $BITCOIND && wait $BITCOIND - -# timeout returns 124 on timeout, otherwise the return value of the child - -# If $RETURN is not 0, the test failed. Dump the tail of the debug log. -if [ $RETURN -ne 0 ]; then tail -n 200 $DATADIR/regtest/debug.log; fi - -exit $RETURN diff --git a/qa/rpc-tests/maxuploadtarget.py b/qa/rpc-tests/maxuploadtarget.py index d0e9fe9a3f..9340e899eb 100755 --- a/qa/rpc-tests/maxuploadtarget.py +++ b/qa/rpc-tests/maxuploadtarget.py @@ -81,49 +81,19 @@ class TestNode(NodeConnCB): class MaxUploadTest(BitcoinTestFramework): - def add_options(self, parser): - parser.add_option("--testbinary", dest="testbinary", - default=os.getenv("BITCOIND", "bitcoind"), - help="bitcoind binary to test") - def __init__(self): super().__init__() self.setup_clean_chain = True self.num_nodes = 1 - self.utxo = [] - self.txouts = gen_return_txouts() + # Cache for utxos, as the listunspent may take a long time later in the test + self.utxo_cache = [] def setup_network(self): # Start a node with maxuploadtarget of 200 MB (/24h) self.nodes = [] self.nodes.append(start_node(0, self.options.tmpdir, ["-debug", "-maxuploadtarget=800", "-blockmaxsize=999000"])) - def mine_full_block(self, node, address): - # Want to create a full block - # We'll generate a 66k transaction below, and 14 of them is close to the 1MB block limit - for j in range(14): - if len(self.utxo) < 14: - self.utxo = node.listunspent() - inputs=[] - outputs = {} - t = self.utxo.pop() - inputs.append({ "txid" : t["txid"], "vout" : t["vout"]}) - remchange = t["amount"] - Decimal("0.001000") - outputs[address]=remchange - # Create a basic transaction that will send change back to ourself after account for a fee - # And then insert the 128 generated transaction outs in the middle rawtx[92] is where the # - # of txouts is stored and is the only thing we overwrite from the original transaction - rawtx = node.createrawtransaction(inputs, outputs) - newtx = rawtx[0:92] - newtx = newtx + self.txouts - newtx = newtx + rawtx[94:] - # Appears to be ever so slightly faster to sign with SIGHASH_NONE - signresult = node.signrawtransaction(newtx,None,None,"NONE") - txid = node.sendrawtransaction(signresult["hex"], True) - # Mine a full sized block which will be these transactions we just created - node.generate(1) - def run_test(self): # Before we connect anything, we first set the time on the node # to be in the past, otherwise things break because the CNode @@ -151,7 +121,7 @@ class MaxUploadTest(BitcoinTestFramework): # Test logic begins here # Now mine a big block - self.mine_full_block(self.nodes[0], self.nodes[0].getnewaddress()) + mine_large_block(self.nodes[0], self.utxo_cache) # Store the hash; we'll request this later big_old_block = self.nodes[0].getbestblockhash() @@ -162,11 +132,10 @@ class MaxUploadTest(BitcoinTestFramework): self.nodes[0].setmocktime(int(time.time()) - 2*60*60*24) # Mine one more block, so that the prior block looks old - self.mine_full_block(self.nodes[0], self.nodes[0].getnewaddress()) + mine_large_block(self.nodes[0], self.utxo_cache) # We'll be requesting this new block too big_new_block = self.nodes[0].getbestblockhash() - new_block_size = self.nodes[0].getblock(big_new_block)['size'] big_new_block = int(big_new_block, 16) # test_nodes[0] will test what happens if we just keep requesting the diff --git a/qa/rpc-tests/mempool_limit.py b/qa/rpc-tests/mempool_limit.py index 4438c152df..154ae59c26 100755 --- a/qa/rpc-tests/mempool_limit.py +++ b/qa/rpc-tests/mempool_limit.py @@ -26,7 +26,7 @@ class MempoolLimitTest(BitcoinTestFramework): def run_test(self): txids = [] - utxos = create_confirmed_utxos(self.relayfee, self.nodes[0], 90) + utxos = create_confirmed_utxos(self.relayfee, self.nodes[0], 91) #create a mempool tx that will be evicted us0 = utxos.pop() @@ -41,9 +41,9 @@ class MempoolLimitTest(BitcoinTestFramework): relayfee = self.nodes[0].getnetworkinfo()['relayfee'] base_fee = relayfee*100 - for i in range (4): + for i in range (3): txids.append([]) - txids[i] = create_lots_of_big_transactions(self.nodes[0], self.txouts, utxos[30*i:30*i+30], (i+1)*base_fee) + txids[i] = create_lots_of_big_transactions(self.nodes[0], self.txouts, utxos[30*i:30*i+30], 30, (i+1)*base_fee) # by now, the tx should be evicted, check confirmation state assert(txid not in self.nodes[0].getrawmempool()) diff --git a/qa/rpc-tests/mempool_packages.py b/qa/rpc-tests/mempool_packages.py index 45dc0e65c4..f605e7524f 100755 --- a/qa/rpc-tests/mempool_packages.py +++ b/qa/rpc-tests/mempool_packages.py @@ -20,8 +20,8 @@ class MempoolPackagesTest(BitcoinTestFramework): def setup_network(self): self.nodes = [] - self.nodes.append(start_node(0, self.options.tmpdir, ["-maxorphantx=1000", "-relaypriority=0", "-debug"])) - self.nodes.append(start_node(1, self.options.tmpdir, ["-maxorphantx=1000", "-relaypriority=0", "-limitancestorcount=5", "-debug"])) + self.nodes.append(start_node(0, self.options.tmpdir, ["-maxorphantx=1000", "-debug"])) + self.nodes.append(start_node(1, self.options.tmpdir, ["-maxorphantx=1000", "-limitancestorcount=5", "-debug"])) connect_nodes(self.nodes[0], 1) self.is_network_split = False self.sync_all() diff --git a/qa/rpc-tests/prioritise_transaction.py b/qa/rpc-tests/prioritise_transaction.py index 85afeab2e3..b7459c80cb 100755 --- a/qa/rpc-tests/prioritise_transaction.py +++ b/qa/rpc-tests/prioritise_transaction.py @@ -39,7 +39,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework): txids.append([]) start_range = i * range_size end_range = start_range + range_size - txids[i] = create_lots_of_big_transactions(self.nodes[0], self.txouts, utxos[start_range:end_range], (i+1)*base_fee) + txids[i] = create_lots_of_big_transactions(self.nodes[0], self.txouts, utxos[start_range:end_range], end_range - start_range, (i+1)*base_fee) # Make sure that the size of each group of transactions exceeds # MAX_BLOCK_BASE_SIZE -- otherwise the test needs to be revised to create diff --git a/qa/rpc-tests/pruning.py b/qa/rpc-tests/pruning.py index 287dbc776e..78b8938e4a 100755 --- a/qa/rpc-tests/pruning.py +++ b/qa/rpc-tests/pruning.py @@ -13,6 +13,9 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import * +import time +import os + def calc_usage(blockdir): return sum(os.path.getsize(blockdir+f) for f in os.listdir(blockdir) if os.path.isfile(blockdir+f)) / (1024. * 1024.) @@ -24,9 +27,9 @@ class PruneTest(BitcoinTestFramework): self.setup_clean_chain = True self.num_nodes = 3 - self.utxo = [] - self.address = ["",""] - self.txouts = gen_return_txouts() + # Cache for utxos, as the listunspent may take a long time later in the test + self.utxo_cache_0 = [] + self.utxo_cache_1 = [] def setup_network(self): self.nodes = [] @@ -40,12 +43,6 @@ class PruneTest(BitcoinTestFramework): self.nodes.append(start_node(2, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-prune=550"], timewait=900)) self.prunedir = self.options.tmpdir+"/node2/regtest/blocks/" - self.address[0] = self.nodes[0].getnewaddress() - self.address[1] = self.nodes[1].getnewaddress() - - # Determine default relay fee - self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"] - connect_nodes(self.nodes[0], 1) connect_nodes(self.nodes[1], 2) connect_nodes(self.nodes[2], 0) @@ -58,7 +55,7 @@ class PruneTest(BitcoinTestFramework): self.nodes[0].generate(150) # Then mine enough full blocks to create more than 550MiB of data for i in range(645): - self.mine_full_block(self.nodes[0], self.address[0]) + mine_large_block(self.nodes[0], self.utxo_cache_0) sync_blocks(self.nodes[0:3]) @@ -70,7 +67,7 @@ class PruneTest(BitcoinTestFramework): print("Mining 25 more blocks should cause the first block file to be pruned") # Pruning doesn't run until we're allocating another chunk, 20 full blocks past the height cutoff will ensure this for i in range(25): - self.mine_full_block(self.nodes[0],self.address[0]) + mine_large_block(self.nodes[0], self.utxo_cache_0) waitstart = time.time() while os.path.isfile(self.prunedir+"blk00000.dat"): @@ -95,17 +92,15 @@ class PruneTest(BitcoinTestFramework): stop_node(self.nodes[0],0) self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900) # Mine 24 blocks in node 1 - self.utxo = self.nodes[1].listunspent() for i in range(24): if j == 0: - self.mine_full_block(self.nodes[1],self.address[1]) + mine_large_block(self.nodes[1], self.utxo_cache_1) else: self.nodes[1].generate(1) #tx's already in mempool from previous disconnects # Reorg back with 25 block chain from node 0 - self.utxo = self.nodes[0].listunspent() for i in range(25): - self.mine_full_block(self.nodes[0],self.address[0]) + mine_large_block(self.nodes[0], self.utxo_cache_0) # Create connections in the order so both nodes can see the reorg at the same time connect_nodes(self.nodes[1], 0) @@ -217,31 +212,6 @@ class PruneTest(BitcoinTestFramework): # Verify we can now have the data for a block previously pruned assert(self.nodes[2].getblock(self.forkhash)["height"] == self.forkheight) - def mine_full_block(self, node, address): - # Want to create a full block - # We'll generate a 66k transaction below, and 14 of them is close to the 1MB block limit - for j in range(14): - if len(self.utxo) < 14: - self.utxo = node.listunspent() - inputs=[] - outputs = {} - t = self.utxo.pop() - inputs.append({ "txid" : t["txid"], "vout" : t["vout"]}) - remchange = t["amount"] - 100*self.relayfee # Fee must be above min relay rate for 66kb tx - outputs[address]=remchange - # Create a basic transaction that will send change back to ourself after account for a fee - # And then insert the 128 generated transaction outs in the middle rawtx[92] is where the # - # of txouts is stored and is the only thing we overwrite from the original transaction - rawtx = node.createrawtransaction(inputs, outputs) - newtx = rawtx[0:92] - newtx = newtx + self.txouts - newtx = newtx + rawtx[94:] - # Appears to be ever so slightly faster to sign with SIGHASH_NONE - signresult = node.signrawtransaction(newtx,None,None,"NONE") - txid = node.sendrawtransaction(signresult["hex"], True) - # Mine a full sized block which will be these transactions we just created - node.generate(1) - def run_test(self): print("Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours)") diff --git a/qa/rpc-tests/replace-by-fee.py b/qa/rpc-tests/replace-by-fee.py index 34c0f9d795..8aba06c60c 100755 --- a/qa/rpc-tests/replace-by-fee.py +++ b/qa/rpc-tests/replace-by-fee.py @@ -76,7 +76,7 @@ class ReplaceByFeeTest(BitcoinTestFramework): def setup_network(self): self.nodes = [] self.nodes.append(start_node(0, self.options.tmpdir, ["-maxorphantx=1000", "-debug", - "-relaypriority=0", "-whitelist=127.0.0.1", + "-whitelist=127.0.0.1", "-limitancestorcount=50", "-limitancestorsize=101", "-limitdescendantcount=200", diff --git a/qa/rpc-tests/segwit.py b/qa/rpc-tests/segwit.py index 41a1b3b20f..7aa72cca34 100755 --- a/qa/rpc-tests/segwit.py +++ b/qa/rpc-tests/segwit.py @@ -13,6 +13,7 @@ from test_framework.mininode import sha256, ripemd160, CTransaction, CTxIn, COut from test_framework.address import script_to_p2sh, key_to_p2pkh from test_framework.script import CScript, OP_HASH160, OP_CHECKSIG, OP_0, hash160, OP_EQUAL, OP_DUP, OP_EQUALVERIFY, OP_1, OP_2, OP_CHECKMULTISIG from io import BytesIO +from test_framework.mininode import FromHex NODE_0 = 0 NODE_1 = 1 @@ -84,8 +85,8 @@ class SegWitTest(BitcoinTestFramework): def setup_network(self): self.nodes = [] - self.nodes.append(start_node(0, self.options.tmpdir, ["-logtimemicros", "-debug", "-walletprematurewitness"])) - self.nodes.append(start_node(1, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness"])) + self.nodes.append(start_node(0, self.options.tmpdir, ["-logtimemicros", "-debug", "-walletprematurewitness", "-rpcserialversion=0"])) + self.nodes.append(start_node(1, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-rpcserialversion=2"])) self.nodes.append(start_node(2, self.options.tmpdir, ["-logtimemicros", "-debug", "-blockversion=536870915", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness"])) connect_nodes(self.nodes[1], 0) connect_nodes(self.nodes[2], 1) @@ -211,7 +212,20 @@ class SegWitTest(BitcoinTestFramework): block = self.nodes[2].generate(1) #block 432 (first block with new rules; 432 = 144 * 3) sync_blocks(self.nodes) assert_equal(len(self.nodes[2].getrawmempool()), 0) - assert_equal(len(self.nodes[2].getblock(block[0])["tx"]), 5) + segwit_tx_list = self.nodes[2].getblock(block[0])["tx"] + assert_equal(len(segwit_tx_list), 5) + + print("Verify block and transaction serialization rpcs return differing serializations depending on rpc serialization flag") + # Note: node1 has version 2, which is simply >0 and will catch future upgrades in tests + assert(self.nodes[2].getblock(block[0], False) != self.nodes[0].getblock(block[0], False)) + assert(self.nodes[1].getblock(block[0], False) == self.nodes[2].getblock(block[0], False)) + for i in range(len(segwit_tx_list)): + tx = FromHex(CTransaction(), self.nodes[2].gettransaction(segwit_tx_list[i])["hex"]) + assert(self.nodes[2].getrawtransaction(segwit_tx_list[i]) != self.nodes[0].getrawtransaction(segwit_tx_list[i])) + assert(self.nodes[1].getrawtransaction(segwit_tx_list[i], 0) == self.nodes[2].getrawtransaction(segwit_tx_list[i])) + assert(self.nodes[0].getrawtransaction(segwit_tx_list[i]) != self.nodes[2].gettransaction(segwit_tx_list[i])["hex"]) + assert(self.nodes[1].getrawtransaction(segwit_tx_list[i]) == self.nodes[2].gettransaction(segwit_tx_list[i])["hex"]) + assert(self.nodes[0].getrawtransaction(segwit_tx_list[i]) == bytes_to_hex_str(tx.serialize_without_witness())) print("Verify witness txs without witness data are invalid after the fork") self.fail_mine(self.nodes[2], wit_ids[NODE_2][WIT_V0][2], False) diff --git a/qa/rpc-tests/smartfees.py b/qa/rpc-tests/smartfees.py index 74a74f679a..2c56f954a2 100755 --- a/qa/rpc-tests/smartfees.py +++ b/qa/rpc-tests/smartfees.py @@ -159,7 +159,7 @@ class EstimateFeeTest(BitcoinTestFramework): self.nodes = [] # Use node0 to mine blocks for input splitting self.nodes.append(start_node(0, self.options.tmpdir, ["-maxorphantx=1000", - "-relaypriority=0", "-whitelist=127.0.0.1"])) + "-whitelist=127.0.0.1"])) print("This test is time consuming, please be patient") print("Splitting inputs to small size so we can generate low priority tx's") @@ -197,12 +197,12 @@ class EstimateFeeTest(BitcoinTestFramework): # (17k is room enough for 110 or so transactions) self.nodes.append(start_node(1, self.options.tmpdir, ["-blockprioritysize=1500", "-blockmaxsize=17000", - "-maxorphantx=1000", "-relaypriority=0", "-debug=estimatefee"])) + "-maxorphantx=1000", "-debug=estimatefee"])) connect_nodes(self.nodes[1], 0) # Node2 is a stingy miner, that # produces too small blocks (room for only 55 or so transactions) - node2args = ["-blockprioritysize=0", "-blockmaxsize=8000", "-maxorphantx=1000", "-relaypriority=0"] + node2args = ["-blockprioritysize=0", "-blockmaxsize=8000", "-maxorphantx=1000"] self.nodes.append(start_node(2, self.options.tmpdir, node2args)) connect_nodes(self.nodes[0], 2) diff --git a/qa/rpc-tests/test_framework/test_framework.py b/qa/rpc-tests/test_framework/test_framework.py index e6d3e9ab9a..98c4f6070b 100755 --- a/qa/rpc-tests/test_framework/test_framework.py +++ b/qa/rpc-tests/test_framework/test_framework.py @@ -172,7 +172,16 @@ class BitcoinTestFramework(object): os.rmdir(self.options.root) else: print("Not cleaning up dir %s" % self.options.tmpdir) - + if os.getenv("PYTHON_DEBUG", ""): + # Dump the end of the debug logs, to aid in debugging rare + # travis failures. + import glob + filenames = glob.glob(self.options.tmpdir + "/node*/regtest/debug.log") + MAX_LINES_TO_PRINT = 1000 + for f in filenames: + print("From" , f, ":") + from collections import deque + print("".join(deque(open(f), MAX_LINES_TO_PRINT))) if success: print("Tests successful") sys.exit(0) diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 99c30f7651..85898d9f32 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -654,16 +654,15 @@ def create_tx(node, coinbase, to_address, amount): # Create a spend of each passed-in utxo, splicing in "txouts" to each raw # transaction to make it large. See gen_return_txouts() above. -def create_lots_of_big_transactions(node, txouts, utxos, fee): +def create_lots_of_big_transactions(node, txouts, utxos, num, fee): addr = node.getnewaddress() txids = [] - for i in range(len(utxos)): + for _ in range(num): t = utxos.pop() - inputs = [] - inputs.append({ "txid" : t["txid"], "vout" : t["vout"]}) + inputs=[{ "txid" : t["txid"], "vout" : t["vout"]}] outputs = {} - send_value = t['amount'] - fee - outputs[addr] = satoshi_round(send_value) + change = t['amount'] - fee + outputs[addr] = satoshi_round(change) rawtx = node.createrawtransaction(inputs, outputs) newtx = rawtx[0:92] newtx = newtx + txouts @@ -673,6 +672,19 @@ def create_lots_of_big_transactions(node, txouts, utxos, fee): txids.append(txid) return txids +def mine_large_block(node, utxos=None): + # generate a 66k transaction, + # and 14 of them is close to the 1MB block limit + num = 14 + txouts = gen_return_txouts() + utxos = utxos if utxos is not None else [] + if len(utxos) < num: + utxos.clear() + utxos.extend(node.listunspent()) + fee = 100 * node.getnetworkinfo()["relayfee"] + create_lots_of_big_transactions(node, txouts, utxos, num, fee=fee) + node.generate(1) + def get_bip9_status(node, key): info = node.getblockchaininfo() return info['bip9_softforks'][key] |