Skip to content

Commit 1308e8d

Browse files
committed
Fix deserialization test, add iterable case
1 parent 45c646b commit 1308e8d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pycardano/plutus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ def from_primitive(cls: Type[RawPlutusData], value: CBORTag) -> RawPlutusData:
693693
return cls(value)
694694

695695

696-
Datum = Union[PlutusData, dict, IndefiniteList, int, bytes, RawCBOR, RawPlutusData]
696+
Datum = Union[PlutusData, dict, int, bytes, IndefiniteList, RawCBOR, RawPlutusData]
697697
"""Plutus Datum type. A Union type that contains all valid datum types."""
698698

699699

test/pycardano/test_serialization.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import cbor2
12
from dataclasses import dataclass, field
23

3-
from pycardano import Datum
4+
from pycardano import Datum, RawPlutusData
45
from test.pycardano.util import check_two_way_cbor
56
from typing import Any, Dict, List, Optional, Set, Tuple, Union
67

@@ -181,7 +182,13 @@ def test_datum_type():
181182
class Test1(MapCBORSerializable):
182183
b: Datum
183184

184-
t = Test1(b=1)
185+
# make sure that no "not iterable" error is thrown
186+
t = Test1(b=RawPlutusData(cbor2.CBORTag(125, [])))
187+
188+
check_two_way_cbor(t)
189+
190+
# Make sure that iterable objects are not deserialized to the wrong object
191+
t = Test1(b=b"hello!")
185192

186193
check_two_way_cbor(t)
187194

0 commit comments

Comments
 (0)