Skip to content

Commit

Permalink
Add golden case/constr test
Browse files Browse the repository at this point in the history
  • Loading branch information
nielstron committed Jan 2, 2025
1 parent 84ed868 commit 4eebe5b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/case_constr/case_constr.flat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4e0101009800600290003003480081
4 changes: 4 additions & 0 deletions tests/case_constr/case_constr.uplc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(program
1.1.0
(case (constr 0)(constr 0(con integer 0))(constr 1(con integer 1)))
)
11 changes: 11 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1752,3 +1752,14 @@ def test_append_plutusdata_list(self):
r.result,
PlutusConstr(0, []),
)

def test_case_constr_encoding(self):
with open(Path(__file__).parent / "case_constr" / "case_constr.uplc", "r") as f:
program = f.read()
p = parse(program)
encoded = flatten(p)
with open(Path(__file__).parent / "case_constr" / "case_constr.flat", "r") as f:
encoded_ref = bytes.fromhex(f.read())
self.assertEqual(encoded, encoded_ref)
decoded = unflatten(encoded_ref)
self.assertEqual(p, decoded)

0 comments on commit 4eebe5b

Please sign in to comment.