def test_json(self): bt = BlockTools() test_constants: Dict[str, Any] = { "DIFFICULTY_STARTING": 5, "DISCRIMINANT_SIZE_BITS": 16, "BLOCK_TIME_TARGET": 10, "MIN_BLOCK_TIME": 2, "DIFFICULTY_EPOCH": 12, # The number of blocks per epoch "DIFFICULTY_DELAY": 3, # EPOCH / WARP_FACTOR } block = bt.create_genesis_block(test_constants, bytes([0] * 32), b"0") dict_block = block.to_json_dict() assert FullBlock.from_json_dict(dict_block) == block
bt = BlockTools() test_constants: Dict[str, Any] = { "DIFFICULTY_STARTING": 5, "DISCRIMINANT_SIZE_BITS": 16, "BLOCK_TIME_TARGET": 10, "MIN_BLOCK_TIME": 2, "DIFFICULTY_FACTOR": 3, "DIFFICULTY_EPOCH": 12, # The number of blocks per epoch "DIFFICULTY_WARP_FACTOR": 4, # DELAY divides EPOCH in order to warp efficiently. "DIFFICULTY_DELAY": 3, # EPOCH / WARP_FACTOR } test_constants["GENESIS_BLOCK"] = bytes( bt.create_genesis_block(test_constants, bytes([0] * 32), b"0")) @pytest.fixture(scope="module") def event_loop(): loop = asyncio.get_event_loop() yield loop class TestStore: @pytest.mark.asyncio async def test_basic_store(self): assert sqlite3.threadsafety == 1 blocks = bt.get_consecutive_blocks(test_constants, 9, [], 9, b"0") db_filename = "blockchain_test" db_filename_2 = "blockchain_test_2"
if __name__ == "__main__": from tests.block_tools import BlockTools, test_constants from chia.util.default_root import DEFAULT_ROOT_PATH # TODO: mariano: fix this with new consensus bt = BlockTools(root_path=DEFAULT_ROOT_PATH) new_genesis_block = bt.create_genesis_block(test_constants, b"0") print(bytes(new_genesis_block))