Skip to content

Commit 5d53661

Browse files
committed
[tests] Remove 'account' API from wallet functional tests
Removes usage of account API from the following functional tests: - wallet_listreceivedby.py - wallet_basic.py - wallet_keypool_topup.py - wallet_txn_clone.py - wallet_listsinceblock.py - wallet_import_rescan.py - wallet_listtransactions.py - wallet_txn_doublespend.py
1 parent baf6b4e commit 5d53661

8 files changed

+78
-126
lines changed

test/functional/wallet_basic.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ class WalletTest(BitcoinTestFramework):
2222
def set_test_params(self):
2323
self.num_nodes = 4
2424
self.setup_clean_chain = True
25-
self.extra_args = [['-deprecatedrpc=accounts']] * 4
2625

2726
def setup_network(self):
28-
self.add_nodes(4, self.extra_args)
27+
self.add_nodes(4)
2928
self.start_node(0)
3029
self.start_node(1)
3130
self.start_node(2)
@@ -151,7 +150,7 @@ def run_test(self):
151150
inputs = []
152151
outputs = {}
153152
inputs.append({"txid": utxo["txid"], "vout": utxo["vout"]})
154-
outputs[self.nodes[2].getnewaddress("from1")] = utxo["amount"] - 3
153+
outputs[self.nodes[2].getnewaddress()] = utxo["amount"] - 3
155154
raw_tx = self.nodes[0].createrawtransaction(inputs, outputs)
156155
txns_to_send.append(self.nodes[0].signrawtransactionwithwallet(raw_tx))
157156

@@ -165,7 +164,6 @@ def run_test(self):
165164

166165
assert_equal(self.nodes[0].getbalance(), 0)
167166
assert_equal(self.nodes[2].getbalance(), 94)
168-
assert_equal(self.nodes[2].getbalance("from1"), 94 - 21)
169167

170168
# Verify that a spent output cannot be locked anymore
171169
spent_0 = {"txid": node0utxos[0]["txid"], "vout": node0utxos[0]["vout"]}
@@ -190,15 +188,15 @@ def run_test(self):
190188
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), Decimal('20'), fee_per_byte, self.get_vsize(self.nodes[2].getrawtransaction(txid)))
191189

192190
# Sendmany 10 BTC
193-
txid = self.nodes[2].sendmany('from1', {address: 10}, 0, "", [])
191+
txid = self.nodes[2].sendmany('', {address: 10}, 0, "", [])
194192
self.nodes[2].generate(1)
195193
self.sync_all([self.nodes[0:3]])
196194
node_0_bal += Decimal('10')
197195
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), node_2_bal - Decimal('10'), fee_per_byte, self.get_vsize(self.nodes[2].getrawtransaction(txid)))
198196
assert_equal(self.nodes[0].getbalance(), node_0_bal)
199197

200198
# Sendmany 10 BTC with subtract fee from amount
201-
txid = self.nodes[2].sendmany('from1', {address: 10}, 0, "", [address])
199+
txid = self.nodes[2].sendmany('', {address: 10}, 0, "", [address])
202200
self.nodes[2].generate(1)
203201
self.sync_all([self.nodes[0:3]])
204202
node_2_bal -= Decimal('10')
@@ -365,14 +363,14 @@ def run_test(self):
365363
# - True: unicode escaped as \u....
366364
# - False: unicode directly as UTF-8
367365
for mode in [True, False]:
368-
self.nodes[0].ensure_ascii = mode
366+
self.nodes[0].rpc.ensure_ascii = mode
369367
# unicode check: Basic Multilingual Plane, Supplementary Plane respectively
370-
for s in [u'рыба', u'𝅘𝅥𝅯']:
371-
addr = self.nodes[0].getaccountaddress(s)
372-
label = self.nodes[0].getaccount(addr)
373-
assert_equal(label, s)
374-
assert(s in self.nodes[0].listaccounts().keys())
375-
self.nodes[0].ensure_ascii = True # restore to default
368+
for label in [u'рыба', u'𝅘𝅥𝅯']:
369+
addr = self.nodes[0].getnewaddress()
370+
self.nodes[0].setlabel(addr, label)
371+
assert_equal(self.nodes[0].getaddressinfo(addr)['label'], label)
372+
assert(label in self.nodes[0].listlabels())
373+
self.nodes[0].rpc.ensure_ascii = True # restore to default
376374

377375
# maintenance tests
378376
maintenance = [
@@ -388,9 +386,9 @@ def run_test(self):
388386
self.log.info("check " + m)
389387
self.stop_nodes()
390388
# set lower ancestor limit for later
391-
self.start_node(0, [m, "-deprecatedrpc=accounts", "-limitancestorcount=" + str(chainlimit)])
392-
self.start_node(1, [m, "-deprecatedrpc=accounts", "-limitancestorcount=" + str(chainlimit)])
393-
self.start_node(2, [m, "-deprecatedrpc=accounts", "-limitancestorcount=" + str(chainlimit)])
389+
self.start_node(0, [m, "-limitancestorcount=" + str(chainlimit)])
390+
self.start_node(1, [m, "-limitancestorcount=" + str(chainlimit)])
391+
self.start_node(2, [m, "-limitancestorcount=" + str(chainlimit)])
394392
if m == '-reindex':
395393
# reindex will leave rpc warm up "early"; Wait for it to finish
396394
wait_until(lambda: [block_count] * 3 == [self.nodes[i].getblockcount() for i in range(3)])
@@ -438,7 +436,7 @@ def run_test(self):
438436
# Try with walletrejectlongchains
439437
# Double chain limit but require combining inputs, so we pass SelectCoinsMinConf
440438
self.stop_node(0)
441-
self.start_node(0, extra_args=["-deprecatedrpc=accounts", "-walletrejectlongchains", "-limitancestorcount=" + str(2 * chainlimit)])
439+
self.start_node(0, extra_args=["-walletrejectlongchains", "-limitancestorcount=" + str(2 * chainlimit)])
442440

443441
# wait for loadmempool
444442
timeout = 10

test/functional/wallet_import_rescan.py

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,15 @@ def try_rpc(self, func, *args, **kwargs):
4242

4343
def do_import(self, timestamp):
4444
"""Call one key import RPC."""
45+
rescan = self.rescan == Rescan.yes
4546

4647
if self.call == Call.single:
4748
if self.data == Data.address:
48-
response = self.try_rpc(self.node.importaddress, self.address["address"], self.label,
49-
self.rescan == Rescan.yes)
49+
response = self.try_rpc(self.node.importaddress, address=self.address["address"], rescan=rescan)
5050
elif self.data == Data.pub:
51-
response = self.try_rpc(self.node.importpubkey, self.address["pubkey"], self.label,
52-
self.rescan == Rescan.yes)
51+
response = self.try_rpc(self.node.importpubkey, pubkey=self.address["pubkey"], rescan=rescan)
5352
elif self.data == Data.priv:
54-
response = self.try_rpc(self.node.importprivkey, self.key, self.label, self.rescan == Rescan.yes)
53+
response = self.try_rpc(self.node.importprivkey, privkey=self.key, rescan=rescan)
5554
assert_equal(response, None)
5655

5756
elif self.call == Call.multi:
@@ -62,40 +61,32 @@ def do_import(self, timestamp):
6261
"timestamp": timestamp + TIMESTAMP_WINDOW + (1 if self.rescan == Rescan.late_timestamp else 0),
6362
"pubkeys": [self.address["pubkey"]] if self.data == Data.pub else [],
6463
"keys": [self.key] if self.data == Data.priv else [],
65-
"label": self.label,
6664
"watchonly": self.data != Data.priv
6765
}], {"rescan": self.rescan in (Rescan.yes, Rescan.late_timestamp)})
6866
assert_equal(response, [{"success": True}])
6967

7068
def check(self, txid=None, amount=None, confirmations=None):
71-
"""Verify that getbalance/listtransactions return expected values."""
69+
"""Verify that listreceivedbyaddress returns expected values."""
7270

73-
balance = self.node.getbalance(self.label, 0, True)
74-
assert_equal(balance, self.expected_balance)
75-
76-
txs = self.node.listtransactions(self.label, 10000, 0, True)
77-
assert_equal(len(txs), self.expected_txs)
71+
addresses = self.node.listreceivedbyaddress(minconf=0, include_watchonly=True, address_filter=self.address['address'])
72+
if self.expected_txs:
73+
assert_equal(len(addresses[0]["txids"]), self.expected_txs)
7874

