refactor: test: use _ variable for unused loop counters

substitutes "for x in range(N):" by "for _ in range(N):"
indicates to the reader that a block is just repeated N times, and
that the loop counter is not used in the body
This commit is contained in:
Sebastian Falbesoner 2020-08-03 01:10:56 +02:00
parent 82127d27c9
commit dac7a111bd
35 changed files with 83 additions and 83 deletions

View file

@ -166,7 +166,7 @@ class ExampleTest(BitcoinTestFramework):
height = self.nodes[0].getblockcount() height = self.nodes[0].getblockcount()
for i in range(10): for _ in range(10):
# Use the mininode and blocktools functionality to manually build a block # Use the mininode and blocktools functionality to manually build a block
# Calling the generate() rpc is easier, but this allows us to exactly # Calling the generate() rpc is easier, but this allows us to exactly
# control the blocks and transactions. # control the blocks and transactions.

View file

@ -123,7 +123,7 @@ class AssumeValidTest(BitcoinTestFramework):
height += 1 height += 1
# Bury the block 100 deep so the coinbase output is spendable # Bury the block 100 deep so the coinbase output is spendable
for i in range(100): for _ in range(100):
block = create_block(self.tip, create_coinbase(height), self.block_time) block = create_block(self.tip, create_coinbase(height), self.block_time)
block.solve() block.solve()
self.blocks.append(block) self.blocks.append(block)
@ -149,7 +149,7 @@ class AssumeValidTest(BitcoinTestFramework):
height += 1 height += 1
# Bury the assumed valid block 2100 deep # Bury the assumed valid block 2100 deep
for i in range(2100): for _ in range(2100):
block = create_block(self.tip, create_coinbase(height), self.block_time) block = create_block(self.tip, create_coinbase(height), self.block_time)
block.nVersion = 4 block.nVersion = 4
block.solve() block.solve()

View file

@ -141,7 +141,7 @@ class BIP68Test(BitcoinTestFramework):
# some of those inputs to be sequence locked (and randomly choose # some of those inputs to be sequence locked (and randomly choose
# between height/time locking). Small random chance of making the locks # between height/time locking). Small random chance of making the locks
# all pass. # all pass.
for i in range(400): for _ in range(400):
# Randomly choose up to 10 inputs # Randomly choose up to 10 inputs
num_inputs = random.randint(1, 10) num_inputs = random.randint(1, 10)
random.shuffle(utxos) random.shuffle(utxos)
@ -260,7 +260,7 @@ class BIP68Test(BitcoinTestFramework):
# Use prioritisetransaction to lower the effective feerate to 0 # Use prioritisetransaction to lower the effective feerate to 0
self.nodes[0].prioritisetransaction(txid=tx2.hash, fee_delta=int(-self.relayfee*COIN)) self.nodes[0].prioritisetransaction(txid=tx2.hash, fee_delta=int(-self.relayfee*COIN))
cur_time = int(time.time()) cur_time = int(time.time())
for i in range(10): for _ in range(10):
self.nodes[0].setmocktime(cur_time + 600) self.nodes[0].setmocktime(cur_time + 600)
self.nodes[0].generate(1) self.nodes[0].generate(1)
cur_time += 600 cur_time += 600

View file

@ -125,7 +125,7 @@ class FullBlockTest(BitcoinTestFramework):
# collect spendable outputs now to avoid cluttering the code later on # collect spendable outputs now to avoid cluttering the code later on
out = [] out = []
for i in range(NUM_OUTPUTS_TO_COLLECT): for _ in range(NUM_OUTPUTS_TO_COLLECT):
out.append(self.get_spendable_output()) out.append(self.get_spendable_output())
# Start by building a couple of blocks on top (which output is spent is # Start by building a couple of blocks on top (which output is spent is

View file

@ -161,7 +161,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
def generate_blocks(self, number): def generate_blocks(self, number):
test_blocks = [] test_blocks = []
for i in range(number): for _ in range(number):
block = self.create_test_block([]) block = self.create_test_block([])
test_blocks.append(block) test_blocks.append(block)
self.last_block_time += 600 self.last_block_time += 600
@ -209,22 +209,22 @@ class BIP68_112_113Test(BitcoinTestFramework):
# Note we reuse inputs for v1 and v2 txs so must test these separately # Note we reuse inputs for v1 and v2 txs so must test these separately
# 16 normal inputs # 16 normal inputs
bip68inputs = [] bip68inputs = []
for i in range(16): for _ in range(16):
bip68inputs.append(send_generic_input_tx(self.nodes[0], self.coinbase_blocks, self.nodeaddress)) bip68inputs.append(send_generic_input_tx(self.nodes[0], self.coinbase_blocks, self.nodeaddress))
# 2 sets of 16 inputs with 10 OP_CSV OP_DROP (actually will be prepended to spending scriptSig) # 2 sets of 16 inputs with 10 OP_CSV OP_DROP (actually will be prepended to spending scriptSig)
bip112basicinputs = [] bip112basicinputs = []
for j in range(2): for _ in range(2):
inputs = [] inputs = []
for i in range(16): for _ in range(16):
inputs.append(send_generic_input_tx(self.nodes[0], self.coinbase_blocks, self.nodeaddress)) inputs.append(send_generic_input_tx(self.nodes[0], self.coinbase_blocks, self.nodeaddress))
bip112basicinputs.append(inputs) bip112basicinputs.append(inputs)
# 2 sets of 16 varied inputs with (relative_lock_time) OP_CSV OP_DROP (actually will be prepended to spending scriptSig) # 2 sets of 16 varied inputs with (relative_lock_time) OP_CSV OP_DROP (actually will be prepended to spending scriptSig)
bip112diverseinputs = [] bip112diverseinputs = []
for j in range(2): for _ in range(2):
inputs = [] inputs = []
for i in range(16): for _ in range(16):
inputs.append(send_generic_input_tx(self.nodes[0], self.coinbase_blocks, self.nodeaddress)) inputs.append(send_generic_input_tx(self.nodes[0], self.coinbase_blocks, self.nodeaddress))
bip112diverseinputs.append(inputs) bip112diverseinputs.append(inputs)

View file

@ -195,7 +195,7 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
while len(utxo_list) >= 2 and num_transactions < count: while len(utxo_list) >= 2 and num_transactions < count:
tx = CTransaction() tx = CTransaction()
input_amount = 0 input_amount = 0
for i in range(2): for _ in range(2):
utxo = utxo_list.pop() utxo = utxo_list.pop()
tx.vin.append(CTxIn(COutPoint(int(utxo['txid'], 16), utxo['vout']))) tx.vin.append(CTxIn(COutPoint(int(utxo['txid'], 16), utxo['vout'])))
input_amount += int(utxo['amount'] * COIN) input_amount += int(utxo['amount'] * COIN)
@ -205,7 +205,7 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
# Sanity check -- if we chose inputs that are too small, skip # Sanity check -- if we chose inputs that are too small, skip
continue continue
for i in range(3): for _ in range(3):
tx.vout.append(CTxOut(output_amount, hex_str_to_bytes(utxo['scriptPubKey']))) tx.vout.append(CTxOut(output_amount, hex_str_to_bytes(utxo['scriptPubKey'])))
# Sign and send the transaction to get into the mempool # Sign and send the transaction to get into the mempool

View file

@ -176,9 +176,9 @@ class EstimateFeeTest(BitcoinTestFramework):
# We shuffle our confirmed txout set before each set of transactions # We shuffle our confirmed txout set before each set of transactions
# small_txpuzzle_randfee will use the transactions that have inputs already in the chain when possible # small_txpuzzle_randfee will use the transactions that have inputs already in the chain when possible
# resorting to tx's that depend on the mempool when those run out # resorting to tx's that depend on the mempool when those run out
for i in range(numblocks): for _ in range(numblocks):
random.shuffle(self.confutxo) random.shuffle(self.confutxo)
for j in range(random.randrange(100 - 50, 100 + 50)): for _ in range(random.randrange(100 - 50, 100 + 50)):
from_index = random.randint(1, 2) from_index = random.randint(1, 2)
(txhex, fee) = small_txpuzzle_randfee(self.nodes[from_index], self.confutxo, (txhex, fee) = small_txpuzzle_randfee(self.nodes[from_index], self.confutxo,
self.memutxo, Decimal("0.005"), min_fee, min_fee) self.memutxo, Decimal("0.005"), min_fee, min_fee)
@ -243,7 +243,7 @@ class EstimateFeeTest(BitcoinTestFramework):
self.confutxo = self.txouts # Start with the set of confirmed txouts after splitting self.confutxo = self.txouts # Start with the set of confirmed txouts after splitting
self.log.info("Will output estimates for 1/2/3/6/15/25 blocks") self.log.info("Will output estimates for 1/2/3/6/15/25 blocks")
for i in range(2): for _ in range(2):
self.log.info("Creating transactions and mining them with a block size that can't keep up") self.log.info("Creating transactions and mining them with a block size that can't keep up")
# Create transactions and mine 10 small blocks with node 2, but create txs faster than we can mine # Create transactions and mine 10 small blocks with node 2, but create txs faster than we can mine
self.transact_and_mine(10, self.nodes[2]) self.transact_and_mine(10, self.nodes[2])

View file

@ -104,7 +104,7 @@ class MaxUploadTest(BitcoinTestFramework):
assert_equal(len(self.nodes[0].getpeerinfo()), 3) assert_equal(len(self.nodes[0].getpeerinfo()), 3)
# At most a couple more tries should succeed (depending on how long # At most a couple more tries should succeed (depending on how long
# the test has been running so far). # the test has been running so far).
for i in range(3): for _ in range(3):
p2p_conns[0].send_message(getdata_request) p2p_conns[0].send_message(getdata_request)
p2p_conns[0].wait_for_disconnect() p2p_conns[0].wait_for_disconnect()
assert_equal(len(self.nodes[0].getpeerinfo()), 2) assert_equal(len(self.nodes[0].getpeerinfo()), 2)

View file

@ -147,7 +147,7 @@ class PruneTest(BitcoinTestFramework):
# Create stale blocks in manageable sized chunks # Create stale blocks in manageable sized chunks
self.log.info("Mine 24 (stale) blocks on Node 1, followed by 25 (main chain) block reorg from Node 0, for 12 rounds") self.log.info("Mine 24 (stale) blocks on Node 1, followed by 25 (main chain) block reorg from Node 0, for 12 rounds")
for j in range(12): for _ in range(12):
# Disconnect node 0 so it can mine a longer reorg chain without knowing about node 1's soon-to-be-stale chain # Disconnect node 0 so it can mine a longer reorg chain without knowing about node 1's soon-to-be-stale chain
# Node 2 stays connected, so it hears about the stale blocks and then reorg's when node0 reconnects # Node 2 stays connected, so it hears about the stale blocks and then reorg's when node0 reconnects
disconnect_nodes(self.nodes[0], 1) disconnect_nodes(self.nodes[0], 1)

View file

@ -376,7 +376,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
split_value = int((initial_nValue-fee)/(MAX_REPLACEMENT_LIMIT+1)) split_value = int((initial_nValue-fee)/(MAX_REPLACEMENT_LIMIT+1))
outputs = [] outputs = []
for i in range(MAX_REPLACEMENT_LIMIT+1): for _ in range(MAX_REPLACEMENT_LIMIT+1):
outputs.append(CTxOut(split_value, CScript([1]))) outputs.append(CTxOut(split_value, CScript([1])))
splitting_tx = CTransaction() splitting_tx = CTransaction()

View file

@ -126,11 +126,11 @@ class SegWitTest(BitcoinTestFramework):
assert_equal(bip173_ms_addr, script_to_p2wsh(multiscript)) assert_equal(bip173_ms_addr, script_to_p2wsh(multiscript))
p2sh_ids.append([]) p2sh_ids.append([])
wit_ids.append([]) wit_ids.append([])
for v in range(2): for _ in range(2):
p2sh_ids[i].append([]) p2sh_ids[i].append([])
wit_ids[i].append([]) wit_ids[i].append([])
for i in range(5): for _ in range(5):
for n in range(3): for n in range(3):
for v in range(2): for v in range(2):
wit_ids[n][v].append(send_to_witness(v, self.nodes[0], find_spendable_utxo(self.nodes[0], 50), self.pubkey[n], False, Decimal("49.999"))) wit_ids[n][v].append(send_to_witness(v, self.nodes[0], find_spendable_utxo(self.nodes[0], 50), self.pubkey[n], False, Decimal("49.999")))

View file

@ -31,7 +31,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
for (txid, vout) in zip(parent_txids, vouts): for (txid, vout) in zip(parent_txids, vouts):
inputs.append({'txid' : txid, 'vout' : vout}) inputs.append({'txid' : txid, 'vout' : vout})
outputs = {} outputs = {}
for i in range(num_outputs): for _ in range(num_outputs):
outputs[node.getnewaddress()] = send_value outputs[node.getnewaddress()] = send_value
rawtx = node.createrawtransaction(inputs, outputs, 0, True) rawtx = node.createrawtransaction(inputs, outputs, 0, True)
signedtx = node.signrawtransactionwithwallet(rawtx) signedtx = node.signrawtransactionwithwallet(rawtx)

View file

@ -48,7 +48,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
send_value = satoshi_round((value - fee)/num_outputs) send_value = satoshi_round((value - fee)/num_outputs)
inputs = [ {'txid' : parent_txid, 'vout' : vout} ] inputs = [ {'txid' : parent_txid, 'vout' : vout} ]
outputs = {} outputs = {}
for i in range(num_outputs): for _ in range(num_outputs):
outputs[node.getnewaddress()] = send_value outputs[node.getnewaddress()] = send_value
rawtx = node.createrawtransaction(inputs, outputs) rawtx = node.createrawtransaction(inputs, outputs)
signedtx = node.signrawtransactionwithwallet(rawtx) signedtx = node.signrawtransactionwithwallet(rawtx)
@ -70,7 +70,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
# MAX_ANCESTORS transactions off a confirmed tx should be fine # MAX_ANCESTORS transactions off a confirmed tx should be fine
chain = [] chain = []
witness_chain = [] witness_chain = []
for i in range(MAX_ANCESTORS): for _ in range(MAX_ANCESTORS):
(txid, sent_value) = self.chain_transaction(self.nodes[0], txid, 0, value, fee, 1) (txid, sent_value) = self.chain_transaction(self.nodes[0], txid, 0, value, fee, 1)
value = sent_value value = sent_value
chain.append(txid) chain.append(txid)
@ -245,7 +245,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
# Sign and send up to MAX_DESCENDANT transactions chained off the parent tx # Sign and send up to MAX_DESCENDANT transactions chained off the parent tx
chain = [] # save sent txs for the purpose of checking node1's mempool later (see below) chain = [] # save sent txs for the purpose of checking node1's mempool later (see below)
for i in range(MAX_DESCENDANTS - 1): for _ in range(MAX_DESCENDANTS - 1):
utxo = transaction_package.pop(0) utxo = transaction_package.pop(0)
(txid, sent_value) = self.chain_transaction(self.nodes[0], utxo['txid'], utxo['vout'], utxo['amount'], fee, 10) (txid, sent_value) = self.chain_transaction(self.nodes[0], utxo['txid'], utxo['vout'], utxo['amount'], fee, 10)
chain.append(txid) chain.append(txid)
@ -312,7 +312,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
send_value = satoshi_round((value - fee)/2) send_value = satoshi_round((value - fee)/2)
inputs = [ {'txid' : txid, 'vout' : vout} ] inputs = [ {'txid' : txid, 'vout' : vout} ]
outputs = {} outputs = {}
for i in range(2): for _ in range(2):
outputs[self.nodes[0].getnewaddress()] = send_value outputs[self.nodes[0].getnewaddress()] = send_value
rawtx = self.nodes[0].createrawtransaction(inputs, outputs) rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx) signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx)
@ -326,7 +326,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
# Create tx2-7 # Create tx2-7
vout = 1 vout = 1
txid = tx0_id txid = tx0_id
for i in range(6): for _ in range(6):
(txid, sent_value) = self.chain_transaction(self.nodes[0], txid, vout, value, fee, 1) (txid, sent_value) = self.chain_transaction(self.nodes[0], txid, vout, value, fee, 1)
vout = 0 vout = 0
value = sent_value value = sent_value

View file

@ -62,7 +62,7 @@ class MempoolPersistTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.log.debug("Send 5 transactions from node2 (to its own address)") self.log.debug("Send 5 transactions from node2 (to its own address)")
tx_creation_time_lower = int(time.time()) tx_creation_time_lower = int(time.time())
for i in range(5): for _ in range(5):
last_txid = self.nodes[2].sendtoaddress(self.nodes[2].getnewaddress(), Decimal("10")) last_txid = self.nodes[2].sendtoaddress(self.nodes[2].getnewaddress(), Decimal("10"))
node2_balance = self.nodes[2].getbalance() node2_balance = self.nodes[2].getbalance()
self.sync_all() self.sync_all()

View file

@ -73,7 +73,7 @@ class MempoolUpdateFromBlockTest(BitcoinTestFramework):
n_outputs = size - tx_count n_outputs = size - tx_count
output_value = ((inputs_value - fee) / Decimal(n_outputs)).quantize(Decimal('0.00000001')) output_value = ((inputs_value - fee) / Decimal(n_outputs)).quantize(Decimal('0.00000001'))
outputs = {} outputs = {}
for n in range(0, n_outputs): for _ in range(n_outputs):
outputs[self.nodes[0].getnewaddress()] = output_value outputs[self.nodes[0].getnewaddress()] = output_value
else: else:
output_value = (inputs_value - fee).quantize(Decimal('0.00000001')) output_value = (inputs_value - fee).quantize(Decimal('0.00000001'))

View file

@ -125,7 +125,7 @@ class CompactBlocksTest(BitcoinTestFramework):
out_value = total_value // 10 out_value = total_value // 10
tx = CTransaction() tx = CTransaction()
tx.vin.append(CTxIn(COutPoint(block.vtx[0].sha256, 0), b'')) tx.vin.append(CTxIn(COutPoint(block.vtx[0].sha256, 0), b''))
for i in range(10): for _ in range(10):
tx.vout.append(CTxOut(out_value, CScript([OP_TRUE]))) tx.vout.append(CTxOut(out_value, CScript([OP_TRUE])))
tx.rehash() tx.rehash()
@ -266,7 +266,7 @@ class CompactBlocksTest(BitcoinTestFramework):
address = node.getnewaddress() address = node.getnewaddress()
segwit_tx_generated = False segwit_tx_generated = False
for i in range(num_transactions): for _ in range(num_transactions):
txid = node.sendtoaddress(address, 0.1) txid = node.sendtoaddress(address, 0.1)
hex_tx = node.gettransaction(txid)["hex"] hex_tx = node.gettransaction(txid)["hex"]
tx = FromHex(CTransaction(), hex_tx) tx = FromHex(CTransaction(), hex_tx)
@ -418,7 +418,7 @@ class CompactBlocksTest(BitcoinTestFramework):
def build_block_with_transactions(self, node, utxo, num_transactions): def build_block_with_transactions(self, node, utxo, num_transactions):
block = self.build_block_on_tip(node) block = self.build_block_on_tip(node)
for i in range(num_transactions): for _ in range(num_transactions):
tx = CTransaction() tx = CTransaction()
tx.vin.append(CTxIn(COutPoint(utxo[0], utxo[1]), b'')) tx.vin.append(CTxIn(COutPoint(utxo[0], utxo[1]), b''))
tx.vout.append(CTxOut(utxo[2] - 1000, CScript([OP_TRUE, OP_DROP] * 15 + [OP_TRUE]))) tx.vout.append(CTxOut(utxo[2] - 1000, CScript([OP_TRUE, OP_DROP] * 15 + [OP_TRUE])))
@ -627,7 +627,7 @@ class CompactBlocksTest(BitcoinTestFramework):
# Test that requesting old compactblocks doesn't work. # Test that requesting old compactblocks doesn't work.
MAX_CMPCTBLOCK_DEPTH = 5 MAX_CMPCTBLOCK_DEPTH = 5
new_blocks = [] new_blocks = []
for i in range(MAX_CMPCTBLOCK_DEPTH + 1): for _ in range(MAX_CMPCTBLOCK_DEPTH + 1):
test_node.clear_block_announcement() test_node.clear_block_announcement()
new_blocks.append(node.generate(1)[0]) new_blocks.append(node.generate(1)[0])
wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock) wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)

View file

@ -19,7 +19,7 @@ def hashToHex(hash):
# Wait up to 60 secs to see if the testnode has received all the expected invs # Wait up to 60 secs to see if the testnode has received all the expected invs
def allInvsMatch(invsExpected, testnode): def allInvsMatch(invsExpected, testnode):
for x in range(60): for _ in range(60):
with mininode_lock: with mininode_lock:
if (sorted(invsExpected) == sorted(testnode.txinvs)): if (sorted(invsExpected) == sorted(testnode.txinvs)):
return True return True
@ -91,7 +91,7 @@ class FeeFilterTest(BitcoinTestFramework):
# Test that invs are received by test connection for all txs at # Test that invs are received by test connection for all txs at
# feerate of .2 sat/byte # feerate of .2 sat/byte
node1.settxfee(Decimal("0.00000200")) node1.settxfee(Decimal("0.00000200"))
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for x in range(3)] txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for _ in range(3)]
assert allInvsMatch(txids, conn) assert allInvsMatch(txids, conn)
conn.clear_invs() conn.clear_invs()
@ -100,14 +100,14 @@ class FeeFilterTest(BitcoinTestFramework):
# Test that txs are still being received by test connection (paying .15 sat/byte) # Test that txs are still being received by test connection (paying .15 sat/byte)
node1.settxfee(Decimal("0.00000150")) node1.settxfee(Decimal("0.00000150"))
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for x in range(3)] txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for _ in range(3)]
assert allInvsMatch(txids, conn) assert allInvsMatch(txids, conn)
conn.clear_invs() conn.clear_invs()
# Change tx fee rate to .1 sat/byte and test they are no longer received # Change tx fee rate to .1 sat/byte and test they are no longer received
# by the test connection # by the test connection
node1.settxfee(Decimal("0.00000100")) node1.settxfee(Decimal("0.00000100"))
[node1.sendtoaddress(node1.getnewaddress(), 1) for x in range(3)] [node1.sendtoaddress(node1.getnewaddress(), 1) for _ in range(3)]
self.sync_mempools() # must be sure node 0 has received all txs self.sync_mempools() # must be sure node 0 has received all txs
# Send one transaction from node0 that should be received, so that we # Send one transaction from node0 that should be received, so that we
@ -124,7 +124,7 @@ class FeeFilterTest(BitcoinTestFramework):
# Remove fee filter and check that txs are received again # Remove fee filter and check that txs are received again
conn.send_and_ping(msg_feefilter(0)) conn.send_and_ping(msg_feefilter(0))
txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for x in range(3)] txids = [node1.sendtoaddress(node1.getnewaddress(), 1) for _ in range(3)]
assert allInvsMatch(txids, conn) assert allInvsMatch(txids, conn)
conn.clear_invs() conn.clear_invs()

View file

@ -942,7 +942,7 @@ class SegWitTest(BitcoinTestFramework):
parent_tx = CTransaction() parent_tx = CTransaction()
parent_tx.vin.append(CTxIn(prevout, b"")) parent_tx.vin.append(CTxIn(prevout, b""))
child_value = int(value / NUM_OUTPUTS) child_value = int(value / NUM_OUTPUTS)
for i in range(NUM_OUTPUTS): for _ in range(NUM_OUTPUTS):
parent_tx.vout.append(CTxOut(child_value, script_pubkey)) parent_tx.vout.append(CTxOut(child_value, script_pubkey))
parent_tx.vout[0].nValue -= 50000 parent_tx.vout[0].nValue -= 50000
assert parent_tx.vout[0].nValue > 0 assert parent_tx.vout[0].nValue > 0
@ -952,7 +952,7 @@ class SegWitTest(BitcoinTestFramework):
for i in range(NUM_OUTPUTS): for i in range(NUM_OUTPUTS):
child_tx.vin.append(CTxIn(COutPoint(parent_tx.sha256, i), b"")) child_tx.vin.append(CTxIn(COutPoint(parent_tx.sha256, i), b""))
child_tx.vout = [CTxOut(value - 100000, CScript([OP_TRUE]))] child_tx.vout = [CTxOut(value - 100000, CScript([OP_TRUE]))]
for i in range(NUM_OUTPUTS): for _ in range(NUM_OUTPUTS):
child_tx.wit.vtxinwit.append(CTxInWitness()) child_tx.wit.vtxinwit.append(CTxInWitness())
child_tx.wit.vtxinwit[-1].scriptWitness.stack = [b'a' * 195] * (2 * NUM_DROPS) + [witness_program] child_tx.wit.vtxinwit[-1].scriptWitness.stack = [b'a' * 195] * (2 * NUM_DROPS) + [witness_program]
child_tx.rehash() child_tx.rehash()
@ -1199,7 +1199,7 @@ class SegWitTest(BitcoinTestFramework):
tx = CTransaction() tx = CTransaction()
tx.vin.append(CTxIn(COutPoint(self.utxo[0].sha256, self.utxo[0].n), b"")) tx.vin.append(CTxIn(COutPoint(self.utxo[0].sha256, self.utxo[0].n), b""))
value = self.utxo[0].nValue value = self.utxo[0].nValue
for i in range(10): for _ in range(10):
tx.vout.append(CTxOut(int(value / 10), script_pubkey)) tx.vout.append(CTxOut(int(value / 10), script_pubkey))
tx.vout[0].nValue -= 1000 tx.vout[0].nValue -= 1000
assert tx.vout[0].nValue >= 0 assert tx.vout[0].nValue >= 0
@ -1372,7 +1372,7 @@ class SegWitTest(BitcoinTestFramework):
tx = CTransaction() tx = CTransaction()
tx.vin.append(CTxIn(COutPoint(self.utxo[0].sha256, self.utxo[0].n), b"")) tx.vin.append(CTxIn(COutPoint(self.utxo[0].sha256, self.utxo[0].n), b""))
split_value = (self.utxo[0].nValue - 4000) // NUM_SEGWIT_VERSIONS split_value = (self.utxo[0].nValue - 4000) // NUM_SEGWIT_VERSIONS
for i in range(NUM_SEGWIT_VERSIONS): for _ in range(NUM_SEGWIT_VERSIONS):
tx.vout.append(CTxOut(split_value, CScript([OP_TRUE]))) tx.vout.append(CTxOut(split_value, CScript([OP_TRUE])))
tx.rehash() tx.rehash()
block = self.build_next_block() block = self.build_next_block()
@ -1646,7 +1646,7 @@ class SegWitTest(BitcoinTestFramework):
tx = CTransaction() tx = CTransaction()
tx.vin.append(CTxIn(COutPoint(prev_utxo.sha256, prev_utxo.n), b"")) tx.vin.append(CTxIn(COutPoint(prev_utxo.sha256, prev_utxo.n), b""))
split_value = prev_utxo.nValue // NUM_SIGHASH_TESTS split_value = prev_utxo.nValue // NUM_SIGHASH_TESTS
for i in range(NUM_SIGHASH_TESTS): for _ in range(NUM_SIGHASH_TESTS):
tx.vout.append(CTxOut(split_value, script_pubkey)) tx.vout.append(CTxOut(split_value, script_pubkey))
tx.wit.vtxinwit.append(CTxInWitness()) tx.wit.vtxinwit.append(CTxInWitness())
sign_p2pk_witness_input(witness_program, tx, 0, SIGHASH_ALL, prev_utxo.nValue, key) sign_p2pk_witness_input(witness_program, tx, 0, SIGHASH_ALL, prev_utxo.nValue, key)
@ -1676,7 +1676,7 @@ class SegWitTest(BitcoinTestFramework):
tx.wit.vtxinwit.append(CTxInWitness()) tx.wit.vtxinwit.append(CTxInWitness())
total_value += temp_utxos[i].nValue total_value += temp_utxos[i].nValue
split_value = total_value // num_outputs split_value = total_value // num_outputs
for i in range(num_outputs): for _ in range(num_outputs):
tx.vout.append(CTxOut(split_value, script_pubkey)) tx.vout.append(CTxOut(split_value, script_pubkey))
for i in range(num_inputs): for i in range(num_inputs):
# Now try to sign each input, using a random hashtype. # Now try to sign each input, using a random hashtype.
@ -1974,7 +1974,7 @@ class SegWitTest(BitcoinTestFramework):
split_value = self.utxo[0].nValue // outputs split_value = self.utxo[0].nValue // outputs
tx = CTransaction() tx = CTransaction()
tx.vin.append(CTxIn(COutPoint(self.utxo[0].sha256, self.utxo[0].n), b"")) tx.vin.append(CTxIn(COutPoint(self.utxo[0].sha256, self.utxo[0].n), b""))
for i in range(outputs): for _ in range(outputs):
tx.vout.append(CTxOut(split_value, script_pubkey)) tx.vout.append(CTxOut(split_value, script_pubkey))
tx.vout[-2].scriptPubKey = script_pubkey_toomany tx.vout[-2].scriptPubKey = script_pubkey_toomany
tx.vout[-1].scriptPubKey = script_pubkey_justright tx.vout[-1].scriptPubKey = script_pubkey_justright
@ -2060,7 +2060,7 @@ class SegWitTest(BitcoinTestFramework):
if (len(tx.wit.vtxinwit) != len(tx.vin)): if (len(tx.wit.vtxinwit) != len(tx.vin)):
# vtxinwit must have the same length as vin # vtxinwit must have the same length as vin
tx.wit.vtxinwit = tx.wit.vtxinwit[:len(tx.vin)] tx.wit.vtxinwit = tx.wit.vtxinwit[:len(tx.vin)]
for i in range(len(tx.wit.vtxinwit), len(tx.vin)): for _ in range(len(tx.wit.vtxinwit), len(tx.vin)):
tx.wit.vtxinwit.append(CTxInWitness()) tx.wit.vtxinwit.append(CTxInWitness())
r += tx.wit.serialize() r += tx.wit.serialize()
r += struct.pack("<I", tx.nLockTime) r += struct.pack("<I", tx.nLockTime)

View file

@ -328,7 +328,7 @@ class SendHeadersTest(BitcoinTestFramework):
for j in range(2): for j in range(2):
self.log.debug("Part 2.{}.{}: starting...".format(i, j)) self.log.debug("Part 2.{}.{}: starting...".format(i, j))
blocks = [] blocks = []
for b in range(i + 1): for _ in range(i + 1):
blocks.append(create_block(tip, create_coinbase(height), block_time)) blocks.append(create_block(tip, create_coinbase(height), block_time))
blocks[-1].solve() blocks[-1].solve()
tip = blocks[-1].sha256 tip = blocks[-1].sha256
@ -443,7 +443,7 @@ class SendHeadersTest(BitcoinTestFramework):
# Create 2 blocks. Send the blocks, then send the headers. # Create 2 blocks. Send the blocks, then send the headers.
blocks = [] blocks = []
for b in range(2): for _ in range(2):
blocks.append(create_block(tip, create_coinbase(height), block_time)) blocks.append(create_block(tip, create_coinbase(height), block_time))
blocks[-1].solve() blocks[-1].solve()
tip = blocks[-1].sha256 tip = blocks[-1].sha256
@ -461,7 +461,7 @@ class SendHeadersTest(BitcoinTestFramework):
# This time, direct fetch should work # This time, direct fetch should work
blocks = [] blocks = []
for b in range(3): for _ in range(3):
blocks.append(create_block(tip, create_coinbase(height), block_time)) blocks.append(create_block(tip, create_coinbase(height), block_time))
blocks[-1].solve() blocks[-1].solve()
tip = blocks[-1].sha256 tip = blocks[-1].sha256
@ -482,7 +482,7 @@ class SendHeadersTest(BitcoinTestFramework):
blocks = [] blocks = []
# Create extra blocks for later # Create extra blocks for later
for b in range(20): for _ in range(20):
blocks.append(create_block(tip, create_coinbase(height), block_time)) blocks.append(create_block(tip, create_coinbase(height), block_time))
blocks[-1].solve() blocks[-1].solve()
tip = blocks[-1].sha256 tip = blocks[-1].sha256
@ -529,7 +529,7 @@ class SendHeadersTest(BitcoinTestFramework):
test_node.last_message.pop("getdata", None) test_node.last_message.pop("getdata", None)
blocks = [] blocks = []
# Create two more blocks. # Create two more blocks.
for j in range(2): for _ in range(2):
blocks.append(create_block(tip, create_coinbase(height), block_time)) blocks.append(create_block(tip, create_coinbase(height), block_time))
blocks[-1].solve() blocks[-1].solve()
tip = blocks[-1].sha256 tip = blocks[-1].sha256
@ -550,7 +550,7 @@ class SendHeadersTest(BitcoinTestFramework):
# Now we test that if we repeatedly don't send connecting headers, we # Now we test that if we repeatedly don't send connecting headers, we
# don't go into an infinite loop trying to get them to connect. # don't go into an infinite loop trying to get them to connect.
MAX_UNCONNECTING_HEADERS = 10 MAX_UNCONNECTING_HEADERS = 10
for j in range(MAX_UNCONNECTING_HEADERS + 1): for _ in range(MAX_UNCONNECTING_HEADERS + 1):
blocks.append(create_block(tip, create_coinbase(height), block_time)) blocks.append(create_block(tip, create_coinbase(height), block_time))
blocks[-1].solve() blocks[-1].solve()
tip = blocks[-1].sha256 tip = blocks[-1].sha256

View file

@ -162,7 +162,7 @@ class TxDownloadTest(BitcoinTestFramework):
# Setup the p2p connections # Setup the p2p connections
self.peers = [] self.peers = []
for node in self.nodes: for node in self.nodes:
for i in range(NUM_INBOUND): for _ in range(NUM_INBOUND):
self.peers.append(node.add_p2p_connection(TestP2PConn())) self.peers.append(node.add_p2p_connection(TestP2PConn()))
self.log.info("Nodes are setup with {} incoming connections each".format(NUM_INBOUND)) self.log.info("Nodes are setup with {} incoming connections each".format(NUM_INBOUND))

View file

@ -554,7 +554,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.nodes[1].generate(1) self.nodes[1].generate(1)
self.sync_all() self.sync_all()
for i in range(0,20): for _ in range(20):
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01) self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.nodes[0].generate(1) self.nodes[0].generate(1)
self.sync_all() self.sync_all()
@ -582,7 +582,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.nodes[1].generate(1) self.nodes[1].generate(1)
self.sync_all() self.sync_all()
for i in range(0,20): for _ in range(20):
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01) self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.nodes[0].generate(1) self.nodes[0].generate(1)
self.sync_all() self.sync_all()

View file

@ -55,7 +55,7 @@ class GenerateBlockTest(BitcoinTestFramework):
node.generatetoaddress(110, address) node.generatetoaddress(110, address)
# Generate some extra mempool transactions to verify they don't get mined # Generate some extra mempool transactions to verify they don't get mined
for i in range(10): for _ in range(10):
node.sendtoaddress(address, 0.001) node.sendtoaddress(address, 0.001)
self.log.info('Generate block with txid') self.log.info('Generate block with txid')

View file

@ -430,7 +430,7 @@ class PSBTTest(BitcoinTestFramework):
# Check that joining shuffles the inputs and outputs # Check that joining shuffles the inputs and outputs
# 10 attempts should be enough to get a shuffled join # 10 attempts should be enough to get a shuffled join
shuffled = False shuffled = False
for i in range(0, 10): for _ in range(10):
shuffled_joined = self.nodes[0].joinpsbts([psbt, psbt2]) shuffled_joined = self.nodes[0].joinpsbts([psbt, psbt2])
shuffled |= joined != shuffled_joined shuffled |= joined != shuffled_joined
if shuffled: if shuffled:

View file

@ -111,7 +111,7 @@ def deser_uint256(f):
def ser_uint256(u): def ser_uint256(u):
rs = b"" rs = b""
for i in range(8): for _ in range(8):
rs += struct.pack("<I", u & 0xFFFFFFFF) rs += struct.pack("<I", u & 0xFFFFFFFF)
u >>= 32 u >>= 32
return rs return rs
@ -134,7 +134,7 @@ def uint256_from_compact(c):
def deser_vector(f, c): def deser_vector(f, c):
nit = deser_compact_size(f) nit = deser_compact_size(f)
r = [] r = []
for i in range(nit): for _ in range(nit):
t = c() t = c()
t.deserialize(f) t.deserialize(f)
r.append(t) r.append(t)
@ -157,7 +157,7 @@ def ser_vector(l, ser_function_name=None):
def deser_uint256_vector(f): def deser_uint256_vector(f):
nit = deser_compact_size(f) nit = deser_compact_size(f)
r = [] r = []
for i in range(nit): for _ in range(nit):
t = deser_uint256(f) t = deser_uint256(f)
r.append(t) r.append(t)
return r return r
@ -173,7 +173,7 @@ def ser_uint256_vector(l):
def deser_string_vector(f): def deser_string_vector(f):
nit = deser_compact_size(f) nit = deser_compact_size(f)
r = [] r = []
for i in range(nit): for _ in range(nit):
t = deser_string(f) t = deser_string(f)
r.append(t) r.append(t)
return r return r
@ -467,7 +467,7 @@ class CTransaction:
else: else:
self.vout = deser_vector(f, CTxOut) self.vout = deser_vector(f, CTxOut)
if flags != 0: if flags != 0:
self.wit.vtxinwit = [CTxInWitness() for i in range(len(self.vin))] self.wit.vtxinwit = [CTxInWitness() for _ in range(len(self.vin))]
self.wit.deserialize(f) self.wit.deserialize(f)
else: else:
self.wit = CTxWitness() self.wit = CTxWitness()
@ -500,7 +500,7 @@ class CTransaction:
if (len(self.wit.vtxinwit) != len(self.vin)): if (len(self.wit.vtxinwit) != len(self.vin)):
# vtxinwit must have the same length as vin # vtxinwit must have the same length as vin
self.wit.vtxinwit = self.wit.vtxinwit[:len(self.vin)] self.wit.vtxinwit = self.wit.vtxinwit[:len(self.vin)]
for i in range(len(self.wit.vtxinwit), len(self.vin)): for _ in range(len(self.wit.vtxinwit), len(self.vin)):
self.wit.vtxinwit.append(CTxInWitness()) self.wit.vtxinwit.append(CTxInWitness())
r += self.wit.serialize() r += self.wit.serialize()
r += struct.pack("<I", self.nLockTime) r += struct.pack("<I", self.nLockTime)
@ -735,7 +735,7 @@ class P2PHeaderAndShortIDs:
self.header.deserialize(f) self.header.deserialize(f)
self.nonce = struct.unpack("<Q", f.read(8))[0] self.nonce = struct.unpack("<Q", f.read(8))[0]
self.shortids_length = deser_compact_size(f) self.shortids_length = deser_compact_size(f)
for i in range(self.shortids_length): for _ in range(self.shortids_length):
# shortids are defined to be 6 bytes in the spec, so append # shortids are defined to be 6 bytes in the spec, so append
# two zero bytes and read it in as an 8-byte number # two zero bytes and read it in as an 8-byte number
self.shortids.append(struct.unpack("<Q", f.read(6) + b'\x00\x00')[0]) self.shortids.append(struct.unpack("<Q", f.read(6) + b'\x00\x00')[0])
@ -852,7 +852,7 @@ class BlockTransactionsRequest:
def deserialize(self, f): def deserialize(self, f):
self.blockhash = deser_uint256(f) self.blockhash = deser_uint256(f)
indexes_length = deser_compact_size(f) indexes_length = deser_compact_size(f)
for i in range(indexes_length): for _ in range(indexes_length):
self.indexes.append(deser_compact_size(f)) self.indexes.append(deser_compact_size(f))
def serialize(self): def serialize(self):

View file

@ -646,7 +646,7 @@ def LegacySignatureHash(script, txTo, inIdx, hashtype):
tmp = txtmp.vout[outIdx] tmp = txtmp.vout[outIdx]
txtmp.vout = [] txtmp.vout = []
for i in range(outIdx): for _ in range(outIdx):
txtmp.vout.append(CTxOut(-1)) txtmp.vout.append(CTxOut(-1))
txtmp.vout.append(tmp) txtmp.vout.append(tmp)

View file

@ -529,7 +529,7 @@ def create_confirmed_utxos(fee, node, count):
addr2 = node.getnewaddress() addr2 = node.getnewaddress()
if iterations <= 0: if iterations <= 0:
return utxos return utxos
for i in range(iterations): for _ in range(iterations):
t = utxos.pop() t = utxos.pop()
inputs = [] inputs = []
inputs.append({"txid": t["txid"], "vout": t["vout"]}) inputs.append({"txid": t["txid"], "vout": t["vout"]})
@ -556,7 +556,7 @@ def gen_return_txouts():
# So we have big transactions (and therefore can't fit very many into each block) # So we have big transactions (and therefore can't fit very many into each block)
# create one script_pubkey # create one script_pubkey
script_pubkey = "6a4d0200" # OP_RETURN OP_PUSH2 512 bytes script_pubkey = "6a4d0200" # OP_RETURN OP_PUSH2 512 bytes
for i in range(512): for _ in range(512):
script_pubkey = script_pubkey + "01" script_pubkey = script_pubkey + "01"
# concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change # concatenate 128 txouts of above script_pubkey which we'll insert before the txout for change
txouts = [] txouts = []
@ -564,7 +564,7 @@ def gen_return_txouts():
txout = CTxOut() txout = CTxOut()
txout.nValue = 0 txout.nValue = 0
txout.scriptPubKey = hex_str_to_bytes(script_pubkey) txout.scriptPubKey = hex_str_to_bytes(script_pubkey)
for k in range(128): for _ in range(128):
txouts.append(txout) txouts.append(txout)
return txouts return txouts

View file

@ -129,7 +129,7 @@ class WalletBackupTest(BitcoinTestFramework):
self.log.info("Creating transactions") self.log.info("Creating transactions")
# Five rounds of sending each other transactions. # Five rounds of sending each other transactions.
for i in range(5): for _ in range(5):
self.do_one_round() self.do_one_round()
self.log.info("Backing up") self.log.info("Backing up")
@ -142,7 +142,7 @@ class WalletBackupTest(BitcoinTestFramework):
self.nodes[2].dumpwallet(os.path.join(self.nodes[2].datadir, 'wallet.dump')) self.nodes[2].dumpwallet(os.path.join(self.nodes[2].datadir, 'wallet.dump'))
self.log.info("More transactions") self.log.info("More transactions")
for i in range(5): for _ in range(5):
self.do_one_round() self.do_one_round()
# Generate 101 more blocks, so any fees paid mature # Generate 101 more blocks, so any fees paid mature

View file

@ -569,7 +569,7 @@ class WalletTest(BitcoinTestFramework):
# So we should be able to generate exactly chainlimit txs for each original output # So we should be able to generate exactly chainlimit txs for each original output
sending_addr = self.nodes[1].getnewaddress() sending_addr = self.nodes[1].getnewaddress()
txid_list = [] txid_list = []
for i in range(chainlimit * 2): for _ in range(chainlimit * 2):
txid_list.append(self.nodes[0].sendtoaddress(sending_addr, Decimal('0.0001'))) txid_list.append(self.nodes[0].sendtoaddress(sending_addr, Decimal('0.0001')))
assert_equal(self.nodes[0].getmempoolinfo()['size'], chainlimit * 2) assert_equal(self.nodes[0].getmempoolinfo()['size'], chainlimit * 2)
assert_equal(len(txid_list), chainlimit * 2) assert_equal(len(txid_list), chainlimit * 2)

View file

@ -62,7 +62,7 @@ class BumpFeeTest(BitcoinTestFramework):
self.log.info("Mining blocks...") self.log.info("Mining blocks...")
peer_node.generate(110) peer_node.generate(110)
self.sync_all() self.sync_all()
for i in range(25): for _ in range(25):
peer_node.sendtoaddress(rbf_node_address, 0.001) peer_node.sendtoaddress(rbf_node_address, 0.001)
self.sync_all() self.sync_all()
peer_node.generate(1) peer_node.generate(1)

View file

@ -45,7 +45,7 @@ class CreateTxWalletTest(BitcoinTestFramework):
def test_tx_size_too_large(self): def test_tx_size_too_large(self):
# More than 10kB of outputs, so that we hit -maxtxfee with a high feerate # More than 10kB of outputs, so that we hit -maxtxfee with a high feerate
outputs = {self.nodes[0].getnewaddress(address_type='bech32'): 0.000025 for i in range(400)} outputs = {self.nodes[0].getnewaddress(address_type='bech32'): 0.000025 for _ in range(400)}
raw_tx = self.nodes[0].createrawtransaction(inputs=[], outputs=outputs) raw_tx = self.nodes[0].createrawtransaction(inputs=[], outputs=outputs)
for fee_setting in ['-minrelaytxfee=0.01', '-mintxfee=0.01', '-paytxfee=0.01']: for fee_setting in ['-minrelaytxfee=0.01', '-mintxfee=0.01', '-paytxfee=0.01']:

View file

@ -107,7 +107,7 @@ class WalletDescriptorTest(BitcoinTestFramework):
assert_equal(info2['desc'], info3['desc']) assert_equal(info2['desc'], info3['desc'])
self.log.info("Test that getnewaddress still works after keypool is exhausted in an encrypted wallet") self.log.info("Test that getnewaddress still works after keypool is exhausted in an encrypted wallet")
for i in range(0, 500): for _ in range(500):
send_wrpc.getnewaddress() send_wrpc.getnewaddress()
self.log.info("Test that unlock is needed when deriving only hardened keys in an encrypted wallet") self.log.info("Test that unlock is needed when deriving only hardened keys in an encrypted wallet")
@ -120,7 +120,7 @@ class WalletDescriptorTest(BitcoinTestFramework):
}]) }])
send_wrpc.walletlock() send_wrpc.walletlock()
# Exhaust keypool of 100 # Exhaust keypool of 100
for i in range(0, 100): for _ in range(100):
send_wrpc.getnewaddress(address_type='bech32') send_wrpc.getnewaddress(address_type='bech32')
# This should now error # This should now error
assert_raises_rpc_error(-12, "Keypool ran out, please call keypoolrefill first", send_wrpc.getnewaddress, '', 'bech32') assert_raises_rpc_error(-12, "Keypool ran out, please call keypoolrefill first", send_wrpc.getnewaddress, '', 'bech32')

View file

@ -116,7 +116,7 @@ class WalletDumpTest(BitcoinTestFramework):
test_addr_count = 10 test_addr_count = 10
addrs = [] addrs = []
for address_type in ['legacy', 'p2sh-segwit', 'bech32']: for address_type in ['legacy', 'p2sh-segwit', 'bech32']:
for i in range(0, test_addr_count): for _ in range(test_addr_count):
addr = self.nodes[0].getnewaddress(address_type=address_type) addr = self.nodes[0].getnewaddress(address_type=address_type)
vaddr = self.nodes[0].getaddressinfo(addr) # required to get hd keypath vaddr = self.nodes[0].getaddressinfo(addr) # required to get hd keypath
addrs.append(vaddr) addrs.append(vaddr)

View file

@ -27,8 +27,8 @@ class WalletGroupTest(BitcoinTestFramework):
self.nodes[0].generate(110) self.nodes[0].generate(110)
# Get some addresses from the two nodes # Get some addresses from the two nodes
addr1 = [self.nodes[1].getnewaddress() for i in range(3)] addr1 = [self.nodes[1].getnewaddress() for _ in range(3)]
addr2 = [self.nodes[2].getnewaddress() for i in range(3)] addr2 = [self.nodes[2].getnewaddress() for _ in range(3)]
addrs = addr1 + addr2 addrs = addr1 + addr2
# Send 1 + 0.5 coin to each address # Send 1 + 0.5 coin to each address
@ -71,7 +71,7 @@ class WalletGroupTest(BitcoinTestFramework):
# Fill node2's wallet with 10000 outputs corresponding to the same # Fill node2's wallet with 10000 outputs corresponding to the same
# scriptPubKey # scriptPubKey
for i in range(5): for _ in range(5):
raw_tx = self.nodes[0].createrawtransaction([{"txid":"0"*64, "vout":0}], [{addr2[0]: 0.05}]) raw_tx = self.nodes[0].createrawtransaction([{"txid":"0"*64, "vout":0}], [{addr2[0]: 0.05}])
tx = FromHex(CTransaction(), raw_tx) tx = FromHex(CTransaction(), raw_tx)
tx.vin = [] tx.vin = []

View file

@ -118,7 +118,7 @@ class WalletLabelsTest(BitcoinTestFramework):
if not self.options.descriptors: if not self.options.descriptors:
for label in labels: for label in labels:
addresses = [] addresses = []
for x in range(10): for _ in range(10):
addresses.append(node.getnewaddress()) addresses.append(node.getnewaddress())
multisig_address = node.addmultisigaddress(5, addresses, label.name)['address'] multisig_address = node.addmultisigaddress(5, addresses, label.name)['address']
label.add_address(multisig_address) label.add_address(multisig_address)

View file

@ -26,7 +26,7 @@ FEATURE_LATEST = 169900
got_loading_error = False got_loading_error = False
def test_load_unload(node, name): def test_load_unload(node, name):
global got_loading_error global got_loading_error
for i in range(10): for _ in range(10):
if got_loading_error: if got_loading_error:
return return
try: try: