Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_balance.py
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
class WalletTest(BitcoinTestFramework): | class WalletTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.extra_args = [ | self.extra_args = [ | ||||
# Limit mempool descendants as a hack to have wallet txs rejected | # Limit mempool descendants as a hack to have wallet txs rejected | ||||
# from the mempool | # from the mempool | ||||
['-limitdescendantcount=3'], | ['-limitdescendantcount=3', '-ecash'], | ||||
[], | ['-ecash'], | ||||
] | ] | ||||
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 run_test(self): | def run_test(self): | ||||
self.nodes[0].importaddress(ADDRESS_WATCHONLY) | self.nodes[0].importaddress(ADDRESS_WATCHONLY) | ||||
# Check that nodes don't own any UTXOs | # Check that nodes don't own any UTXOs | ||||
▲ Show 20 Lines • Show All 231 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.nodes[0].syncwithvalidationinterfacequeue() | self.nodes[0].syncwithvalidationinterfacequeue() | ||||
# wallet txs not in the mempool are untrusted | # wallet txs not in the mempool are untrusted | ||||
assert_equal(self.nodes[0].getbalance(minconf=0), 0) | assert_equal(self.nodes[0].getbalance(minconf=0), 0) | ||||
self.nodes[0].generatetoaddress(1, ADDRESS_WATCHONLY) | self.nodes[0].generatetoaddress(1, ADDRESS_WATCHONLY) | ||||
# wallet txs not in the mempool are untrusted | # wallet txs not in the mempool are untrusted | ||||
assert_equal(self.nodes[0].getbalance(minconf=0), 0) | assert_equal(self.nodes[0].getbalance(minconf=0), 0) | ||||
# Now confirm tx_orig | # Now confirm tx_orig | ||||
self.restart_node(1, ['-persistmempool=0']) | self.restart_node(1, ['-persistmempool=0', '-ecash']) | ||||
connect_nodes(self.nodes[0], self.nodes[1]) | connect_nodes(self.nodes[0], self.nodes[1]) | ||||
self.sync_blocks() | self.sync_blocks() | ||||
self.nodes[1].sendrawtransaction(tx_orig) | self.nodes[1].sendrawtransaction(tx_orig) | ||||
self.nodes[1].generatetoaddress(1, ADDRESS_WATCHONLY) | self.nodes[1].generatetoaddress(1, ADDRESS_WATCHONLY) | ||||
self.sync_all() | self.sync_all() | ||||
# The reorg recovered our fee of 1 coin | # The reorg recovered our fee of 1 coin | ||||
assert_equal(self.nodes[0].getbalance(minconf=0), total_amount + 1) | assert_equal(self.nodes[0].getbalance(minconf=0), total_amount + 1) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
WalletTest().main() | WalletTest().main() |