Skip to content

Commit 6b9faf7

Browse files
committed
[QA] add basic multiwallet test
1 parent 979d0b8 commit 6b9faf7

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

test/functional/multiwallet.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2017 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 multiwallet."""
6+
from test_framework.test_framework import BitcoinTestFramework
7+
from test_framework.util import *
8+
9+
class MultiWalletTest(BitcoinTestFramework):
10+
11+
def __init__(self):
12+
super().__init__()
13+
self.setup_clean_chain = True
14+
self.num_nodes = 1
15+
self.extra_args = [['-wallet=w1', '-wallet=w2', '-wallet=w3']]
16+
17+
def run_test(self):
18+
w1 = self.nodes[0] / "wallet/w1"
19+
w1.generate(1)
20+
21+
#accessing wallet RPC without using wallet endpoint fails
22+
assert_raises_jsonrpc(-32601, "Method not found", self.nodes[0].getwalletinfo)
23+
24+
#check w1 wallet balance
25+
walletinfo = w1.getwalletinfo()
26+
assert_equal(walletinfo['immature_balance'], 50)
27+
28+
#check w1 wallet balance
29+
w2 = self.nodes[0] / "wallet/w2"
30+
walletinfo = w2.getwalletinfo()
31+
assert_equal(walletinfo['immature_balance'], 0)
32+
33+
w3 = self.nodes[0] / "wallet/w3"
34+
35+
w1.generate(101)
36+
assert_equal(w1.getbalance(), 100)
37+
assert_equal(w2.getbalance(), 0)
38+
assert_equal(w3.getbalance(), 0)
39+
40+
w1.sendtoaddress(w2.getnewaddress(), 1)
41+
w1.sendtoaddress(w3.getnewaddress(), 2)
42+
w1.generate(1)
43+
assert_equal(w2.getbalance(), 1)
44+
assert_equal(w3.getbalance(), 2)
45+
46+
if __name__ == '__main__':
47+
MultiWalletTest().main()

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
'segwit.py',
6464
# vv Tests less than 2m vv
6565
'wallet.py',
66+
'multiwallet.py',
6667
'wallet-accounts.py',
6768
'p2p-segwit.py',
6869
'wallet-dump.py',

0 commit comments

Comments
 (0)