Changeset View
Changeset View
Standalone View
Standalone View
test/functional/chronik_blockchain_info.py
Show All 10 Lines | |||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal | from test_framework.util import assert_equal | ||||
class ChronikBlockchainInfoTest(BitcoinTestFramework): | class ChronikBlockchainInfoTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.extra_args = [['-chronik']] | self.extra_args = [["-chronik"]] | ||||
def skip_test_if_missing_module(self): | def skip_test_if_missing_module(self): | ||||
self.skip_if_no_chronik() | self.skip_if_no_chronik() | ||||
def run_test(self): | def run_test(self): | ||||
from test_framework.chronik.client import ChronikClient, pb | from test_framework.chronik.client import ChronikClient, pb | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
chronik = ChronikClient('127.0.0.1', node.chronik_port) | chronik = ChronikClient("127.0.0.1", node.chronik_port) | ||||
assert_equal(chronik.blockchain_info().ok(), pb.BlockchainInfo( | assert_equal( | ||||
chronik.blockchain_info().ok(), | |||||
pb.BlockchainInfo( | |||||
tip_hash=bytes.fromhex(GENESIS_BLOCK_HASH)[::-1], | tip_hash=bytes.fromhex(GENESIS_BLOCK_HASH)[::-1], | ||||
tip_height=0, | tip_height=0, | ||||
)) | ), | ||||
) | |||||
block_hashes = self.generatetoaddress(node, 12, ADDRESS_ECREG_UNSPENDABLE) | block_hashes = self.generatetoaddress(node, 12, ADDRESS_ECREG_UNSPENDABLE) | ||||
assert_equal(chronik.blockchain_info().ok(), pb.BlockchainInfo( | assert_equal( | ||||
chronik.blockchain_info().ok(), | |||||
pb.BlockchainInfo( | |||||
tip_hash=bytes.fromhex(block_hashes[11])[::-1], | tip_hash=bytes.fromhex(block_hashes[11])[::-1], | ||||
tip_height=12, | tip_height=12, | ||||
)) | ), | ||||
) | |||||
node.invalidateblock(block_hashes[6]) | node.invalidateblock(block_hashes[6]) | ||||
assert_equal(chronik.blockchain_info().ok(), pb.BlockchainInfo( | assert_equal( | ||||
chronik.blockchain_info().ok(), | |||||
pb.BlockchainInfo( | |||||
tip_hash=bytes.fromhex(block_hashes[5])[::-1], | tip_hash=bytes.fromhex(block_hashes[5])[::-1], | ||||
tip_height=6, | tip_height=6, | ||||
)) | ), | ||||
) | |||||
if __name__ == '__main__': | if __name__ == "__main__": | ||||
ChronikBlockchainInfoTest().main() | ChronikBlockchainInfoTest().main() |