Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-high_priority_transaction.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2017 The Bitcoin developers | # Copyright (c) 2017 The Bitcoin developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
# | # | ||||
# Test HighPriorityTransaction code | # Test HighPriorityTransaction code | ||||
# | # | ||||
from test_framework.blocktools import create_confirmed_utxos | from test_framework.blocktools import create_confirmed_utxos | ||||
from test_framework.messages import COIN | from test_framework.messages import COIN | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal, gen_return_txouts, satoshi_round | from test_framework.util import assert_equal, satoshi_round | ||||
class HighPriorityTransactionTest(BitcoinTestFramework): | class HighPriorityTransactionTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.extra_args = [["-blockprioritypercentage=0", "-limitfreerelay=2"]] | self.extra_args = [["-blockprioritypercentage=0", "-limitfreerelay=2"]] | ||||
Show All 9 Lines | def create_small_transactions(self, node, utxos, num, fee): | ||||
rawtx = node.createrawtransaction(inputs, outputs) | rawtx = node.createrawtransaction(inputs, outputs) | ||||
signresult = node.signrawtransactionwithwallet( | signresult = node.signrawtransactionwithwallet( | ||||
rawtx, None, "NONE|FORKID") | rawtx, None, "NONE|FORKID") | ||||
txid = node.sendrawtransaction(signresult["hex"], True) | txid = node.sendrawtransaction(signresult["hex"], True) | ||||
txids.append(txid) | txids.append(txid) | ||||
return txids | return txids | ||||
def generate_high_priotransactions(self, node, count): | def generate_high_priotransactions(self, node, count): | ||||
# generate a bunch of spendable utxos | |||||
self.txouts = gen_return_txouts() | |||||
# create 150 simple one input one output hi prio txns | # create 150 simple one input one output hi prio txns | ||||
hiprio_utxo_count = 150 | hiprio_utxo_count = 150 | ||||
age = 250 | age = 250 | ||||
# be sure to make this utxo aged enough | # be sure to make this utxo aged enough | ||||
hiprio_utxos = create_confirmed_utxos(node, hiprio_utxo_count, age) | hiprio_utxos = create_confirmed_utxos(node, hiprio_utxo_count, age) | ||||
txids = [] | |||||
# Create hiprio_utxo_count number of txns with 0 fee | # Create hiprio_utxo_count number of txns with 0 fee | ||||
range_size = [0, hiprio_utxo_count] | |||||
start_range = range_size[0] | |||||
end_range = range_size[1] | |||||
txids = self.create_small_transactions( | txids = self.create_small_transactions( | ||||
node, hiprio_utxos[start_range:end_range], end_range - start_range, 0) | node, hiprio_utxos, hiprio_utxo_count, 0) | ||||
return txids | return txids | ||||
def run_test(self): | def run_test(self): | ||||
# this is the priority cut off as defined in AllowFreeThreshold() (see: src/txmempool.h) | # this is the priority cut off as defined in AllowFreeThreshold() (see: src/txmempool.h) | ||||
# anything above that value is considered an high priority transaction | # anything above that value is considered an high priority transaction | ||||
hiprio_threshold = COIN * 144 / 250 | hiprio_threshold = COIN * 144 / 250 | ||||
self.relayfee = self.nodes[0].getnetworkinfo()['relayfee'] | self.relayfee = self.nodes[0].getnetworkinfo()['relayfee'] | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |