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 <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2017-06-20 21:20:50 +01:00
parent aff0bf7fa1
commit 811b36ba80
15 changed files with 20 additions and 23 deletions

View File

@ -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 + "\""]))

View File

@ -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 + "\""]))

View File

@ -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()

View File

@ -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 ]

View File

@ -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:

View File

@ -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')

View File

@ -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)

View File

@ -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()

View File

@ -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()

View File

@ -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):

View File

@ -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):

View File

@ -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)

View File

@ -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"]

View File

@ -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()

View File

@ -42,6 +42,7 @@ class ZMQTest (BitcoinTestFramework):
assert_equal(topic, b"hashtx")
body = msg[1]
nseq = msg[2]
[nseq] # hush pyflakes
msgSequence = struct.unpack('<I', msg[-1])[-1]
assert_equal(msgSequence, 0) #must be sequence 0 on hashtx