Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@ jobs:
# Fail if poetry.lock is stale vs pyproject.toml; install what is committed.
- run: poetry check --lock
- run: poetry install
# No pytest suite yet; import-smoke the built package so CI fails fast
# on broken codegen/spec dependencies.
- run: poetry run python -c "import utxorpc"
- run: poetry run pytest
111 changes: 109 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protobuf = "^7.34.1"
[tool.poetry.group.dev.dependencies]
mypy = "^1.18.2"
ruff = "^0.14.3"
pytest = "^8.4"

[[tool.poetry.source]]
name = "pypi"
29 changes: 29 additions & 0 deletions tests/test_cardano_vectors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Decodes the Cardano vectors with the spec's generated types."""

import csv
from pathlib import Path

import pytest
from utxorpc_spec.utxorpc.v1alpha.cardano import cardano_pb2 as v1alpha
from utxorpc_spec.utxorpc.v1beta.cardano import cardano_pb2 as v1beta

VECTORS = Path(__file__).parent / "vectors" / "cardano"

with open(VECTORS / "vectors.tsv", newline="") as index:
ROWS = list(csv.DictReader(index, delimiter="\t"))


@pytest.mark.parametrize("row", ROWS, ids=[row["name"] for row in ROWS])
@pytest.mark.parametrize("version,module", [("v1alpha", v1alpha), ("v1beta", v1beta)])
def test_decodes_vector(version, module, row):
raw = (VECTORS / version / f"{row['name']}.pb").read_bytes()

block = module.Block()
block.ParseFromString(raw)

assert block.header.slot == int(row["slot"])
assert block.header.hash.hex() == row["hash"]
assert len(block.body.tx) == int(row["tx_count"])
if row["first_tx_hash"] != "-":
assert block.body.tx[0].hash.hex() == row["first_tx_hash"]
assert block.SerializeToString(deterministic=True) == raw
4 changes: 4 additions & 0 deletions tests/vectors/cardano/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Cardano vectors

Copied from [`conformance/vectors/cardano`](https://github.com/utxorpc/u5c-factory/tree/main/conformance/vectors/cardano)
in u5c-factory, where the blocks, their sources and the generator live. Don't edit by hand.
Binary file added tests/vectors/cardano/v1alpha/babbage-v7.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1alpha/babbage-v8.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1alpha/conway-v10.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1alpha/conway-v11.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1alpha/conway-v12.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1alpha/conway-v9.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1alpha/dijkstra-v12.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1beta/babbage-v7.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1beta/babbage-v8.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1beta/conway-v10.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1beta/conway-v11.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1beta/conway-v12.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1beta/conway-v9.pb
Binary file not shown.
Binary file added tests/vectors/cardano/v1beta/dijkstra-v12.pb
Binary file not shown.
8 changes: 8 additions & 0 deletions tests/vectors/cardano/vectors.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name era protocol slot hash tx_count first_tx_hash
babbage-v7 Babbage 7 1029948 0ee46e356d778433273365b895b1aea1a81f33db4cc80e05b6ffca33e0f8b83b 1 3fad302595665b004971a6b76909854a39a0a7ecdbff3692f37b77ae37dbe882
babbage-v8 Babbage 8 1363368 16202fe98de909fda9156919633459ed2368bb2db28393c934acf36e52f2f66b 4 05337a1c2ce0e1d6714eb1dd993c733c50436682a3079e9ef0939f3d6819e3ba
conway-v10 Conway 10 31412056 1240f59bd88d16f4f6e425ae60935926985478965e37b73b5b85276625bcbe82 1 ea3d309d4ef836cf0aea7e2b5f70537ca82e647754958ff191d5162b55036838
conway-v11 Conway 11 202315107 d03a37835e9f1ffb70e8a476334c69183ab5491c911faa7ea0d6ba285dd7c8b4 4 cec3db3a981bde28ca7396ee4611686f701184394a9ff3810adb51f1346a6415
conway-v12 Conway 12 86373 802112126cc600a6afc5193a0150aafd9f6563bec28207df7e6c20cc62e95f8e 0 -
conway-v9 Conway 9 22075282 9b51ccd4f161c08382a445684ff3eb788923608acbea283081fa5ccf663fef8d 1 ed8431dbe32cff36814ee838a7a002152d43a7465faaf05529907717c793527a
dijkstra-v12 Dijkstra 12 285530 294b3df1e6758e6f17f2b5a09ed469c6ec37c2db4d274264c8ee5edabe31229a 1 5bff1759d143172c5fd1fddc9910f1a7a1ea2c1666f0d1f0299371f9fa889b7c
Loading