File tree 2 files changed +16
-3
lines changed
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 19
19
)
20
20
from pycardano .hash import VERIFICATION_KEY_HASH_SIZE , ScriptHash , VerificationKeyHash
21
21
from pycardano .network import Network
22
- from pycardano .serialization import CBORSerializable
22
+ from pycardano .serialization import CBORSerializable , Primitive
23
23
24
24
__all__ = ["AddressType" , "PointerAddress" , "Address" ]
25
25
@@ -160,7 +160,11 @@ def to_primitive(self) -> bytes:
160
160
return self .encode ()
161
161
162
162
@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
+ )
164
168
return cls .decode (value )
165
169
166
170
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
2
5
from pycardano .key import PaymentVerificationKey
3
6
from pycardano .network import Network
4
7
@@ -15,3 +18,9 @@ def test_payment_addr():
15
18
Address (vk .hash (), network = Network .TESTNET ).encode ()
16
19
== "addr_test1vr2p8st5t5cxqglyjky7vk98k7jtfhdpvhl4e97cezuhn0cqcexl7"
17
20
)
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