Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_fundrawtransaction.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2014-2019 The Bitcoin Core developers | # Copyright (c) 2014-2019 The Bitcoin Core 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. | ||||
from decimal import Decimal | from decimal import Decimal | ||||
from test_framework.messages import CTransaction, FromHex | from test_framework.messages import CTransaction, FromHex | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import ( | ||||
assert_equal, | assert_equal, | ||||
assert_fee_amount, | assert_fee_amount, | ||||
assert_greater_than, | assert_greater_than, | ||||
assert_greater_than_or_equal, | assert_greater_than_or_equal, | ||||
assert_raises_rpc_error, | assert_raises_rpc_error, | ||||
connect_nodes_bi, | connect_nodes, | ||||
find_vout_for_address, | find_vout_for_address, | ||||
) | ) | ||||
def get_unspent(listunspent, amount): | def get_unspent(listunspent, amount): | ||||
for utx in listunspent: | for utx in listunspent: | ||||
if utx['amount'] == amount: | if utx['amount'] == amount: | ||||
return utx | return utx | ||||
raise AssertionError( | raise AssertionError( | ||||
'Could not find unspent with amount={}'.format(amount)) | 'Could not find unspent with amount={}'.format(amount)) | ||||
class RawTransactionsTest(BitcoinTestFramework): | class RawTransactionsTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 4 | self.num_nodes = 4 | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.extra_args = [[], [], [], []] | self.extra_args = [[], [], [], []] | ||||
def skip_test_if_missing_module(self): | def skip_test_if_missing_module(self): | ||||
self.skip_if_no_wallet() | self.skip_if_no_wallet() | ||||
def setup_network(self): | def setup_network(self): | ||||
self.setup_nodes() | self.setup_nodes() | ||||
connect_nodes_bi(self.nodes[0], self.nodes[1]) | connect_nodes(self.nodes[0], self.nodes[1]) | ||||
connect_nodes_bi(self.nodes[1], self.nodes[2]) | connect_nodes(self.nodes[1], self.nodes[2]) | ||||
connect_nodes_bi(self.nodes[0], self.nodes[2]) | connect_nodes(self.nodes[0], self.nodes[2]) | ||||
connect_nodes_bi(self.nodes[0], self.nodes[3]) | connect_nodes(self.nodes[0], self.nodes[3]) | ||||
def run_test(self): | def run_test(self): | ||||
min_relay_tx_fee = self.nodes[0].getnetworkinfo()['relayfee'] | min_relay_tx_fee = self.nodes[0].getnetworkinfo()['relayfee'] | ||||
# This test is not meant to test fee estimation and we'd like | # This test is not meant to test fee estimation and we'd like | ||||
# to be sure all txs are sent at a consistent desired feerate | # to be sure all txs are sent at a consistent desired feerate | ||||
for node in self.nodes: | for node in self.nodes: | ||||
node.settxfee(min_relay_tx_fee) | node.settxfee(min_relay_tx_fee) | ||||
▲ Show 20 Lines • Show All 438 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.stop_nodes() | self.stop_nodes() | ||||
self.start_nodes() | self.start_nodes() | ||||
# This test is not meant to test fee estimation and we'd like | # This test is not meant to test fee estimation and we'd like | ||||
# to be sure all txs are sent at a consistent desired feerate | # to be sure all txs are sent at a consistent desired feerate | ||||
for node in self.nodes: | for node in self.nodes: | ||||
node.settxfee(min_relay_tx_fee) | node.settxfee(min_relay_tx_fee) | ||||
connect_nodes_bi(self.nodes[0], self.nodes[1]) | connect_nodes(self.nodes[0], self.nodes[1]) | ||||
connect_nodes_bi(self.nodes[1], self.nodes[2]) | connect_nodes(self.nodes[1], self.nodes[2]) | ||||
connect_nodes_bi(self.nodes[0], self.nodes[2]) | connect_nodes(self.nodes[0], self.nodes[2]) | ||||
connect_nodes_bi(self.nodes[0], self.nodes[3]) | connect_nodes(self.nodes[0], self.nodes[3]) | ||||
# Again lock the watchonly UTXO or nodes[0] may spend it, because | # Again lock the watchonly UTXO or nodes[0] may spend it, because | ||||
# lockunspent is memory-only and thus lost on restart | # lockunspent is memory-only and thus lost on restart | ||||
self.nodes[0].lockunspent( | self.nodes[0].lockunspent( | ||||
False, [{"txid": watchonly_txid, "vout": watchonly_vout}]) | False, [{"txid": watchonly_txid, "vout": watchonly_vout}]) | ||||
self.sync_all() | self.sync_all() | ||||
# drain the keypool | # drain the keypool | ||||
self.nodes[1].getnewaddress() | self.nodes[1].getnewaddress() | ||||
▲ Show 20 Lines • Show All 293 Lines • Show Last 20 Lines |