Skip to content

Commit

Permalink
tweak datalayer test consistency (#19325)
Browse files Browse the repository at this point in the history
avoid depending on the order of the rpc call response
  • Loading branch information
altendky authored Feb 26, 2025
1 parent c09d63c commit 8611f3c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion chia/_tests/core/data_layer/test_data_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,20 +418,26 @@ async def test_keys_values_ancestors(
assert res is not None
store_id = bytes32.from_hexstr(res["id"])
await farm_block_check_singleton(data_layer, full_node_api, ph, store_id, wallet=wallet_rpc_api.service)
reference_hashes = []
key1 = b"a"
value1 = b"\x01\x02"
reference_hashes.append(leaf_hash(key=key1, value=value1))
changelist: list[dict[str, str]] = [{"action": "insert", "key": key1.hex(), "value": value1.hex()}]
key2 = b"b"
value2 = b"\x03\x02"
reference_hashes.append(leaf_hash(key=key2, value=value2))
changelist.append({"action": "insert", "key": key2.hex(), "value": value2.hex()})
key3 = b"c"
value3 = b"\x04\x05"
reference_hashes.append(leaf_hash(key=key3, value=value3))
changelist.append({"action": "insert", "key": key3.hex(), "value": value3.hex()})
key4 = b"d"
value4 = b"\x06\x03"
reference_hashes.append(leaf_hash(key=key4, value=value4))
changelist.append({"action": "insert", "key": key4.hex(), "value": value4.hex()})
key5 = b"e"
value5 = b"\x07\x01"
reference_hashes.append(leaf_hash(key=key5, value=value5))
changelist.append({"action": "insert", "key": key5.hex(), "value": value5.hex()})
res = await data_rpc_api.batch_update({"id": store_id.hex(), "changelist": changelist})
update_tx_rec0 = res["tx_id"]
Expand All @@ -449,7 +455,7 @@ async def test_keys_values_ancestors(
assert len(keys["keys"]) == len(dic)
for key in keys["keys"]:
assert key in dic
val = await data_rpc_api.get_ancestors({"id": store_id.hex(), "hash": val["keys_values"][4]["hash"]})
val = await data_rpc_api.get_ancestors({"id": store_id.hex(), "hash": reference_hashes[4].hex()})
# todo better assertions for get_ancestors result
assert len(val["ancestors"]) == 1
res_before = await data_rpc_api.get_root({"id": store_id.hex()})
Expand Down

0 comments on commit 8611f3c

Please sign in to comment.