Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_blockchain.py
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | from test_framework.mininode import ( | ||||
P2PInterface, | P2PInterface, | ||||
) | ) | ||||
class BlockchainTest(BitcoinTestFramework): | class BlockchainTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.extra_args = [['-stopatheight=207', '-prune=1']] | |||||
def run_test(self): | def run_test(self): | ||||
# Set extra args with pruning after rescan is complete | |||||
self.restart_node(0, extra_args=['-stopatheight=207', '-prune=1']) | |||||
self._test_getblockchaininfo() | self._test_getblockchaininfo() | ||||
self._test_getchaintxstats() | self._test_getchaintxstats() | ||||
self._test_gettxoutsetinfo() | self._test_gettxoutsetinfo() | ||||
self._test_getblockheader() | self._test_getblockheader() | ||||
self._test_getdifficulty() | self._test_getdifficulty() | ||||
self._test_getnetworkhashps() | self._test_getnetworkhashps() | ||||
self._test_stopatheight() | self._test_stopatheight() | ||||
self._test_getblock() | self._test_getblock() | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | class BlockchainTest(BitcoinTestFramework): | ||||
def _test_gettxoutsetinfo(self): | def _test_gettxoutsetinfo(self): | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
res = node.gettxoutsetinfo() | res = node.gettxoutsetinfo() | ||||
assert_equal(res['total_amount'], Decimal('8725.00000000')) | assert_equal(res['total_amount'], Decimal('8725.00000000')) | ||||
assert_equal(res['transactions'], 200) | assert_equal(res['transactions'], 200) | ||||
assert_equal(res['height'], 200) | assert_equal(res['height'], 200) | ||||
assert_equal(res['txouts'], 200) | assert_equal(res['txouts'], 200) | ||||
assert_equal(res['bogosize'], 17000), | assert_equal(res['bogosize'], 15000), | ||||
assert_equal(res['bestblock'], node.getblockhash(200)) | assert_equal(res['bestblock'], node.getblockhash(200)) | ||||
size = res['disk_size'] | size = res['disk_size'] | ||||
assert size > 6400 | assert size > 6400 | ||||
assert size < 64000 | assert size < 64000 | ||||
assert_equal(len(res['bestblock']), 64) | assert_equal(len(res['bestblock']), 64) | ||||
assert_equal(len(res['hash_serialized']), 64) | assert_equal(len(res['hash_serialized']), 64) | ||||
self.log.info( | self.log.info( | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | def _test_getblock(self): | ||||
assert_equal(getblockinfo['hash'], gettransactioninfo['blockhash']) | assert_equal(getblockinfo['hash'], gettransactioninfo['blockhash']) | ||||
assert_equal( | assert_equal( | ||||
getblockinfo['confirmations'], gettransactioninfo['confirmations']) | getblockinfo['confirmations'], gettransactioninfo['confirmations']) | ||||
assert_equal(getblockinfo['height'], getblockheaderinfo['height']) | assert_equal(getblockinfo['height'], getblockheaderinfo['height']) | ||||
assert_equal( | assert_equal( | ||||
getblockinfo['versionHex'], getblockheaderinfo['versionHex']) | getblockinfo['versionHex'], getblockheaderinfo['versionHex']) | ||||
assert_equal(getblockinfo['version'], getblockheaderinfo['version']) | assert_equal(getblockinfo['version'], getblockheaderinfo['version']) | ||||
assert_equal(getblockinfo['size'], 188) | assert_equal(getblockinfo['size'], 181) | ||||
assert_equal( | assert_equal( | ||||
getblockinfo['merkleroot'], getblockheaderinfo['merkleroot']) | getblockinfo['merkleroot'], getblockheaderinfo['merkleroot']) | ||||
# Verify transaction data by check the hex values | # Verify transaction data by check the hex values | ||||
for tx in getblockinfo['tx']: | for tx in getblockinfo['tx']: | ||||
getrawtransaction = node.getrawtransaction(tx['txid'], True) | getrawtransaction = node.getrawtransaction(tx['txid'], True) | ||||
assert_equal(tx['hex'], getrawtransaction['hex']) | assert_equal(tx['hex'], getrawtransaction['hex']) | ||||
assert_equal(getblockinfo['time'], getblockheaderinfo['time']) | assert_equal(getblockinfo['time'], getblockheaderinfo['time']) | ||||
assert_equal( | assert_equal( | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |