gameeconomy-forge-verifiabl.../tests/test_dsl.py

27 lines
822 B
Python

import json
from gameeconomy_forge_verifiable_dsl_driven_ import parse_dsl, compile_flow, attest_flow
def test_parse_compile_attest_flow():
dsl_json = json.dumps({
"assets": {
"gold": {"type": "currency", "initial": 1000},
"sword": {"type": "item", "initial": 5},
},
"constraints": [
{"type": "budget_cap", "asset": "gold", "cap": 100000}
],
})
model = parse_dsl(dsl_json)
flow = compile_flow(model)
asserted = attest_flow(flow, secret="test-secret")
assert "flow" in asserted
assert "proofs" in asserted
assert isinstance(asserted["flow"], list)
assert len(asserted["flow"]) == len(asserted["proofs"])
# The first step should initialize assets
assert asserted["flow"][0]["action"] == "initialize_assets"