|
| 1 | +import copy |
1 | 2 | import unittest
|
2 | 3 | from dataclasses import dataclass
|
3 | 4 | from test.pycardano.util import check_two_way_cbor
|
4 | 5 | from typing import Dict, List, Union
|
5 | 6 |
|
6 | 7 | import pytest
|
| 8 | +from cbor2 import CBORTag |
7 | 9 |
|
8 | 10 | from pycardano.exception import DeserializeException, SerializeException
|
9 | 11 | from pycardano.plutus import (
|
@@ -284,3 +286,33 @@ def test_raw_plutus_data():
|
284 | 286 | raw_plutus_data = RawPlutusData.from_cbor(raw_plutus_cbor)
|
285 | 287 | assert raw_plutus_data.to_cbor() == raw_plutus_cbor
|
286 | 288 | check_two_way_cbor(raw_plutus_data)
|
| 289 | + |
| 290 | + |
| 291 | +def test_clone_raw_plutus_data(): |
| 292 | + tag = RawPlutusData(CBORTag(121, [1000])) |
| 293 | + |
| 294 | + cloned_tag = copy.deepcopy(tag) |
| 295 | + assert cloned_tag == tag |
| 296 | + assert cloned_tag.to_cbor() == tag.to_cbor() |
| 297 | + |
| 298 | + tag.data.value = [1001] |
| 299 | + |
| 300 | + assert cloned_tag != tag |
| 301 | + |
| 302 | + |
| 303 | +def test_clone_plutus_data(): |
| 304 | + key_hash = bytes.fromhex("c2ff616e11299d9094ce0a7eb5b7284b705147a822f4ffbd471f971a") |
| 305 | + deadline = 1643235300000 |
| 306 | + testa = BigTest(MyTest(123, b"1234", IndefiniteList([4, 5, 6]), {1: b"1", 2: b"2"})) |
| 307 | + testb = LargestTest() |
| 308 | + my_vesting = VestingParam( |
| 309 | + beneficiary=key_hash, deadline=deadline, testa=testa, testb=testb |
| 310 | + ) |
| 311 | + |
| 312 | + cloned_vesting = copy.deepcopy(my_vesting) |
| 313 | + assert cloned_vesting == my_vesting |
| 314 | + assert cloned_vesting.to_cbor() == my_vesting.to_cbor() |
| 315 | + |
| 316 | + my_vesting.deadline = 1643235300001 |
| 317 | + |
| 318 | + assert cloned_vesting != my_vesting |
0 commit comments