~ubuntu-branches/debian/stretch/bitcoin/stretch

« back to all changes in this revision

Viewing changes to qa/rpc-tests/blockchain.py

  • Committer: Package Import Robot
  • Author(s): Anthony Towns
  • Date: 2016-10-21 17:13:13 UTC
  • mfrom: (1.3.2)
  • Revision ID: package-import@ubuntu.com-20161021171313-7eu2ltpbk0xag3q1
Tags: 0.13.0-0.1
* Non-maintainer upload.
* New upstream release.
* Allow compilation with gcc/g++ 6. (Closes: Bug#835963)
* Additional fixes for openssl 1.1 compatibility. (See Bug#828248)
* Check if -latomic is needed (it is on mips*).
* Remove reproducible build patch, since leveldb build system is
  no longer used in 0.13. (See Bug#791834)
* Update description since the blockchain is much more than "several GB"
  now. (Closes: Bug#835809)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python2
2
 
# Copyright (c) 2014-2015 The Bitcoin Core developers
 
1
#!/usr/bin/env python3
 
2
# Copyright (c) 2014-2016 The Bitcoin Core developers
3
3
# Distributed under the MIT software license, see the accompanying
4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
 
6
6
#
7
7
# Test RPC calls related to blockchain state. Tests correspond to code in
8
 
# rpcblockchain.cpp.
 
8
# rpc/blockchain.cpp.
9
9
#
10
10
 
11
11
from decimal import Decimal
13
13
from test_framework.test_framework import BitcoinTestFramework
14
14
from test_framework.authproxy import JSONRPCException
15
15
from test_framework.util import (
16
 
    initialize_chain,
17
16
    assert_equal,
18
17
    assert_raises,
19
18
    assert_is_hex_string,
28
27
    Test blockchain-related RPC calls:
29
28
 
30
29
        - gettxoutsetinfo
 
30
        - verifychain
31
31
 
32
32
    """
33
33
 
34
 
    def setup_chain(self):
35
 
        print("Initializing test directory " + self.options.tmpdir)
36
 
        initialize_chain(self.options.tmpdir)
 
34
    def __init__(self):
 
35
        super().__init__()
 
36
        self.setup_clean_chain = False
 
37
        self.num_nodes = 2
37
38
 
38
39
    def setup_network(self, split=False):
39
 
        self.nodes = start_nodes(2, self.options.tmpdir)
 
40
        self.nodes = start_nodes(self.num_nodes, self.options.tmpdir)
40
41
        connect_nodes_bi(self.nodes, 0, 1)
41
42
        self.is_network_split = False
42
43
        self.sync_all()
44
45
    def run_test(self):
45
46
        self._test_gettxoutsetinfo()
46
47
        self._test_getblockheader()
 
48
        self.nodes[0].verifychain(4, 0)
47
49
 
48
50
    def _test_gettxoutsetinfo(self):
49
51
        node = self.nodes[0]
50
52
        res = node.gettxoutsetinfo()
51
53
 
52
 
        assert_equal(res[u'total_amount'], Decimal('8725.00000000'))
53
 
        assert_equal(res[u'transactions'], 200)
54
 
        assert_equal(res[u'height'], 200)
55
 
        assert_equal(res[u'txouts'], 200)
56
 
        assert_equal(res[u'bytes_serialized'], 13924),
57
 
        assert_equal(len(res[u'bestblock']), 64)
58
 
        assert_equal(len(res[u'hash_serialized']), 64)
 
54
        assert_equal(res['total_amount'], Decimal('8725.00000000'))
 
55
        assert_equal(res['transactions'], 200)
 
56
        assert_equal(res['height'], 200)
 
57
        assert_equal(res['txouts'], 200)
 
58
        assert_equal(res['bytes_serialized'], 13924),
 
59
        assert_equal(len(res['bestblock']), 64)
 
60
        assert_equal(len(res['hash_serialized']), 64)
59
61
 
60
62
    def _test_getblockheader(self):
61
63
        node = self.nodes[0]
80
82
        assert isinstance(header['mediantime'], int)
81
83
        assert isinstance(header['nonce'], int)
82
84
        assert isinstance(header['version'], int)
 
85
        assert isinstance(int(header['versionHex'], 16), int)
83
86
        assert isinstance(header['difficulty'], Decimal)
84
87
 
85
88
if __name__ == '__main__':