diff options
author | MarcoFalke <falke.marco@gmail.com> | 2016-10-01 18:44:54 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2016-12-02 16:32:00 +0100 |
commit | facbfa5816b5c947627f9c840169484605a5ca38 (patch) | |
tree | 275206718968d6aad879059233fde1a7a4fe35f4 /qa/rpc-tests/maxuploadtarget.py | |
parent | e22f409f18881b63a8e747036584a71217f40e6e (diff) |
[qa] Get rid of duplicate code
Diffstat (limited to 'qa/rpc-tests/maxuploadtarget.py')
-rwxr-xr-x | qa/rpc-tests/maxuploadtarget.py | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/qa/rpc-tests/maxuploadtarget.py b/qa/rpc-tests/maxuploadtarget.py index d0e9fe9a3f..83168a7ce7 100755 --- a/qa/rpc-tests/maxuploadtarget.py +++ b/qa/rpc-tests/maxuploadtarget.py @@ -81,49 +81,16 @@ 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() - 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 +118,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]) # Store the hash; we'll request this later big_old_block = self.nodes[0].getbestblockhash() @@ -162,11 +129,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]) # 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 |