Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_address_types.py
Show All 34 Lines | |||||
from decimal import Decimal | from decimal import Decimal | ||||
import itertools | import itertools | ||||
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_greater_than, | assert_greater_than, | ||||
connect_nodes_bi, | connect_nodes_bi, | ||||
sync_blocks, | |||||
sync_mempools, | |||||
) | ) | ||||
class AddressTypeTest(BitcoinTestFramework): | class AddressTypeTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 5 | self.num_nodes = 5 | ||||
# whitelist all peers to speed up tx relay / mempool sync | # whitelist all peers to speed up tx relay / mempool sync | ||||
self.extra_args = [["-whitelist=127.0.0.1"]] * self.num_nodes | self.extra_args = [["-whitelist=127.0.0.1"]] * self.num_nodes | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | def test_change_output_type( | ||||
change_addresses[0], | change_addresses[0], | ||||
multisig=False, | multisig=False, | ||||
typ=expected_type) | typ=expected_type) | ||||
def run_test(self): | def run_test(self): | ||||
# Mine 101 blocks on node4 to bring nodes out of IBD and make sure that | # Mine 101 blocks on node4 to bring nodes out of IBD and make sure that | ||||
# no coinbases are maturing for the nodes-under-test during the test | # no coinbases are maturing for the nodes-under-test during the test | ||||
self.nodes[4].generate(101) | self.nodes[4].generate(101) | ||||
sync_blocks(self.nodes) | self.sync_blocks() | ||||
uncompressed_1 = "0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee" | uncompressed_1 = "0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee" | ||||
uncompressed_2 = "047211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073dee6c89064984f03385237d92167c13e236446b417ab79a0fcae412ae3316b77" | uncompressed_2 = "047211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073dee6c89064984f03385237d92167c13e236446b417ab79a0fcae412ae3316b77" | ||||
compressed_1 = "0296b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52" | compressed_1 = "0296b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52" | ||||
compressed_2 = "037211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073" | compressed_2 = "037211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073" | ||||
# addmultisigaddress with at least 1 uncompressed key should return a | # addmultisigaddress with at least 1 uncompressed key should return a | ||||
# legacy address. | # legacy address. | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.test_address(to_node, address, multisig, typ) | self.test_address(to_node, address, multisig, typ) | ||||
# Output entry | # Output entry | ||||
sends[address] = to_send * 10 * (1 + n) | sends[address] = to_send * 10 * (1 + n) | ||||
addresses[to_node] = (address, typ) | addresses[to_node] = (address, typ) | ||||
self.log.debug("Sending: {}".format(sends)) | self.log.debug("Sending: {}".format(sends)) | ||||
self.nodes[from_node].sendmany("", sends) | self.nodes[from_node].sendmany("", sends) | ||||
sync_mempools(self.nodes) | self.sync_mempools() | ||||
unconf_balances = self.get_balances(False) | unconf_balances = self.get_balances(False) | ||||
self.log.debug( | self.log.debug( | ||||
"Check unconfirmed balances: {}".format(unconf_balances)) | "Check unconfirmed balances: {}".format(unconf_balances)) | ||||
assert_equal(unconf_balances[from_node], 0) | assert_equal(unconf_balances[from_node], 0) | ||||
for n, to_node in enumerate(range(from_node + 1, from_node + 4)): | for n, to_node in enumerate(range(from_node + 1, from_node + 4)): | ||||
to_node %= 4 | to_node %= 4 | ||||
assert_equal(unconf_balances[to_node], to_send * 10 * (2 + n)) | assert_equal(unconf_balances[to_node], to_send * 10 * (2 + n)) | ||||
# node4 collects fee and block subsidy to keep accounting simple | # node4 collects fee and block subsidy to keep accounting simple | ||||
self.nodes[4].generate(1) | self.nodes[4].generate(1) | ||||
sync_blocks(self.nodes) | self.sync_blocks() | ||||
# Verify that the receiving wallet contains a UTXO with the | # Verify that the receiving wallet contains a UTXO with the | ||||
# expected address, and expected descriptor | # expected address, and expected descriptor | ||||
for n, to_node in enumerate(range(from_node, from_node + 4)): | for n, to_node in enumerate(range(from_node, from_node + 4)): | ||||
to_node %= 4 | to_node %= 4 | ||||
found = False | found = False | ||||
for utxo in self.nodes[to_node].listunspent(): | for utxo in self.nodes[to_node].listunspent(): | ||||
if utxo['address'] == addresses[to_node][0]: | if utxo['address'] == addresses[to_node][0]: | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |