(self)
| 26 | self.skip_if_no_wallet() |
| 27 | |
| 28 | def run_test(self): |
| 29 | # Check that there's no UTXO on the node |
| 30 | node = self.nodes[0] |
| 31 | assert_equal(len(node.listunspent()), 0) |
| 32 | |
| 33 | # Note each time we call generate, all generated coins go into |
| 34 | # the same address, so we call twice to get two addresses w/50 each |
| 35 | self.generatetoaddress(node, nblocks=1, address=node.getnewaddress(label='coinbase')) |
| 36 | self.generatetoaddress(node, nblocks=COINBASE_MATURITY + 1, address=node.getnewaddress(label='coinbase')) |
| 37 | assert_equal(node.getbalance()['bitcoin'], 100) |
| 38 | |
| 39 | # there should be 2 address groups |
| 40 | # each with 1 address with a balance of 50 Bitcoins |
| 41 | address_groups = node.listaddressgroupings() |
| 42 | assert_equal(len(address_groups), 2) |
| 43 | # the addresses aren't linked now, but will be after we send to the |
| 44 | # common address |
| 45 | linked_addresses = set() |
| 46 | for address_group in address_groups: |
| 47 | assert_equal(len(address_group), 1) |
| 48 | assert_equal(len(address_group[0]), 3) |
| 49 | assert_equal(address_group[0][1], 50) |
| 50 | assert_equal(address_group[0][2], 'coinbase') |
| 51 | linked_addresses.add(address_group[0][0]) |
| 52 | |
| 53 | # send 50 from each address to a third address not in this wallet |
| 54 | common_address = "CTEtJrqH4767uF3AHRn7w8m9WWNE4uEv4gSzYPcCyq35Jb6BUZR5mVNZNRMZskJk21pkYCr6dRUz6BcZ" |
| 55 | node.sendmany( |
| 56 | amounts={common_address: 100}, |
| 57 | subtractfeefrom=[common_address], |
| 58 | minconf=1, |
| 59 | ) |
| 60 | # there should be 1 address group, with the previously |
| 61 | # unlinked addresses now linked (they both have 0 balance) |
| 62 | address_groups = node.listaddressgroupings() |
| 63 | assert_equal(len(address_groups), 1) |
| 64 | assert_equal(len(address_groups[0]), 2) |
| 65 | assert_equal(set([a[0] for a in address_groups[0]]), linked_addresses) |
| 66 | assert_equal([a[1] for a in address_groups[0]], [0, 0]) |
| 67 | |
| 68 | self.generate(node, 1) |
| 69 | |
| 70 | # we want to reset so that the "" label has what's expected. |
| 71 | # otherwise we're off by exactly the fee amount as that's mined |
| 72 | # and matures in the next 100 blocks |
| 73 | amount_to_send = 1.0 |
| 74 | |
| 75 | # Create labels and make sure subsequent label API calls |
| 76 | # recognize the label/address associations. |
| 77 | labels = [Label(name) for name in ("a", "b", "c", "d", "e")] |
| 78 | for label in labels: |
| 79 | address = node.getnewaddress(label.name) |
| 80 | label.add_receive_address(address) |
| 81 | label.verify(node) |
| 82 | |
| 83 | # Check all labels are returned by listlabels. |
| 84 | assert_equal(node.listlabels(), sorted(['coinbase'] + [label.name for label in labels])) |
| 85 |
nothing calls this directly
no test coverage detected