7975
if txid is not None:
80-
tx, = [tx for tx in txs if tx["txid"] == txid]
81-
assert_equal(tx["label"], self.label)
82-
assert_equal(tx["address"], self.address["address"])
83-
assert_equal(tx["amount"], amount)
84-
assert_equal(tx["category"], "receive")
85-
assert_equal(tx["label"], self.label)
86-
assert_equal(tx["txid"], txid)
87-
assert_equal(tx["confirmations"], confirmations)
88-
assert_equal("trusted" not in tx, True)
76+
address, = [ad for ad in addresses if txid in ad["txids"]]
77+
assert_equal(address["address"], self.address["address"])
78+
assert_equal(address["amount"], self.expected_balance)
79+
assert_equal(address["confirmations"], confirmations)
8980
# Verify the transaction is correctly marked watchonly depending on
9081
# whether the transaction pays to an imported public key or
9182
# imported private key. The test setup ensures that transaction
9283
# inputs will not be from watchonly keys (important because
9384
# involvesWatchonly will be true if either the transaction output
9485
# or inputs are watchonly).
9586
if self.data != Data.priv:
96-
assert_equal(tx["involvesWatchonly"], True)
87+
assert_equal(address["involvesWatchonly"], True)
9788
else:
98-
assert_equal("involvesWatchonly" not in tx, True)
89+
assert_equal("involvesWatchonly" not in address, True)
9990

10091

10192
# List of Variants for each way a key or address could be imported.
@@ -119,7 +110,7 @@ def set_test_params(self):
119110
self.num_nodes = 2 + len(IMPORT_NODES)
120111

121112
def setup_network(self):
122-
extra_args = [["-addresstype=legacy", '-deprecatedrpc=accounts'] for _ in range(self.num_nodes)]
113+
extra_args = [["-addresstype=legacy"] for _ in range(self.num_nodes)]
123114
for i, import_node in enumerate(IMPORT_NODES, 2):
124115
if import_node.prune:
125116
extra_args[i] += ["-prune=1"]
@@ -130,11 +121,10 @@ def setup_network(self):
130121
connect_nodes(self.nodes[i], 0)
131122

132123
def run_test(self):
133-
# Create one transaction on node 0 with a unique amount and label for
124+
# Create one transaction on node 0 with a unique amount for
134125
# each possible type of wallet import RPC.
135126
for i, variant in enumerate(IMPORT_VARIANTS):
136-
variant.label = "label {} {}".format(i, variant)
137-
variant.address = self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress(variant.label))
127+
variant.address = self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress())
138128
variant.key = self.nodes[1].dumpprivkey(variant.address["address"])
139129
variant.initial_amount = 10 - (i + 1) / 4.0
140130
variant.initial_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.initial_amount)

test/functional/wallet_keypool_topup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class KeypoolRestoreTest(BitcoinTestFramework):
2525
def set_test_params(self):
2626
self.setup_clean_chain = True
2727
self.num_nodes = 2
28-
self.extra_args = [['-deprecatedrpc=accounts'], ['-deprecatedrpc=accounts', '-keypool=100', '-keypoolmin=20']]
28+
self.extra_args = [[], ['-keypool=100']]
2929

3030
def run_test(self):
3131
wallet_path = os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat")

test/functional/wallet_listreceivedby.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
class ReceivedByTest(BitcoinTestFramework):
1515
def set_test_params(self):
1616
self.num_nodes = 2
17-
self.extra_args = [['-deprecatedrpc=accounts']] * 2
1817

1918
def run_test(self):
2019
# Generate block to get out of IBD
@@ -112,8 +111,9 @@ def run_test(self):
112111
self.log.info("listreceivedbylabel + getreceivedbylabel Test")
113112

114113
# set pre-state
114+
label = ''
115115
address = self.nodes[1].getnewaddress()
116-
label = self.nodes[1].getaccount(address)
116+
assert_equal(self.nodes[1].getaddressinfo(address)['label'], label)
117117
received_by_label_json = [r for r in self.nodes[1].listreceivedbylabel() if r["label"] == label][0]
118118
balance_by_label = self.nodes[1].getreceivedbylabel(label)
119119

@@ -141,7 +141,8 @@ def run_test(self):
141141
assert_equal(balance, balance_by_label + Decimal("0.1"))
142142

143143
# Create a new label named "mynewlabel" that has a 0 balance
144-
self.nodes[1].getlabeladdress(label="mynewlabel", force=True)
144+
address = self.nodes[1].getnewaddress()
145+
self.nodes[1].setlabel(address, "mynewlabel")
145146
received_by_label_json = [r for r in self.nodes[1].listreceivedbylabel(0, True) if r["label"] == "mynewlabel"][0]
146147

147148
# Test includeempty of listreceivedbylabel

test/functional/wallet_listsinceblock.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class ListSinceBlockTest (BitcoinTestFramework):
1111
def set_test_params(self):
1212
self.num_nodes = 4
1313
self.setup_clean_chain = True
14-
self.extra_args = [['-deprecatedrpc=accounts']] * 4
1514

1615
def run_test(self):
1716
self.nodes[2].generate(101)

test/functional/wallet_listtransactions.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def tx_from_hex(hexstring):
2525
class ListTransactionsTest(BitcoinTestFramework):
2626
def set_test_params(self):
2727
self.num_nodes = 2
28-
self.extra_args = [['-deprecatedrpc=accounts']] * 2
2928
self.enable_mocktime()
3029

3130
def run_test(self):
@@ -34,19 +33,19 @@ def run_test(self):
3433
self.sync_all()
3534
assert_array_result(self.nodes[0].listtransactions(),
3635
{"txid": txid},
37-
{"category": "send", "account": "", "amount": Decimal("-0.1"), "confirmations": 0})
36+
{"category": "send", "amount": Decimal("-0.1"), "confirmations": 0})
3837
assert_array_result(self.nodes[1].listtransactions(),
3938
{"txid": txid},
40-
{"category": "receive", "account": "", "amount": Decimal("0.1"), "confirmations": 0})
39+
{"category": "receive", "amount": Decimal("0.1"), "confirmations": 0})
4140
# mine a block, confirmations should change:
4241
self.nodes[0].generate(1)
4342
self.sync_all()
4443
assert_array_result(self.nodes[0].listtransactions(),
4544
{"txid": txid},
46-
{"category": "send", "account": "", "amount": Decimal("-0.1"), "confirmations": 1})
45+
{"category": "send", "amount": Decimal("-0.1"), "confirmations": 1})
4746
assert_array_result(self.nodes[1].listtransactions(),
4847
{"txid": txid},
49-
{"category": "receive", "account": "", "amount": Decimal("0.1"), "confirmations": 1})
48+
{"category": "receive", "amount": Decimal("0.1"), "confirmations": 1})
5049

5150
# send-to-self:
5251
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 0.2)
@@ -60,8 +59,8 @@ def run_test(self):
6059
# sendmany from node1: twice to self, twice to node2:
6160
send_to = {self.nodes[0].getnewaddress(): 0.11,
6261
self.nodes[1].getnewaddress(): 0.22,
63-
self.nodes[0].getaccountaddress("from1"): 0.33,
64-
self.nodes[1].getaccountaddress("toself"): 0.44}
62+
self.nodes[0].getnewaddress(): 0.33,
63+
self.nodes[1].getnewaddress(): 0.44}
6564
txid = self.nodes[1].sendmany("", send_to)
6665
self.sync_all()
6766
assert_array_result(self.nodes[1].listtransactions(),
@@ -81,24 +80,23 @@ def run_test(self):
8180
{"txid": txid})
8281
assert_array_result(self.nodes[0].listtransactions(),
8382
{"category": "receive", "amount": Decimal("0.33")},
84-
{"txid": txid, "account": "from1"})
83+
{"txid": txid})
8584
assert_array_result(self.nodes[1].listtransactions(),
8685
{"category": "send", "amount": Decimal("-0.44")},
87-
{"txid": txid, "account": ""})
86+
{"txid": txid})
8887
assert_array_result(self.nodes[1].listtransactions(),
8988
{"category": "receive", "amount": Decimal("0.44")},
90-
{"txid": txid, "account": "toself"})
89+
{"txid": txid})
9190

9291
pubkey = self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress())['pubkey']
9392
multisig = self.nodes[1].createmultisig(1, [pubkey])
9493
self.nodes[0].importaddress(multisig["redeemScript"], "watchonly", False, True)
9594
txid = self.nodes[1].sendtoaddress(multisig["address"], 0.1)
9695
self.nodes[1].generate(1)
9796
self.sync_all()
98-
assert(len(self.nodes[0].listtransactions("watchonly", 100, 0, False)) == 0)
99-
assert_array_result(self.nodes[0].listtransactions("watchonly", 100, 0, True),
100-
{"category": "receive", "amount": Decimal("0.1")},
101-
{"txid": txid, "account": "watchonly"})
97+
assert not [tx for tx in self.nodes[0].listtransactions(dummy="*", count=100, skip=0, include_watchonly=False) if "label" in tx and tx["label"] == "watchonly"]
98+
txs = [tx for tx in self.nodes[0].listtransactions(dummy="*", count=100, skip=0, include_watchonly=True) if "label" in tx and tx['label'] == 'watchonly']
99+
assert_array_result(txs, {"category": "receive", "amount": Decimal("0.1")}, {"txid": txid})
102100

103101
self.run_rbf_opt_in_test()
104102

0 commit comments

Comments
 (0)