Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_basic.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. | ||||
"""Test the wallet.""" | """Test the wallet.""" | ||||
from decimal import Decimal | from decimal import Decimal | ||||
import time | |||||
from test_framework.messages import FromHex, CTransaction | from test_framework.messages import FromHex, CTransaction | ||||
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_array_result, | assert_array_result, | ||||
assert_equal, | assert_equal, | ||||
assert_fee_amount, | assert_fee_amount, | ||||
assert_raises_rpc_error, | assert_raises_rpc_error, | ||||
▲ Show 20 Lines • Show All 531 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Try with walletrejectlongchains | # Try with walletrejectlongchains | ||||
# Double chain limit but require combining inputs, so we pass | # Double chain limit but require combining inputs, so we pass | ||||
# SelectCoinsMinConf | # SelectCoinsMinConf | ||||
self.stop_node(0) | self.stop_node(0) | ||||
self.start_node(0, | self.start_node(0, | ||||
self.extra_args[0] + ["-walletrejectlongchains", | self.extra_args[0] + ["-walletrejectlongchains", | ||||
"-limitancestorcount=" + str(2 * chainlimit)]) | "-limitancestorcount=" + str(2 * chainlimit)]) | ||||
# wait for loadmempool | # wait until the wallet has submitted all transactions to the mempool | ||||
timeout = 10 | wait_until( | ||||
while (timeout > 0 and len( | lambda: len( | ||||
self.nodes[0].getrawmempool()) < chainlimit * 2): | self.nodes[0].getrawmempool()) == chainlimit * | ||||
time.sleep(0.5) | 2) | ||||
timeout -= 0.5 | |||||
assert_equal(len(self.nodes[0].getrawmempool()), chainlimit * 2) | |||||
node0_balance = self.nodes[0].getbalance() | node0_balance = self.nodes[0].getbalance() | ||||
# With walletrejectlongchains we will not create the tx and store it in | # With walletrejectlongchains we will not create the tx and store it in | ||||
# our wallet. | # our wallet. | ||||
assert_raises_rpc_error(-4, "Transaction has too long of a mempool chain", | assert_raises_rpc_error(-4, "Transaction has too long of a mempool chain", | ||||
self.nodes[0].sendtoaddress, sending_addr, node0_balance - Decimal('0.01')) | self.nodes[0].sendtoaddress, sending_addr, node0_balance - Decimal('0.01')) | ||||
# Verify nothing new in wallet | # Verify nothing new in wallet | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |