You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

blockchain.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env python2
  2. # Copyright (c) 2014-2015 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. #
  6. # Test RPC calls related to blockchain state.
  7. #
  8. import decimal
  9. from test_framework.test_framework import BitcoinTestFramework
  10. from test_framework.util import (
  11. initialize_chain,
  12. assert_equal,
  13. start_nodes,
  14. connect_nodes_bi,
  15. )
  16. class BlockchainTest(BitcoinTestFramework):
  17. """
  18. Test blockchain-related RPC calls:
  19. - gettxoutsetinfo
  20. """
  21. def setup_chain(self):
  22. print("Initializing test directory " + self.options.tmpdir)
  23. initialize_chain(self.options.tmpdir)
  24. def setup_network(self, split=False):
  25. self.nodes = start_nodes(2, self.options.tmpdir)
  26. connect_nodes_bi(self.nodes, 0, 1)
  27. self.is_network_split = False
  28. self.sync_all()
  29. def run_test(self):
  30. node = self.nodes[0]
  31. res = node.gettxoutsetinfo()
  32. assert_equal(res[u'total_amount'], decimal.Decimal('8725.00000000'))
  33. assert_equal(res[u'transactions'], 200)
  34. assert_equal(res[u'height'], 200)
  35. assert_equal(res[u'txouts'], 200)
  36. assert_equal(res[u'bytes_serialized'], 13924),
  37. assert_equal(len(res[u'bestblock']), 64)
  38. assert_equal(len(res[u'hash_serialized']), 64)
  39. if __name__ == '__main__':
  40. BlockchainTest().main()