From 811b36ba80f4a4199463eb5e7ad0cf9c288c81bb Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Tue, 20 Jun 2017 21:20:50 +0100 Subject: [PATCH] For unused variables reported by pyflakes, either remove the variable, suppress the warning, or fix a bug (if the wrong variable was used). refs #2450 Signed-off-by: Daira Hopwood --- qa/rpc-tests/forknotify.py | 2 +- qa/rpc-tests/hardforkdetection.py | 2 +- qa/rpc-tests/httpbasics.py | 4 ++-- qa/rpc-tests/maxblocksinflight.py | 1 - qa/rpc-tests/mempool_coinbase_spends.py | 3 +-- qa/rpc-tests/mempool_tx_input_limit.py | 3 --- qa/rpc-tests/pruning.py | 4 ++-- qa/rpc-tests/rawtransactions.py | 2 ++ qa/rpc-tests/receivedby.py | 3 +-- qa/rpc-tests/rpcbind_test.py | 1 - qa/rpc-tests/test_framework/util.py | 2 +- qa/rpc-tests/txn_doublespend.py | 2 +- qa/rpc-tests/wallet.py | 12 ++++++------ qa/rpc-tests/wallet_nullifiers.py | 1 + qa/rpc-tests/zmq_test.py | 1 + 15 files changed, 20 insertions(+), 23 deletions(-) diff --git a/qa/rpc-tests/forknotify.py b/qa/rpc-tests/forknotify.py index 059bfadde..1be750a64 100755 --- a/qa/rpc-tests/forknotify.py +++ b/qa/rpc-tests/forknotify.py @@ -19,7 +19,7 @@ class ForkNotifyTest(BitcoinTestFramework): def setup_network(self): self.nodes = [] self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt") - with open(self.alert_filename, 'w') as f: + with open(self.alert_filename, 'w'): pass # Just open then close to create zero-length file self.nodes.append(start_node(0, self.options.tmpdir, ["-blockversion=2", "-alertnotify=echo %s >> \"" + self.alert_filename + "\""])) diff --git a/qa/rpc-tests/hardforkdetection.py b/qa/rpc-tests/hardforkdetection.py index 553f363a9..dbfb5cd34 100755 --- a/qa/rpc-tests/hardforkdetection.py +++ b/qa/rpc-tests/hardforkdetection.py @@ -17,7 +17,7 @@ class HardForkDetectionTest(BitcoinTestFramework): def setup_network(self): self.nodes = [] self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt") - with open(self.alert_filename, 'w') as f: + with open(self.alert_filename, 'w'): pass # Just open then close to create zero-length file self.nodes.append(start_node(0, self.options.tmpdir, ["-blockversion=2", "-alertnotify=echo %s >> \"" + self.alert_filename + "\""])) diff --git a/qa/rpc-tests/httpbasics.py b/qa/rpc-tests/httpbasics.py index 5944bb488..b2ea84b4f 100755 --- a/qa/rpc-tests/httpbasics.py +++ b/qa/rpc-tests/httpbasics.py @@ -44,7 +44,7 @@ class HTTPBasicsTest (BitcoinTestFramework): #send 2nd request without closing connection conn.request('POST', '/', '{"method": "getchaintips"}', headers) out2 = conn.getresponse().read(); - assert_equal('"error":null' in out1, True) #must also response with a correct json-rpc message + assert_equal('"error":null' in out2, True) # must also response with a correct json-rpc message assert_equal(conn.sock!=None, True) #according to http/1.1 connection must still be open! conn.close() @@ -61,7 +61,7 @@ class HTTPBasicsTest (BitcoinTestFramework): #send 2nd request without closing connection conn.request('POST', '/', '{"method": "getchaintips"}', headers) out2 = conn.getresponse().read(); - assert_equal('"error":null' in out1, True) #must also response with a correct json-rpc message + assert_equal('"error":null' in out2, True) # must also response with a correct json-rpc message assert_equal(conn.sock!=None, True) #according to http/1.1 connection must still be open! conn.close() diff --git a/qa/rpc-tests/maxblocksinflight.py b/qa/rpc-tests/maxblocksinflight.py index 4c646040b..227679b69 100755 --- a/qa/rpc-tests/maxblocksinflight.py +++ b/qa/rpc-tests/maxblocksinflight.py @@ -49,7 +49,6 @@ class TestManager(NodeConnCB): def run(self): try: - fail = False self.connection.rpc.generate(1) # Leave IBD numBlocksToGenerate = [ 8, 16, 128, 1024 ] diff --git a/qa/rpc-tests/mempool_coinbase_spends.py b/qa/rpc-tests/mempool_coinbase_spends.py index a5f426092..041de831b 100755 --- a/qa/rpc-tests/mempool_coinbase_spends.py +++ b/qa/rpc-tests/mempool_coinbase_spends.py @@ -35,8 +35,6 @@ class MempoolCoinbaseTest(BitcoinTestFramework): return signresult["hex"] def run_test(self): - start_count = self.nodes[0].getblockcount() - # Mine three blocks. After this, nodes[0] blocks # 101, 102, and 103 are spend-able. new_blocks = self.nodes[1].generate(4) @@ -68,6 +66,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework): # Broadcast and mine 103_1: spend_103_1_id = self.nodes[0].sendrawtransaction(spend_103_1_raw) + [spend_103_1_id] # hush pyflakes self.nodes[0].generate(1) # ... now put spend_101 and spend_102_1 in memory pools: diff --git a/qa/rpc-tests/mempool_tx_input_limit.py b/qa/rpc-tests/mempool_tx_input_limit.py index 8483c5d0a..538122671 100755 --- a/qa/rpc-tests/mempool_tx_input_limit.py +++ b/qa/rpc-tests/mempool_tx_input_limit.py @@ -63,8 +63,6 @@ class MempoolTxInputLimitTest(BitcoinTestFramework): return txid def run_test(self): - start_count = self.nodes[0].getblockcount() - self.nodes[0].generate(100) self.sync_all() # Mine three blocks. After this, nodes[0] blocks @@ -118,7 +116,6 @@ class MempoolTxInputLimitTest(BitcoinTestFramework): assert_equal(set(self.nodes[0].getrawmempool()), set()) # Check 2: sendfrom is limited by -mempooltxinputlimit - node1_taddr = self.nodes[1].getnewaddress(); recipients = [] spend_taddr_amount = spend_zaddr_amount - Decimal('0.0001') spend_taddr_output = Decimal('8') diff --git a/qa/rpc-tests/pruning.py b/qa/rpc-tests/pruning.py index 6bf79933c..2639060fa 100755 --- a/qa/rpc-tests/pruning.py +++ b/qa/rpc-tests/pruning.py @@ -194,7 +194,7 @@ class PruneTest(BitcoinTestFramework): try: self.nodes[2].getblock(self.forkhash) raise AssertionError("Old block wasn't pruned so can't test redownload") - except JSONRPCException as e: + except JSONRPCException: print "Will need to redownload block",self.forkheight # Verify that we have enough history to reorg back to the fork point @@ -257,7 +257,7 @@ class PruneTest(BitcoinTestFramework): 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) + node.sendrawtransaction(signresult["hex"], True) # Mine a full sized block which will be these transactions we just created node.generate(1) diff --git a/qa/rpc-tests/rawtransactions.py b/qa/rpc-tests/rawtransactions.py index 2eb04813f..82dbb7b26 100755 --- a/qa/rpc-tests/rawtransactions.py +++ b/qa/rpc-tests/rawtransactions.py @@ -106,11 +106,13 @@ class RawTransactionsTest(BitcoinTestFramework): mSigObj = self.nodes[2].addmultisigaddress(2, [addr1Obj['pubkey'], addr2Obj['pubkey'], addr3Obj['pubkey']]) mSigObjValid = self.nodes[2].validateaddress(mSigObj) + assert_equal(mSigObjValid['isvalid'], True) txId = self.nodes[0].sendtoaddress(mSigObj, 2.2); decTx = self.nodes[0].gettransaction(txId) rawTx = self.nodes[0].decoderawtransaction(decTx['hex']) sPK = rawTx['vout'][0]['scriptPubKey']['hex'] + [sPK] # hush pyflakes self.sync_all() self.nodes[0].generate(1) self.sync_all() diff --git a/qa/rpc-tests/receivedby.py b/qa/rpc-tests/receivedby.py index fcab3e29d..e928aec8b 100755 --- a/qa/rpc-tests/receivedby.py +++ b/qa/rpc-tests/receivedby.py @@ -14,7 +14,6 @@ def get_sub_array_from_array(object_array, to_match): Finds and returns a sub array from an array of arrays. to_match should be a unique idetifier of a sub array ''' - num_matched = 0 for item in object_array: all_match = True for key,value in to_match.items(): @@ -120,7 +119,7 @@ class ReceivedByTest(BitcoinTestFramework): received_by_account_json = get_sub_array_from_array(self.nodes[1].listreceivedbyaccount(),{"account":account}) if len(received_by_account_json) == 0: raise AssertionError("No accounts found in node") - balance_by_account = rec_by_accountArr = self.nodes[1].getreceivedbyaccount(account) + balance_by_account = self.nodes[1].getreceivedbyaccount(account) txid = self.nodes[0].sendtoaddress(addr, 0.1) self.sync_all() diff --git a/qa/rpc-tests/rpcbind_test.py b/qa/rpc-tests/rpcbind_test.py index ca0f9b1f8..676a4bf32 100755 --- a/qa/rpc-tests/rpcbind_test.py +++ b/qa/rpc-tests/rpcbind_test.py @@ -120,7 +120,6 @@ def main(): check_json_precision() success = False - nodes = [] try: print("Initializing test directory "+options.tmpdir) if not os.path.isdir(options.tmpdir): diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 4cf925c36..8ac09f472 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -152,7 +152,7 @@ def initialize_chain_clean(test_dir, num_nodes): Useful if a test case wants complete control over initialization. """ for i in range(num_nodes): - datadir=initialize_datadir(test_dir, i) + initialize_datadir(test_dir, i) def _rpchost_to_args(rpchost): diff --git a/qa/rpc-tests/txn_doublespend.py b/qa/rpc-tests/txn_doublespend.py index 3a45938b7..bbe383d16 100755 --- a/qa/rpc-tests/txn_doublespend.py +++ b/qa/rpc-tests/txn_doublespend.py @@ -76,7 +76,7 @@ class TxnMallTest(BitcoinTestFramework): assert_equal(tx2["confirmations"], 0) # Now give doublespend to miner: - mutated_txid = self.nodes[2].sendrawtransaction(doublespend["hex"]) + self.nodes[2].sendrawtransaction(doublespend["hex"]) # ... mine a block... self.nodes[2].generate(1) diff --git a/qa/rpc-tests/wallet.py b/qa/rpc-tests/wallet.py index 0e2a7983b..0aeae995d 100755 --- a/qa/rpc-tests/wallet.py +++ b/qa/rpc-tests/wallet.py @@ -105,7 +105,7 @@ class WalletTest (BitcoinTestFramework): # Send 10 BTC normal address = self.nodes[0].getnewaddress("") self.nodes[2].settxfee(Decimal('0.001')) - txid = self.nodes[2].sendtoaddress(address, 10, "", "", False) + self.nodes[2].sendtoaddress(address, 10, "", "", False) self.sync_all() self.nodes[2].generate(1) self.sync_all() @@ -115,7 +115,7 @@ class WalletTest (BitcoinTestFramework): assert_equal(self.nodes[0].getbalance("*"), Decimal('10.00000000')) # Send 10 BTC with subtract fee from amount - txid = self.nodes[2].sendtoaddress(address, 10, "", "", True) + self.nodes[2].sendtoaddress(address, 10, "", "", True) self.sync_all() self.nodes[2].generate(1) self.sync_all() @@ -125,7 +125,7 @@ class WalletTest (BitcoinTestFramework): assert_equal(self.nodes[0].getbalance("*"), Decimal('19.99900000')) # Sendmany 10 BTC - txid = self.nodes[2].sendmany("", {address: 10}, 0, "", []) + self.nodes[2].sendmany("", {address: 10}, 0, "", []) self.sync_all() self.nodes[2].generate(1) self.sync_all() @@ -135,7 +135,7 @@ class WalletTest (BitcoinTestFramework): assert_equal(self.nodes[0].getbalance("*"), Decimal('29.99900000')) # Sendmany 10 BTC with subtract fee from amount - txid = self.nodes[2].sendmany("", {address: 10}, 0, "", [address]) + self.nodes[2].sendmany("", {address: 10}, 0, "", [address]) self.sync_all() self.nodes[2].generate(1) self.sync_all() @@ -176,7 +176,7 @@ class WalletTest (BitcoinTestFramework): signedRawTx = self.nodes[1].signrawtransaction(rawTx) decRawTx = self.nodes[1].decoderawtransaction(signedRawTx['hex']) zeroValueTxid= decRawTx['txid'] - sendResp = self.nodes[1].sendrawtransaction(signedRawTx['hex']) + self.nodes[1].sendrawtransaction(signedRawTx['hex']) self.sync_all() self.nodes[1].generate(1) #mine a block @@ -243,7 +243,7 @@ class WalletTest (BitcoinTestFramework): self.sync_all() mybalance = self.nodes[2].z_getbalance(mytaddr) - assert_equal(self.nodes[2].z_getbalance(mytaddr), Decimal('10.0')); + assert_equal(mybalance, Decimal('10.0')); mytxdetails = self.nodes[2].gettransaction(mytxid) myvjoinsplits = mytxdetails["vjoinsplit"] diff --git a/qa/rpc-tests/wallet_nullifiers.py b/qa/rpc-tests/wallet_nullifiers.py index b69b9d7d1..b7e94b6a6 100755 --- a/qa/rpc-tests/wallet_nullifiers.py +++ b/qa/rpc-tests/wallet_nullifiers.py @@ -154,6 +154,7 @@ class WalletNullifiersTest (BitcoinTestFramework): status = results[0]["status"] assert_equal("success", status) mytxid = results[0]["result"]["txid"] + [mytxid] # hush pyflakes break self.sync_all() diff --git a/qa/rpc-tests/zmq_test.py b/qa/rpc-tests/zmq_test.py index 901d61699..b895c628c 100755 --- a/qa/rpc-tests/zmq_test.py +++ b/qa/rpc-tests/zmq_test.py @@ -42,6 +42,7 @@ class ZMQTest (BitcoinTestFramework): assert_equal(topic, b"hashtx") body = msg[1] nseq = msg[2] + [nseq] # hush pyflakes msgSequence = struct.unpack('