Skip to content

Commit 981ac92

Browse files
committed
Rename account to label in wallet-labels test
This is a separate commit because changing the test at the same time as renaming it breaks git (and github) rename detection.
1 parent d31cc7f commit 981ac92

File tree

1 file changed

+82
-82
lines changed

1 file changed

+82
-82
lines changed

test/functional/wallet-labels.py

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
# Copyright (c) 2016 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5-
"""Test account RPCs.
5+
"""Test label RPCs.
66
77
RPCs tested are:
8-
- getaccountaddress
8+
- getlabeladdress
99
- getaddressesbyaccount
1010
- listaddressgroupings
11-
- setaccount
11+
- setlabel
1212
- sendfrom (with account arguments)
1313
- move (with account arguments)
1414
"""
1515

1616
from test_framework.test_framework import BitcoinTestFramework
1717
from test_framework.util import assert_equal
1818

19-
class WalletAccountsTest(BitcoinTestFramework):
19+
class WalletLabelsTest(BitcoinTestFramework):
2020
def set_test_params(self):
2121
self.setup_clean_chain = True
2222
self.num_nodes = 1
@@ -68,97 +68,97 @@ def run_test(self):
6868

6969
node.generate(1)
7070

71-
# we want to reset so that the "" account has what's expected.
71+
# we want to reset so that the "" label has what's expected.
7272
# otherwise we're off by exactly the fee amount as that's mined
7373
# and matures in the next 100 blocks
7474
node.sendfrom("", common_address, fee)
7575
amount_to_send = 1.0
7676

77-
# Create accounts and make sure subsequent account API calls
78-
# recognize the account/address associations.
79-
accounts = [Account(name) for name in ("a", "b", "c", "d", "e")]
80-
for account in accounts:
81-
account.add_receive_address(node.getaccountaddress(account.name))
82-
account.verify(node)
77+
# Create labels and make sure subsequent label API calls
78+
# recognize the label/address associations.
79+
labels = [Label(name) for name in ("a", "b", "c", "d", "e")]
80+
for label in labels:
81+
label.add_receive_address(node.getlabeladdress(label.name))
82+
label.verify(node)
8383

84-
# Send a transaction to each account, and make sure this forces
85-
# getaccountaddress to generate a new receiving address.
86-
for account in accounts:
87-
node.sendtoaddress(account.receive_address, amount_to_send)
88-
account.add_receive_address(node.getaccountaddress(account.name))
89-
account.verify(node)
84+
# Send a transaction to each label, and make sure this forces
85+
# getlabeladdress to generate a new receiving address.
86+
for label in labels:
87+
node.sendtoaddress(label.receive_address, amount_to_send)
88+
label.add_receive_address(node.getlabeladdress(label.name))
89+
label.verify(node)
9090

9191
# Check the amounts received.
9292
node.generate(1)
93-
for account in accounts:
93+
for label in labels:
9494
assert_equal(
95-
node.getreceivedbyaddress(account.addresses[0]), amount_to_send)
96-
assert_equal(node.getreceivedbyaccount(account.name), amount_to_send)
97-
98-
# Check that sendfrom account reduces listaccounts balances.
99-
for i, account in enumerate(accounts):
100-
to_account = accounts[(i+1) % len(accounts)]
101-
node.sendfrom(account.name, to_account.receive_address, amount_to_send)
95+
node.getreceivedbyaddress(label.addresses[0]), amount_to_send)
96+
assert_equal(node.getreceivedbylabel(label.name), amount_to_send)
97+
98+
# Check that sendfrom label reduces listaccounts balances.
99+
for i, label in enumerate(labels):
100+
to_label = labels[(i+1) % len(labels)]
101+
node.sendfrom(label.name, to_label.receive_address, amount_to_send)
102102
node.generate(1)
103-
for account in accounts:
104-
account.add_receive_address(node.getaccountaddress(account.name))
105-
account.verify(node)
106-
assert_equal(node.getreceivedbyaccount(account.name), 2)
107-
node.move(account.name, "", node.getbalance(account.name))
108-
account.verify(node)
103+
for label in labels:
104+
label.add_receive_address(node.getlabeladdress(label.name))
105+
label.verify(node)
106+
assert_equal(node.getreceivedbylabel(label.name), 2)
107+
node.move(label.name, "", node.getbalance(label.name))
108+
label.verify(node)
109109
node.generate(101)
110110
expected_account_balances = {"": 5200}
111-
for account in accounts:
112-
expected_account_balances[account.name] = 0
111+
for label in labels:
112+
expected_account_balances[label.name] = 0
113113
assert_equal(node.listaccounts(), expected_account_balances)
114114
assert_equal(node.getbalance(""), 5200)
115-
116-
# Check that setaccount can assign an account to a new unused address.
117-
for account in accounts:
118-
address = node.getaccountaddress("")
119-
node.setaccount(address, account.name)
120-
account.add_address(address)
121-
account.verify(node)
115+
116+
# Check that setlabel can assign an label to a new unused address.
117+
for label in labels:
118+
address = node.getlabeladdress("")
119+
node.setlabel(address, label.name)
120+
label.add_address(address)
121+
label.verify(node)
122122
assert(address not in node.getaddressesbyaccount(""))
123-
124-
# Check that addmultisigaddress can assign accounts.
125-
for account in accounts:
123+
124+
# Check that addmultisigaddress can assign labels.
125+
for label in labels:
126126
addresses = []
127127
for x in range(10):
128128
addresses.append(node.getnewaddress())
129-
multisig_address = node.addmultisigaddress(5, addresses, account.name)
130-
account.add_address(multisig_address)
131-
account.verify(node)
129+
multisig_address = node.addmultisigaddress(5, addresses, label.name)
130+
label.add_address(multisig_address)
131+
label.verify(node)
132132
node.sendfrom("", multisig_address, 50)
133133
node.generate(101)
134-
for account in accounts:
135-
assert_equal(node.getbalance(account.name), 50)
134+
for label in labels:
135+
assert_equal(node.getbalance(label.name), 50)
136136

137-
# Check that setaccount can change the account of an address from a
138-
# different account.
139-
change_account(node, accounts[0].addresses[0], accounts[0], accounts[1])
137+
# Check that setlabel can change the label of an address from a
138+
# different label.
139+
change_label(node, labels[0].addresses[0], labels[0], labels[1])
140140

141-
# Check that setaccount can change the account of an address which
142-
# is the receiving address of a different account.
143-
change_account(node, accounts[0].receive_address, accounts[0], accounts[1])
141+
# Check that setlabel can change the label of an address which
142+
# is the receiving address of a different label.
143+
change_label(node, labels[0].receive_address, labels[0], labels[1])
144144

145-
# Check that setaccount can set the account of an address already
146-
# in the account. This is a no-op.
147-
change_account(node, accounts[2].addresses[0], accounts[2], accounts[2])
145+
# Check that setlabel can set the label of an address already
146+
# in the label. This is a no-op.
147+
change_label(node, labels[2].addresses[0], labels[2], labels[2])
148148

149-
# Check that setaccount can set the account of an address which is
150-
# already the receiving address of the account. It would probably make
149+
# Check that setlabel can set the label of an address which is
150+
# already the receiving address of the label. It would probably make
151151
# sense for this to be a no-op, but right now it resets the receiving
152-
# address, causing getaccountaddress to return a brand new address.
153-
change_account(node, accounts[2].receive_address, accounts[2], accounts[2])
152+
# address, causing getlabeladdress to return a brand new address.
153+
change_label(node, labels[2].receive_address, labels[2], labels[2])
154154

155-
class Account:
155+
class Label:
156156
def __init__(self, name):
157-
# Account name
157+
# Label name
158158
self.name = name
159-
# Current receiving address associated with this account.
159+
# Current receiving address associated with this label.
160160
self.receive_address = None
161-
# List of all addresses assigned with this account
161+
# List of all addresses assigned with this label
162162
self.addresses = []
163163

164164
def add_address(self, address):
@@ -172,7 +172,7 @@ def add_receive_address(self, address):
172172
def verify(self, node):
173173
if self.receive_address is not None:
174174
assert self.receive_address in self.addresses
175-
assert_equal(node.getaccountaddress(self.name), self.receive_address)
175+
assert_equal(node.getlabeladdress(self.name), self.receive_address)
176176

177177
for address in self.addresses:
178178
assert_equal(node.getaccount(address), self.name)
@@ -181,26 +181,26 @@ def verify(self, node):
181181
set(node.getaddressesbyaccount(self.name)), set(self.addresses))
182182

183183

184-
def change_account(node, address, old_account, new_account):
185-
assert_equal(address in old_account.addresses, True)
186-
node.setaccount(address, new_account.name)
184+
def change_label(node, address, old_label, new_label):
185+
assert_equal(address in old_label.addresses, True)
186+
node.setlabel(address, new_label.name)
187187

188-
old_account.addresses.remove(address)
189-
new_account.add_address(address)
188+
old_label.addresses.remove(address)
189+
new_label.add_address(address)
190190

191-
# Calling setaccount on an address which was previously the receiving
192-
# address of a different account should reset the receiving address of
193-
# the old account, causing getaccountaddress to return a brand new
191+
# Calling setlabel on an address which was previously the receiving
192+
# address of a different label should reset the receiving address of
193+
# the old label, causing getlabeladdress to return a brand new
194194
# address.
195-
if address == old_account.receive_address:
196-
new_address = node.getaccountaddress(old_account.name)
197-
assert_equal(new_address not in old_account.addresses, True)
198-
assert_equal(new_address not in new_account.addresses, True)
199-
old_account.add_receive_address(new_address)
195+
if address == old_label.receive_address:
196+
new_address = node.getlabeladdress(old_label.name)
197+
assert_equal(new_address not in old_label.addresses, True)
198+
assert_equal(new_address not in new_label.addresses, True)
199+
old_label.add_receive_address(new_address)
200200

201-
old_account.verify(node)
202-
new_account.verify(node)
201+
old_label.verify(node)
202+
new_label.verify(node)
203203

204204

205205
if __name__ == '__main__':
206-
WalletAccountsTest().main()
206+
WalletLabelsTest().main()

0 commit comments

Comments
 (0)