mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
c81394b975
589827975
scripted-diff: various renames for per-utxo consistency (Pieter Wuille)a5e02bc7f
Increase travis unit test timeout (Pieter Wuille)73de2c1ff
Rename CCoinsCacheEntry::coins to coin (Pieter Wuille)119e552f7
Merge CCoinsViewCache's GetOutputFor and AccessCoin (Pieter Wuille)580b02309
[MOVEONLY] Move old CCoins class to txdb.cpp (Pieter Wuille)8b25d2c0c
Upgrade from per-tx database to per-txout (Pieter Wuille)b2af357f3
Reduce reserved memory space for flushing (Pieter Wuille)41aa5b79a
Pack Coin more tightly (Pieter Wuille)97072d668
Remove unused CCoins methods (Pieter Wuille)ce23efaa5
Extend coins_tests (Pieter Wuille)508307968
Switch CCoinsView and chainstate db from per-txid to per-txout (Pieter Wuille)4ec0d9e79
Refactor GetUTXOStats in preparation for per-COutPoint iteration (Pieter Wuille)13870b56f
Replace CCoins-based CTxMemPool::pruneSpent with isSpent (Pieter Wuille)05293f3cb
Remove ModifyCoins/ModifyNewCoins (Pieter Wuille)961e48397
Switch tests from ModifyCoins to AddCoin/SpendCoin (Pieter Wuille)8b3868c1b
Switch CScriptCheck to use Coin instead of CCoins (Pieter Wuille)c87b957a3
Only pass things committed to by tx's witness hash to CScriptCheck (Matt Corallo)f68cdfe92
Switch from per-tx to per-txout CCoinsViewCache methods in some places (Pieter Wuille)000391132
Introduce new per-txout CCoinsViewCache functions (Pieter Wuille)bd83111a0
Optimization: Coin&& to ApplyTxInUndo (Pieter Wuille)cb2c7fdac
Replace CTxInUndo with Coin (Pieter Wuille)422634e2f
Introduce Coin, a single unspent output (Pieter Wuille)7d991b55d
Store/allow tx metadata in all undo records (Pieter Wuille)c3aa0c119
Report on-disk size in gettxoutsetinfo (Pieter Wuille)d34242430
Remove/ignore tx version in utxo and undo (Pieter Wuille)7e0032290
Add specialization of SipHash for 256 + 32 bit data (Pieter Wuille)e484652fc
Introduce CHashVerifier to hash read data (Pieter Wuille)f54580e7e
error() in disconnect for disk corruption, not inconsistency (Pieter Wuille)e66dbde6d
Add SizeEstimate to CDBBatch (Pieter Wuille) Tree-SHA512: ce1fb1e40c77d38915cd02189fab7a8b125c7f44d425c85579d872c3bede3a437760997907c99d7b3017ced1c2de54b2ac7223d99d83a6658fe5ef61edef1de3
113 lines
3.8 KiB
Python
Executable File
113 lines
3.8 KiB
Python
Executable File
#!/usr/bin/env python2
|
|
# Copyright (c) 2014-2015 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#
|
|
# Test RPC calls related to blockchain state. Tests correspond to code in
|
|
# rpc/blockchain.cpp.
|
|
#
|
|
|
|
from decimal import Decimal
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.authproxy import JSONRPCException
|
|
from test_framework.util import (
|
|
initialize_chain,
|
|
assert_equal,
|
|
assert_raises,
|
|
assert_is_hex_string,
|
|
assert_is_hash_string,
|
|
start_nodes,
|
|
connect_nodes_bi,
|
|
)
|
|
|
|
|
|
class BlockchainTest(BitcoinTestFramework):
|
|
"""
|
|
Test blockchain-related RPC calls:
|
|
|
|
- gettxoutsetinfo
|
|
- verifychain
|
|
|
|
"""
|
|
|
|
def setup_chain(self):
|
|
print("Initializing test directory " + self.options.tmpdir)
|
|
initialize_chain(self.options.tmpdir)
|
|
|
|
def setup_network(self, split=False):
|
|
self.nodes = start_nodes(1, self.options.tmpdir)
|
|
self.is_network_split = False
|
|
self.sync_all()
|
|
|
|
def run_test(self):
|
|
self._test_gettxoutsetinfo()
|
|
self._test_getblockheader()
|
|
self.nodes[0].verifychain(4, 0)
|
|
|
|
def _test_gettxoutsetinfo(self):
|
|
node = self.nodes[0]
|
|
res = node.gettxoutsetinfo()
|
|
|
|
assert_equal(res[u'total_amount'], Decimal('98214.28571450'))
|
|
assert_equal(res[u'transactions'], 200)
|
|
assert_equal(res[u'height'], 200)
|
|
assert_equal(res[u'txouts'], 200)
|
|
size = res['disk_size']
|
|
assert size > 6400
|
|
assert size < 64000
|
|
assert_equal(len(res[u'bestblock']), 64)
|
|
assert_equal(len(res[u'hash_serialized_2']), 64)
|
|
|
|
print("Test that gettxoutsetinfo() works for blockchain with just the genesis block")
|
|
b1hash = node.getblockhash(1)
|
|
node.invalidateblock(b1hash)
|
|
|
|
res2 = node.gettxoutsetinfo()
|
|
assert_equal(res2['transactions'], 0)
|
|
assert_equal(res2['total_amount'], Decimal('0'))
|
|
assert_equal(res2['height'], 0)
|
|
assert_equal(res2['txouts'], 0)
|
|
assert_equal(res2['bestblock'], node.getblockhash(0))
|
|
assert_equal(len(res2['hash_serialized_2']), 64)
|
|
|
|
print("Test that gettxoutsetinfo() returns the same result after invalidate/reconsider block")
|
|
node.reconsiderblock(b1hash)
|
|
|
|
res3 = node.gettxoutsetinfo()
|
|
assert_equal(res['total_amount'], res3['total_amount'])
|
|
assert_equal(res['transactions'], res3['transactions'])
|
|
assert_equal(res['height'], res3['height'])
|
|
assert_equal(res['txouts'], res3['txouts'])
|
|
assert_equal(res['bestblock'], res3['bestblock'])
|
|
assert_equal(res['hash_serialized_2'], res3['hash_serialized_2'])
|
|
|
|
def _test_getblockheader(self):
|
|
node = self.nodes[0]
|
|
|
|
assert_raises(
|
|
JSONRPCException, lambda: node.getblockheader('nonsense'))
|
|
|
|
besthash = node.getbestblockhash()
|
|
secondbesthash = node.getblockhash(199)
|
|
header = node.getblockheader(besthash)
|
|
|
|
assert_equal(header['hash'], besthash)
|
|
assert_equal(header['height'], 200)
|
|
assert_equal(header['confirmations'], 1)
|
|
assert_equal(header['previousblockhash'], secondbesthash)
|
|
assert_is_hex_string(header['chainwork'])
|
|
assert_is_hash_string(header['hash'])
|
|
assert_is_hash_string(header['previousblockhash'])
|
|
assert_is_hash_string(header['merkleroot'])
|
|
assert_is_hash_string(header['bits'], length=None)
|
|
assert isinstance(header['time'], int)
|
|
assert isinstance(header['mediantime'], int)
|
|
assert isinstance(header['nonce'], int)
|
|
assert isinstance(header['version'], int)
|
|
assert isinstance(header['difficulty'], Decimal)
|
|
|
|
if __name__ == '__main__':
|
|
BlockchainTest().main()
|