Changeset View
Changeset View
Standalone View
Standalone View
test/functional/chronik_blocks.py
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
f'400: Blocks page size too large, may not be above 500 but got {2**31}') | f'400: Blocks page size too large, may not be above 500 but got {2**31}') | ||||
genesis_info = pb.BlockInfo( | genesis_info = pb.BlockInfo( | ||||
hash=bytes.fromhex(GENESIS_BLOCK_HASH)[::-1], | hash=bytes.fromhex(GENESIS_BLOCK_HASH)[::-1], | ||||
prev_hash=bytes(32), | prev_hash=bytes(32), | ||||
height=0, | height=0, | ||||
n_bits=0x207fffff, | n_bits=0x207fffff, | ||||
timestamp=TIME_GENESIS_BLOCK, | timestamp=TIME_GENESIS_BLOCK, | ||||
block_size=285, | |||||
num_txs=1, | |||||
num_inputs=1, | |||||
num_outputs=1, | |||||
sum_input_sats=0, | |||||
sum_coinbase_output_sats=5000000000, | |||||
sum_normal_output_sats=0, | |||||
sum_burned_sats=0, | |||||
) | ) | ||||
assert_equal(chronik.blocks(0, 100).ok(), pb.Blocks(blocks=[genesis_info])) | assert_equal(chronik.blocks(0, 100).ok(), pb.Blocks(blocks=[genesis_info])) | ||||
assert_equal(chronik.blocks(0, 0).ok(), pb.Blocks(blocks=[genesis_info])) | assert_equal(chronik.blocks(0, 0).ok(), pb.Blocks(blocks=[genesis_info])) | ||||
assert_equal(chronik.blocks(500, 500).ok(), pb.Blocks(blocks=[])) | assert_equal(chronik.blocks(500, 500).ok(), pb.Blocks(blocks=[])) | ||||
assert_equal(chronik.blocks(1, 500).ok(), pb.Blocks(blocks=[])) | assert_equal(chronik.blocks(1, 500).ok(), pb.Blocks(blocks=[])) | ||||
assert_equal(chronik.blocks(500, 999).ok(), pb.Blocks(blocks=[])) | assert_equal(chronik.blocks(500, 999).ok(), pb.Blocks(blocks=[])) | ||||
assert_equal(chronik.blocks(2**31 - 500, 2**31 - 1).ok(), pb.Blocks(blocks=[])) | assert_equal(chronik.blocks(2**31 - 500, 2**31 - 1).ok(), pb.Blocks(blocks=[])) | ||||
block_hashes = [GENESIS_BLOCK_HASH] | block_hashes = [GENESIS_BLOCK_HASH] | ||||
block_hashes += self.generatetoaddress(node, 12, ADDRESS_ECREG_UNSPENDABLE) | block_hashes += self.generatetoaddress(node, 12, ADDRESS_ECREG_UNSPENDABLE) | ||||
assert_equal( | assert_equal( | ||||
chronik.blocks(8, 12).ok(), | chronik.blocks(8, 12).ok(), | ||||
pb.Blocks(blocks=[ | pb.Blocks(blocks=[ | ||||
pb.BlockInfo( | pb.BlockInfo( | ||||
hash=bytes.fromhex(block_hashes[height])[::-1], | hash=bytes.fromhex(block_hashes[height])[::-1], | ||||
prev_hash=bytes.fromhex(block_hashes[height - 1])[::-1], | prev_hash=bytes.fromhex(block_hashes[height - 1])[::-1], | ||||
height=height, | height=height, | ||||
n_bits=0x207fffff, | n_bits=0x207fffff, | ||||
timestamp=1300000003, | timestamp=1300000003, | ||||
block_size=181, | |||||
num_txs=1, | |||||
num_inputs=1, | |||||
num_outputs=1, | |||||
sum_input_sats=0, | |||||
sum_coinbase_output_sats=5000000000, | |||||
sum_normal_output_sats=0, | |||||
sum_burned_sats=0, | |||||
) | ) | ||||
for height in range(8, 13) | for height in range(8, 13) | ||||
]), | ]), | ||||
) | ) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
ChronikBlockRangeTest().main() | ChronikBlockRangeTest().main() |