mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-09-28 01:56:38 -04:00
remove some not-yet used fixtures
This commit is contained in:
@@ -22,7 +22,6 @@ from tests.core.data_layer.util import (
|
||||
add_0123_example,
|
||||
add_01234567_example,
|
||||
ChiaRoot,
|
||||
create_valid_node_values,
|
||||
Example,
|
||||
)
|
||||
|
||||
@@ -120,21 +119,3 @@ async def data_store_fixture(raw_data_store: DataStore, tree_id: bytes32) -> Asy
|
||||
await raw_data_store.check()
|
||||
yield raw_data_store
|
||||
await raw_data_store.check()
|
||||
|
||||
|
||||
@pytest.fixture(name="node_type", params=NodeType)
|
||||
def node_type_fixture(request: SubRequest) -> NodeType:
|
||||
return request.param # type: ignore[no-any-return]
|
||||
|
||||
|
||||
@pytest.fixture(name="valid_node_values")
|
||||
async def valid_node_values_fixture(
|
||||
data_store: DataStore,
|
||||
tree_id: bytes32,
|
||||
node_type: NodeType,
|
||||
) -> Dict[str, Any]:
|
||||
await add_01234567_example(data_store=data_store, tree_id=tree_id)
|
||||
node_a = await data_store.get_node_by_key(key=b"\x02", tree_id=tree_id)
|
||||
node_b = await data_store.get_node_by_key(key=b"\x04", tree_id=tree_id)
|
||||
|
||||
return create_valid_node_values(node_type=node_type, left_hash=node_a.hash, right_hash=node_b.hash)
|
||||
|
||||
@@ -28,18 +28,6 @@ log = logging.getLogger(__name__)
|
||||
pytestmark = pytest.mark.data_layer
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_valid_node_values_fixture_are_valid(data_store: DataStore, valid_node_values: Dict[str, Any]) -> None:
|
||||
async with data_store.db_wrapper.locked_transaction():
|
||||
await data_store.db.execute(
|
||||
"""
|
||||
INSERT INTO node(hash, node_type, left, right, key, value)
|
||||
VALUES(:hash, :node_type, :left, :right, :key, :value)
|
||||
""",
|
||||
valid_node_values,
|
||||
)
|
||||
|
||||
|
||||
table_columns: Dict[str, List[str]] = {
|
||||
"node": ["hash", "node_type", "left", "right", "key", "value"],
|
||||
"root": ["tree_id", "generation", "node_hash", "status"],
|
||||
|
||||
@@ -173,32 +173,3 @@ class ChiaRoot:
|
||||
yield
|
||||
finally:
|
||||
self.print_log()
|
||||
|
||||
|
||||
def create_valid_node_values(
|
||||
node_type: NodeType,
|
||||
left_hash: Optional[bytes32] = None,
|
||||
right_hash: Optional[bytes32] = None,
|
||||
) -> Dict[str, Any]:
|
||||
if node_type == NodeType.INTERNAL:
|
||||
return {
|
||||
"hash": Program.to((left_hash, right_hash)).get_tree_hash(left_hash, right_hash).hex(),
|
||||
"node_type": node_type,
|
||||
"left": None if left_hash is None else left_hash.hex(),
|
||||
"right": None if right_hash is None else right_hash.hex(),
|
||||
"key": None,
|
||||
"value": None,
|
||||
}
|
||||
elif node_type == NodeType.TERMINAL:
|
||||
key = b""
|
||||
value = b""
|
||||
return {
|
||||
"hash": Program.to((key, value)).get_tree_hash().hex(),
|
||||
"node_type": node_type,
|
||||
"left": None,
|
||||
"right": None,
|
||||
"key": key.hex(),
|
||||
"value": value.hex(),
|
||||
}
|
||||
|
||||
raise Exception(f"Unhandled node type: {node_type!r}")
|
||||
|
||||
Reference in New Issue
Block a user