Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_labels.py
Show All 24 Lines | class WalletLabelsTest(BitcoinTestFramework): | ||||
def run_test(self): | def run_test(self): | ||||
# Check that there's no UTXO on the node | # Check that there's no UTXO on the node | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
assert_equal(len(node.listunspent()), 0) | assert_equal(len(node.listunspent()), 0) | ||||
# Note each time we call generate, all generated coins go into | # Note each time we call generate, all generated coins go into | ||||
# the same address, so we call twice to get two addresses w/50 each | # the same address, so we call twice to get two addresses w/50 each | ||||
node.generate(1) | node.generatetoaddress( | ||||
node.generate(101) | nblocks=1, address=node.getnewaddress( | ||||
label='coinbase')) | |||||
node.generatetoaddress( | |||||
nblocks=101, | |||||
address=node.getnewaddress( | |||||
label='coinbase')) | |||||
assert_equal(node.getbalance(), 100) | assert_equal(node.getbalance(), 100) | ||||
# there should be 2 address groups | # there should be 2 address groups | ||||
# each with 1 address with a balance of 50 Bitcoins | # each with 1 address with a balance of 50 Bitcoins | ||||
address_groups = node.listaddressgroupings() | address_groups = node.listaddressgroupings() | ||||
assert_equal(len(address_groups), 2) | assert_equal(len(address_groups), 2) | ||||
# the addresses aren't linked now, but will be after we send to the | # the addresses aren't linked now, but will be after we send to the | ||||
# common address | # common address | ||||
linked_addresses = set() | linked_addresses = set() | ||||
for address_group in address_groups: | for address_group in address_groups: | ||||
assert_equal(len(address_group), 1) | assert_equal(len(address_group), 1) | ||||
assert_equal(len(address_group[0]), 2) | assert_equal(len(address_group[0]), 3) | ||||
assert_equal(address_group[0][1], 50) | assert_equal(address_group[0][1], 50) | ||||
assert_equal(address_group[0][2], 'coinbase') | |||||
linked_addresses.add(address_group[0][0]) | linked_addresses.add(address_group[0][0]) | ||||
# send 50 from each address to a third address not in this wallet | # send 50 from each address to a third address not in this wallet | ||||
common_address = "msf4WtN1YQKXvNtvdFYt9JBnUD2FB41kjr" | common_address = "msf4WtN1YQKXvNtvdFYt9JBnUD2FB41kjr" | ||||
node.sendmany( | node.sendmany( | ||||
amounts={common_address: 100}, | amounts={common_address: 100}, | ||||
subtractfeefrom=[common_address], | subtractfeefrom=[common_address], | ||||
minconf=1, | minconf=1, | ||||
Show All 18 Lines | def run_test(self): | ||||
labels = [Label(name) | labels = [Label(name) | ||||
for name in ("a", "b", "c", "d", "e")] | for name in ("a", "b", "c", "d", "e")] | ||||
for label in labels: | for label in labels: | ||||
address = node.getnewaddress(label.name) | address = node.getnewaddress(label.name) | ||||
label.add_receive_address(address) | label.add_receive_address(address) | ||||
label.verify(node) | label.verify(node) | ||||
# Check all labels are returned by listlabels. | # Check all labels are returned by listlabels. | ||||
assert_equal(node.listlabels(), [label.name for label in labels]) | assert_equal(node.listlabels(), sorted( | ||||
['coinbase'] + [label.name for label in labels])) | |||||
# Send a transaction to each label. | # Send a transaction to each label. | ||||
for label in labels: | for label in labels: | ||||
node.sendtoaddress(label.addresses[0], amount_to_send) | node.sendtoaddress(label.addresses[0], amount_to_send) | ||||
label.verify(node) | label.verify(node) | ||||
# Check the amounts received. | # Check the amounts received. | ||||
node.generate(1) | node.generate(1) | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |