File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1919)
2020from pycardano .hash import VERIFICATION_KEY_HASH_SIZE , ScriptHash , VerificationKeyHash
2121from pycardano .network import Network
22- from pycardano .serialization import CBORSerializable
22+ from pycardano .serialization import CBORSerializable , Primitive
2323
2424__all__ = ["AddressType" , "PointerAddress" , "Address" ]
2525
@@ -160,7 +160,11 @@ def to_primitive(self) -> bytes:
160160 return self .encode ()
161161
162162 @classmethod
163- def from_primitive (cls : Type [PointerAddress ], value : bytes ) -> PointerAddress :
163+ def from_primitive (cls : Type [PointerAddress ], value : Primitive ) -> PointerAddress :
164+ if not isinstance (value , bytes ):
165+ raise DeserializeException (
166+ f"A bytes value is required for deserialization: { value } "
167+ )
164168 return cls .decode (value )
165169
166170 def __eq__ (self , other ):
Original file line number Diff line number Diff line change 1- from pycardano .address import Address
1+ from unittest import TestCase
2+
3+ from pycardano .address import Address , PointerAddress
4+ from pycardano .exception import DeserializeException
25from pycardano .key import PaymentVerificationKey
36from pycardano .network import Network
47
@@ -15,3 +18,9 @@ def test_payment_addr():
1518 Address (vk .hash (), network = Network .TESTNET ).encode ()
1619 == "addr_test1vr2p8st5t5cxqglyjky7vk98k7jtfhdpvhl4e97cezuhn0cqcexl7"
1720 )
21+
22+
23+ class PointerAddressTest (TestCase ):
24+ def test_from_primitive_invalid_value (self ):
25+ with self .assertRaises (DeserializeException ):
26+ PointerAddress .from_primitive (1 )
You can’t perform that action at this time.
0 commit comments