Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_blockchain.py
Show All 28 Lines | from test_framework.blocktools import ( | ||||
TIME_GENESIS_BLOCK, | TIME_GENESIS_BLOCK, | ||||
) | ) | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
msg_block, | msg_block, | ||||
) | ) | ||||
from test_framework.p2p import P2PInterface | from test_framework.p2p import P2PInterface | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import ( | ||||
assert_approx, | |||||
assert_equal, | assert_equal, | ||||
assert_greater_than, | assert_greater_than, | ||||
assert_greater_than_or_equal, | assert_greater_than_or_equal, | ||||
assert_raises, | assert_raises, | ||||
assert_raises_rpc_error, | assert_raises_rpc_error, | ||||
assert_is_hex_string, | assert_is_hex_string, | ||||
assert_is_hash_string, | assert_is_hash_string, | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | def _test_stopatheight(self): | ||||
6, self.nodes[0].get_deterministic_priv_key().address) | 6, self.nodes[0].get_deterministic_priv_key().address) | ||||
assert_equal(self.nodes[0].getblockcount(), 206) | assert_equal(self.nodes[0].getblockcount(), 206) | ||||
self.log.debug('Node should not stop at this height') | self.log.debug('Node should not stop at this height') | ||||
assert_raises(subprocess.TimeoutExpired, | assert_raises(subprocess.TimeoutExpired, | ||||
lambda: self.nodes[0].process.wait(timeout=3)) | lambda: self.nodes[0].process.wait(timeout=3)) | ||||
try: | try: | ||||
self.nodes[0].generatetoaddress( | self.nodes[0].generatetoaddress( | ||||
1, self.nodes[0].get_deterministic_priv_key().address) | 1, self.nodes[0].get_deterministic_priv_key().address) | ||||
except (ConnectionError, http.client.BadStatusLine): | except (ConnectionError, http.client.BadStatusLine): | ||||
Lint: flake8 F821: undefined name 'ConnectionError' | |||||
pass # The node already shut down before response | pass # The node already shut down before response | ||||
self.log.debug('Node should stop at this height...') | self.log.debug('Node should stop at this height...') | ||||
self.nodes[0].wait_until_stopped() | self.nodes[0].wait_until_stopped() | ||||
self.start_node(0) | self.start_node(0) | ||||
assert_equal(self.nodes[0].getblockcount(), 207) | assert_equal(self.nodes[0].getblockcount(), 207) | ||||
def _test_waitforblockheight(self): | def _test_waitforblockheight(self): | ||||
self.log.info("Test waitforblockheight") | self.log.info("Test waitforblockheight") | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | def _test_getblock(self): | ||||
assert_equal(blockinfo['hash'], transactioninfo['blockhash']) | assert_equal(blockinfo['hash'], transactioninfo['blockhash']) | ||||
assert_equal( | assert_equal( | ||||
blockinfo['confirmations'], | blockinfo['confirmations'], | ||||
transactioninfo['confirmations']) | transactioninfo['confirmations']) | ||||
assert_equal(blockinfo['height'], blockheaderinfo['height']) | assert_equal(blockinfo['height'], blockheaderinfo['height']) | ||||
assert_equal(blockinfo['versionHex'], blockheaderinfo['versionHex']) | assert_equal(blockinfo['versionHex'], blockheaderinfo['versionHex']) | ||||
assert_equal(blockinfo['version'], blockheaderinfo['version']) | assert_equal(blockinfo['version'], blockheaderinfo['version']) | ||||
assert_equal(blockinfo['size'], 181) | assert_approx(blockinfo['size'], 181) | ||||
assert_equal(blockinfo['merkleroot'], blockheaderinfo['merkleroot']) | assert_equal(blockinfo['merkleroot'], blockheaderinfo['merkleroot']) | ||||
# Verify transaction data by check the hex values | # Verify transaction data by check the hex values | ||||
for tx in blockinfo['tx']: | for tx in blockinfo['tx']: | ||||
rawtransaction = node.getrawtransaction(tx['txid'], True) | rawtransaction = node.getrawtransaction(tx['txid'], True) | ||||
assert_equal(tx['hex'], rawtransaction['hex']) | assert_equal(tx['hex'], rawtransaction['hex']) | ||||
assert_equal(blockinfo['time'], blockheaderinfo['time']) | assert_equal(blockinfo['time'], blockheaderinfo['time']) | ||||
assert_equal(blockinfo['mediantime'], blockheaderinfo['mediantime']) | assert_equal(blockinfo['mediantime'], blockheaderinfo['mediantime']) | ||||
assert_equal(blockinfo['nonce'], blockheaderinfo['nonce']) | assert_equal(blockinfo['nonce'], blockheaderinfo['nonce']) | ||||
Show All 14 Lines |
undefined name 'ConnectionError'