Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_dbcrash.py
Show First 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | class ChainstateWriteCrashTest(BitcoinTestFramework): | ||||
def generate_small_transactions(self, node, count, utxo_list): | def generate_small_transactions(self, node, count, utxo_list): | ||||
FEE = 1000 # TODO: replace this with node relay fee based calculation | FEE = 1000 # TODO: replace this with node relay fee based calculation | ||||
num_transactions = 0 | num_transactions = 0 | ||||
random.shuffle(utxo_list) | random.shuffle(utxo_list) | ||||
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( | tx.vin.append( | ||||
CTxIn(COutPoint(int(utxo['txid'], 16), utxo['vout']))) | CTxIn(COutPoint(int(utxo['txid'], 16), utxo['vout']))) | ||||
input_amount += int(utxo['amount'] * XEC) | input_amount += int(utxo['amount'] * XEC) | ||||
output_amount = (input_amount - FEE) // 3 | output_amount = (input_amount - FEE) // 3 | ||||
if output_amount <= 0: | if output_amount <= 0: | ||||
# 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( | tx.vout.append( | ||||
CTxOut(output_amount, hex_str_to_bytes(utxo['scriptPubKey']))) | 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 | ||||
tx_signed_hex = node.signrawtransactionwithwallet(ToHex(tx))['hex'] | tx_signed_hex = node.signrawtransactionwithwallet(ToHex(tx))['hex'] | ||||
node.sendrawtransaction(tx_signed_hex) | node.sendrawtransaction(tx_signed_hex) | ||||
num_transactions += 1 | num_transactions += 1 | ||||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |