Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_basic.py
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Send 21 BCH from 0 to 2 using sendtoaddress call. | # Send 21 BCH from 0 to 2 using sendtoaddress call. | ||||
# Locked memory should use at least 32 bytes to sign each transaction | # Locked memory should use at least 32 bytes to sign each transaction | ||||
self.log.info("test getmemoryinfo") | self.log.info("test getmemoryinfo") | ||||
memory_before = self.nodes[0].getmemoryinfo() | memory_before = self.nodes[0].getmemoryinfo() | ||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11) | self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11) | ||||
mempool_txid = self.nodes[0].sendtoaddress( | mempool_txid = self.nodes[0].sendtoaddress( | ||||
self.nodes[2].getnewaddress(), 10) | self.nodes[2].getnewaddress(), 10) | ||||
memory_after = self.nodes[0].getmemoryinfo() | memory_after = self.nodes[0].getmemoryinfo() | ||||
assert(memory_before['locked']['used'] + | assert memory_before['locked']['used'] + \ | ||||
64 <= memory_after['locked']['used']) | 64 <= memory_after['locked']['used'] | ||||
self.log.info("test gettxout (second part)") | self.log.info("test gettxout (second part)") | ||||
# utxo spent in mempool should be visible if you exclude mempool | # utxo spent in mempool should be visible if you exclude mempool | ||||
# but invisible if you include mempool | # but invisible if you include mempool | ||||
txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, False) | txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, False) | ||||
assert_equal(txout['value'], 50) | assert_equal(txout['value'], 50) | ||||
txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, True) | txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, True) | ||||
assert txout is None | assert txout is None | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.start_node(3) | self.start_node(3) | ||||
connect_nodes_bi(self.nodes[0], self.nodes[3]) | connect_nodes_bi(self.nodes[0], self.nodes[3]) | ||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
relayed = self.nodes[0].resendwallettransactions() | relayed = self.nodes[0].resendwallettransactions() | ||||
assert_equal(set(relayed), {txid1, txid2}) | assert_equal(set(relayed), {txid1, txid2}) | ||||
sync_mempools(self.nodes) | sync_mempools(self.nodes) | ||||
assert(txid1 in self.nodes[3].getrawmempool()) | assert txid1 in self.nodes[3].getrawmempool() | ||||
# Exercise balance rpcs | # Exercise balance rpcs | ||||
assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"], 1) | assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"], 1) | ||||
assert_equal(self.nodes[0].getunconfirmedbalance(), 1) | assert_equal(self.nodes[0].getunconfirmedbalance(), 1) | ||||
# check if we can list zero value tx as available coins | # check if we can list zero value tx as available coins | ||||
# 1. create rawtx | # 1. create rawtx | ||||
# 2. hex-changed one output to 0.0 | # 2. hex-changed one output to 0.0 | ||||
Show All 18 Lines | def run_test(self): | ||||
# zero value tx must be in listunspents output | # zero value tx must be in listunspents output | ||||
unspentTxs = self.nodes[0].listunspent() | unspentTxs = self.nodes[0].listunspent() | ||||
found = False | found = False | ||||
for uTx in unspentTxs: | for uTx in unspentTxs: | ||||
if uTx['txid'] == zeroValueTxid: | if uTx['txid'] == zeroValueTxid: | ||||
found = True | found = True | ||||
assert_equal(uTx['amount'], Decimal('0')) | assert_equal(uTx['amount'], Decimal('0')) | ||||
assert(found) | assert found | ||||
# do some -walletbroadcast tests | # do some -walletbroadcast tests | ||||
self.stop_nodes() | self.stop_nodes() | ||||
self.start_node(0, ["-walletbroadcast=0"]) | self.start_node(0, ["-walletbroadcast=0"]) | ||||
self.start_node(1, ["-walletbroadcast=0"]) | self.start_node(1, ["-walletbroadcast=0"]) | ||||
self.start_node(2, ["-walletbroadcast=0"]) | self.start_node(2, ["-walletbroadcast=0"]) | ||||
connect_nodes_bi(self.nodes[0], self.nodes[1]) | connect_nodes_bi(self.nodes[0], self.nodes[1]) | ||||
connect_nodes_bi(self.nodes[1], self.nodes[2]) | connect_nodes_bi(self.nodes[1], self.nodes[2]) | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
txid = self.nodes[0].sendtoaddress(address_to_import, 1) | txid = self.nodes[0].sendtoaddress(address_to_import, 1) | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all([self.nodes[0:3]]) | self.sync_all([self.nodes[0:3]]) | ||||
# 2. Import address from node2 to node1 | # 2. Import address from node2 to node1 | ||||
self.nodes[1].importaddress(address_to_import) | self.nodes[1].importaddress(address_to_import) | ||||
# 3. Validate that the imported address is watch-only on node1 | # 3. Validate that the imported address is watch-only on node1 | ||||
assert(self.nodes[1].getaddressinfo(address_to_import)["iswatchonly"]) | assert self.nodes[1].getaddressinfo(address_to_import)["iswatchonly"] | ||||
# 4. Check that the unspents after import are not spendable | # 4. Check that the unspents after import are not spendable | ||||
assert_array_result(self.nodes[1].listunspent(), | assert_array_result(self.nodes[1].listunspent(), | ||||
{"address": address_to_import}, | {"address": address_to_import}, | ||||
{"spendable": False}) | {"spendable": False}) | ||||
# 5. Import private key of the previously imported address on node1 | # 5. Import private key of the previously imported address on node1 | ||||
priv_key = self.nodes[2].dumpprivkey(address_to_import) | priv_key = self.nodes[2].dumpprivkey(address_to_import) | ||||
Show All 25 Lines | def run_test(self): | ||||
# - False: unicode directly as UTF-8 | # - False: unicode directly as UTF-8 | ||||
for mode in [True, False]: | for mode in [True, False]: | ||||
self.nodes[0].ensure_ascii = mode | self.nodes[0].ensure_ascii = mode | ||||
# unicode check: Basic Multilingual Plane, Supplementary Plane respectively | # unicode check: Basic Multilingual Plane, Supplementary Plane respectively | ||||
for s in [u'рыба', u'𝅘𝅥𝅯']: | for s in [u'рыба', u'𝅘𝅥𝅯']: | ||||
addr = self.nodes[0].getaccountaddress(s) | addr = self.nodes[0].getaccountaddress(s) | ||||
label = self.nodes[0].getaccount(addr) | label = self.nodes[0].getaccount(addr) | ||||
assert_equal(label, s) | assert_equal(label, s) | ||||
assert(s in self.nodes[0].listaccounts().keys()) | assert s in self.nodes[0].listaccounts().keys() | ||||
self.nodes[0].ensure_ascii = True # restore to default | self.nodes[0].ensure_ascii = True # restore to default | ||||
# maintenance tests | # maintenance tests | ||||
maintenance = [ | maintenance = [ | ||||
'-rescan', | '-rescan', | ||||
'-reindex', | '-reindex', | ||||
'-zapwallettxes=1', | '-zapwallettxes=1', | ||||
'-zapwallettxes=2', | '-zapwallettxes=2', | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
sending_addr, Decimal('0.0001'))) | sending_addr, Decimal('0.0001'))) | ||||
assert_equal(self.nodes[0].getmempoolinfo()['size'], chainlimit * 2) | assert_equal(self.nodes[0].getmempoolinfo()['size'], chainlimit * 2) | ||||
assert_equal(len(txid_list), chainlimit * 2) | assert_equal(len(txid_list), chainlimit * 2) | ||||
# Without walletrejectlongchains, we will still generate a txid | # Without walletrejectlongchains, we will still generate a txid | ||||
# The tx will be stored in the wallet but not accepted to the mempool | # The tx will be stored in the wallet but not accepted to the mempool | ||||
extra_txid = self.nodes[0].sendtoaddress( | extra_txid = self.nodes[0].sendtoaddress( | ||||
sending_addr, Decimal('0.0001')) | sending_addr, Decimal('0.0001')) | ||||
assert(extra_txid not in self.nodes[0].getrawmempool()) | assert extra_txid not in self.nodes[0].getrawmempool() | ||||
assert(extra_txid in [tx["txid"] | assert extra_txid in [tx["txid"] | ||||
for tx in self.nodes[0].listtransactions()]) | for tx in self.nodes[0].listtransactions()] | ||||
self.nodes[0].abandontransaction(extra_txid) | self.nodes[0].abandontransaction(extra_txid) | ||||
total_txs = len(self.nodes[0].listtransactions("*", 99999)) | total_txs = len(self.nodes[0].listtransactions("*", 99999)) | ||||
# Try with walletrejectlongchains | # Try with walletrejectlongchains | ||||
# Double chain limit but require combining inputs, so we pass SelectCoinsMinConf | # Double chain limit but require combining inputs, so we pass SelectCoinsMinConf | ||||
self.stop_node(0) | self.stop_node(0) | ||||
self.start_node(0, extra_args=[ | self.start_node(0, extra_args=[ | ||||
"-walletrejectlongchains", "-limitancestorcount=" + str(2 * chainlimit)]) | "-walletrejectlongchains", "-limitancestorcount=" + str(2 * chainlimit)]) | ||||
Show All 33 Lines |