mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-03 02:08:58 +02:00
Minor Python cleanups to make flake8 pass with the new rules enabled
This commit is contained in:
@@ -129,7 +129,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||
|
||||
# Track whether any sequence locks used should fail
|
||||
should_pass = True
|
||||
|
||||
|
||||
# Track whether this transaction was built with sequence locks
|
||||
using_sequence_locks = False
|
||||
|
||||
@@ -343,7 +343,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||
tx2.rehash()
|
||||
|
||||
self.nodes[0].sendrawtransaction(ToHex(tx2))
|
||||
|
||||
|
||||
# Now make an invalid spend of tx2 according to BIP68
|
||||
sequence_value = 100 # 100 block relative locktime
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class TestP2PConn(P2PInterface):
|
||||
self.block_receive_map[message.block.sha256] += 1
|
||||
|
||||
class MaxUploadTest(BitcoinTestFramework):
|
||||
|
||||
|
||||
def set_test_params(self):
|
||||
self.setup_clean_chain = True
|
||||
self.num_nodes = 1
|
||||
|
||||
@@ -182,7 +182,7 @@ class ProxyTest(BitcoinTestFramework):
|
||||
assert_equal(n1['onion']['proxy'], '%s:%i' % (self.conf2.addr))
|
||||
assert_equal(n1['onion']['proxy_randomize_credentials'], False)
|
||||
assert_equal(n1['onion']['reachable'], True)
|
||||
|
||||
|
||||
n2 = networks_dict(self.nodes[2].getnetworkinfo())
|
||||
for net in ['ipv4','ipv6','onion']:
|
||||
assert_equal(n2[net]['proxy'], '%s:%i' % (self.conf2.addr))
|
||||
|
||||
@@ -186,10 +186,10 @@ class RESTTest (BitcoinTestFramework):
|
||||
self.test_rest_request("/getutxos/checkmempool", http_method='POST', req_type=ReqType.JSON, status=400, ret_type=RetType.OBJ)
|
||||
|
||||
# Test limits
|
||||
long_uri = '/'.join(["{}-{}".format(txid, n) for n in range(20)])
|
||||
long_uri = '/'.join(["{}-{}".format(txid, n_) for n_ in range(20)])
|
||||
self.test_rest_request("/getutxos/checkmempool/{}".format(long_uri), http_method='POST', status=400, ret_type=RetType.OBJ)
|
||||
|
||||
long_uri = '/'.join(['{}-{}'.format(txid, n) for n in range(15)])
|
||||
long_uri = '/'.join(['{}-{}'.format(txid, n_) for n_ in range(15)])
|
||||
self.test_rest_request("/getutxos/checkmempool/{}".format(long_uri), http_method='POST', status=200)
|
||||
|
||||
self.nodes[0].generate(1) # generate block to not affect upcoming tests
|
||||
|
||||
@@ -30,6 +30,6 @@ class P2PMempoolTests(BitcoinTestFramework):
|
||||
|
||||
#mininode must be disconnected at this point
|
||||
assert_equal(len(self.nodes[0].getpeerinfo()), 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
P2PMempoolTests().main()
|
||||
|
||||
@@ -450,7 +450,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||
block = self.build_next_block()
|
||||
|
||||
assert(len(self.utxo) > 0)
|
||||
|
||||
|
||||
# Create a P2WSH transaction.
|
||||
# The witness program will be a bunch of OP_2DROP's, followed by OP_TRUE.
|
||||
# This should give us plenty of room to tweak the spending tx's
|
||||
@@ -562,7 +562,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||
self.log.info("Testing extra witness data in tx")
|
||||
|
||||
assert(len(self.utxo) > 0)
|
||||
|
||||
|
||||
block = self.build_next_block()
|
||||
|
||||
witness_program = CScript([OP_DROP, OP_TRUE])
|
||||
@@ -730,7 +730,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||
witness_program = CScript([OP_DROP, OP_TRUE])
|
||||
witness_hash = sha256(witness_program)
|
||||
scriptPubKey = CScript([OP_0, witness_hash])
|
||||
|
||||
|
||||
# Create a transaction that splits our utxo into many outputs
|
||||
tx = CTransaction()
|
||||
tx.vin.append(CTxIn(COutPoint(self.utxo[0].sha256, self.utxo[0].n), b""))
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Dummy Socks5 server for testing."""
|
||||
|
||||
import socket, threading, queue
|
||||
import socket
|
||||
import threading
|
||||
import queue
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger("TestFramework.socks5")
|
||||
|
||||
### Protocol constants
|
||||
# Protocol constants
|
||||
class Command:
|
||||
CONNECT = 0x01
|
||||
|
||||
@@ -18,7 +20,7 @@ class AddressType:
|
||||
DOMAINNAME = 0x03
|
||||
IPV6 = 0x04
|
||||
|
||||
### Utility functions
|
||||
# Utility functions
|
||||
def recvall(s, n):
|
||||
"""Receive n bytes from a socket, or fail."""
|
||||
rv = bytearray()
|
||||
@@ -30,7 +32,7 @@ def recvall(s, n):
|
||||
n -= len(d)
|
||||
return rv
|
||||
|
||||
### Implementation classes
|
||||
# Implementation classes
|
||||
class Socks5Configuration():
|
||||
"""Proxy configuration."""
|
||||
def __init__(self):
|
||||
@@ -141,7 +143,7 @@ class Socks5Server():
|
||||
thread = threading.Thread(None, conn.handle)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
|
||||
def start(self):
|
||||
assert(not self.running)
|
||||
self.running = True
|
||||
|
||||
@@ -16,7 +16,7 @@ class ImportPrunedFundsTest(BitcoinTestFramework):
|
||||
self.nodes[0].generate(101)
|
||||
|
||||
self.sync_all()
|
||||
|
||||
|
||||
# address
|
||||
address1 = self.nodes[0].getnewaddress()
|
||||
# pubkey
|
||||
|
||||
@@ -17,7 +17,7 @@ class KeyPoolTest(BitcoinTestFramework):
|
||||
addr_before_encrypting_data = nodes[0].getaddressinfo(addr_before_encrypting)
|
||||
wallet_info_old = nodes[0].getwalletinfo()
|
||||
assert(addr_before_encrypting_data['hdmasterkeyid'] == wallet_info_old['hdmasterkeyid'])
|
||||
|
||||
|
||||
# Encrypt wallet and wait to terminate
|
||||
nodes[0].node_encrypt_wallet('test')
|
||||
# Restart node 0
|
||||
|
||||
@@ -92,7 +92,8 @@ class TxnMallTest(BitcoinTestFramework):
|
||||
# Node0's balance should be starting balance, plus 50BTC for another
|
||||
# matured block, minus tx1 and tx2 amounts, and minus transaction fees:
|
||||
expected = starting_balance + fund_foo_tx["fee"] + fund_bar_tx["fee"]
|
||||
if self.options.mine_block: expected += 50
|
||||
if self.options.mine_block:
|
||||
expected += 50
|
||||
expected += tx1["amount"] + tx1["fee"]
|
||||
expected += tx2["amount"] + tx2["fee"]
|
||||
assert_equal(self.nodes[0].getbalance(), expected)
|
||||
@@ -131,7 +132,7 @@ class TxnMallTest(BitcoinTestFramework):
|
||||
tx1 = self.nodes[0].gettransaction(txid1)
|
||||
tx1_clone = self.nodes[0].gettransaction(txid1_clone)
|
||||
tx2 = self.nodes[0].gettransaction(txid2)
|
||||
|
||||
|
||||
# Verify expected confirmations
|
||||
assert_equal(tx1["confirmations"], -2)
|
||||
assert_equal(tx1_clone["confirmations"], 2)
|
||||
|
||||
@@ -27,7 +27,7 @@ class TxnMallTest(BitcoinTestFramework):
|
||||
for i in range(4):
|
||||
assert_equal(self.nodes[i].getbalance(), starting_balance)
|
||||
self.nodes[i].getnewaddress("") # bug workaround, coins generated assigned to first getnewaddress!
|
||||
|
||||
|
||||
# Assign coins to foo and bar accounts:
|
||||
node0_address_foo = self.nodes[0].getnewaddress("foo")
|
||||
fund_foo_txid = self.nodes[0].sendfrom("", node0_address_foo, 1219)
|
||||
@@ -64,7 +64,7 @@ class TxnMallTest(BitcoinTestFramework):
|
||||
# Create two spends using 1 50 BTC coin each
|
||||
txid1 = self.nodes[0].sendfrom("foo", node1_address, 40, 0)
|
||||
txid2 = self.nodes[0].sendfrom("bar", node1_address, 20, 0)
|
||||
|
||||
|
||||
# Have node0 mine a block:
|
||||
if (self.options.mine_block):
|
||||
self.nodes[0].generate(1)
|
||||
@@ -76,7 +76,8 @@ class TxnMallTest(BitcoinTestFramework):
|
||||
# Node0's balance should be starting balance, plus 50BTC for another
|
||||
# matured block, minus 40, minus 20, and minus transaction fees:
|
||||
expected = starting_balance + fund_foo_tx["fee"] + fund_bar_tx["fee"]
|
||||
if self.options.mine_block: expected += 50
|
||||
if self.options.mine_block:
|
||||
expected += 50
|
||||
expected += tx1["amount"] + tx1["fee"]
|
||||
expected += tx2["amount"] + tx2["fee"]
|
||||
assert_equal(self.nodes[0].getbalance(), expected)
|
||||
@@ -93,7 +94,7 @@ class TxnMallTest(BitcoinTestFramework):
|
||||
else:
|
||||
assert_equal(tx1["confirmations"], 0)
|
||||
assert_equal(tx2["confirmations"], 0)
|
||||
|
||||
|
||||
# Now give doublespend and its parents to miner:
|
||||
self.nodes[2].sendrawtransaction(fund_foo_tx["hex"])
|
||||
self.nodes[2].sendrawtransaction(fund_bar_tx["hex"])
|
||||
|
||||
Reference in New Issue
Block a user