[tests] Remove is_network_split from funtional test cases
[bitcoinplatinum.git] / test / functional / wallet-accounts.py
blob700f06b2cfafb35c23dfbf0088f5a9efbfa6525c
1 #!/usr/bin/env python3
2 # Copyright (c) 2016 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 """Test account RPCs.
7 RPCs tested are:
8 - getaccountaddress
9 - getaddressesbyaccount
10 - setaccount
11 - sendfrom (with account arguments)
12 - move (with account arguments)
13 """
15 from test_framework.test_framework import BitcoinTestFramework
16 from test_framework.util import (
17 start_nodes,
18 assert_equal,
21 class WalletAccountsTest(BitcoinTestFramework):
23 def __init__(self):
24 super().__init__()
25 self.setup_clean_chain = True
26 self.num_nodes = 1
27 self.extra_args = [[]]
29 def run_test (self):
30 node = self.nodes[0]
31 # Check that there's no UTXO on any of the nodes
32 assert_equal(len(node.listunspent()), 0)
34 node.generate(101)
36 assert_equal(node.getbalance(), 50)
38 accounts = ["a","b","c","d","e"]
39 amount_to_send = 1.0
40 account_addresses = dict()
41 for account in accounts:
42 address = node.getaccountaddress(account)
43 account_addresses[account] = address
45 node.getnewaddress(account)
46 assert_equal(node.getaccount(address), account)
47 assert(address in node.getaddressesbyaccount(account))
49 node.sendfrom("", address, amount_to_send)
51 node.generate(1)
53 for i in range(len(accounts)):
54 from_account = accounts[i]
55 to_account = accounts[(i+1)%len(accounts)]
56 to_address = account_addresses[to_account]
57 node.sendfrom(from_account, to_address, amount_to_send)
59 node.generate(1)
61 for account in accounts:
62 address = node.getaccountaddress(account)
63 assert(address != account_addresses[account])
64 assert_equal(node.getreceivedbyaccount(account), 2)
65 node.move(account, "", node.getbalance(account))
67 node.generate(101)
69 expected_account_balances = {"": 5200}
70 for account in accounts:
71 expected_account_balances[account] = 0
73 assert_equal(node.listaccounts(), expected_account_balances)
75 assert_equal(node.getbalance(""), 5200)
77 for account in accounts:
78 address = node.getaccountaddress("")
79 node.setaccount(address, account)
80 assert(address in node.getaddressesbyaccount(account))
81 assert(address not in node.getaddressesbyaccount(""))
83 for account in accounts:
84 addresses = []
85 for x in range(10):
86 addresses.append(node.getnewaddress())
87 multisig_address = node.addmultisigaddress(5, addresses, account)
88 node.sendfrom("", multisig_address, 50)
90 node.generate(101)
92 for account in accounts:
93 assert_equal(node.getbalance(account), 50)
95 if __name__ == '__main__':
96 WalletAccountsTest().main ()