|
| 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() |
0 commit comments