コード例 #1
0
def test_type_con_name():
    a = PackageRef(
        "deadbeef00000000000000000000000000000000000000000000000000000000")
    con1 = TypeConName(module=ModuleRef(a, DottedName(["Some", "Module"])),
                       name=["Iou"])
    con2 = TypeConName(module=ModuleRef(a, DottedName(["Some", "Module"])),
                       name=["Iou"])
    assert con1 == con2
    assert hash(con1) == hash(con2)
コード例 #2
0
def test_render_update_of_contract_type_con():
    module_ref = ModuleRef(
        package_id=PackageRef("00000000000000000000000000000000"),
        module_name=DottedName(("ABC", )))
    name = TypeConName(module=module_ref, name=("DefGhi", ))
    type_ = daml.Update(daml.ContractId(daml.con(name)))

    expected = "Update (ContractId ABC:DefGhi)"
    actual = str(type_)

    assert expected == actual
コード例 #3
0
def test_render_update_of_contract_type_con_old():
    from dazl.model.types import ContractIdType, UpdateType, ModuleRef, TypeReference

    module_ref = ModuleRef(
        package_id=PackageRef('00000000000000000000000000000000'),
        module_name=DottedName(('ABC', )))
    type_ref = TypeReference(
        con=TypeConName(module=module_ref, name=('DefGhi', )))
    type_ = UpdateType(ContractIdType(type_ref))

    expected = 'Update (ContractId ABC:DefGhi)'
    actual = str(type_)

    assert expected == actual
コード例 #4
0
def test_render_update_of_contract_type_con_new():
    from dazl.damlast.daml_lf_1 import PrimType, Type
    from dazl.model.types import ModuleRef, TypeReference

    module_ref = ModuleRef(
        package_id=PackageRef('00000000000000000000000000000000'),
        module_name=DottedName(('ABC', )))
    con_type = Type(con=Type.Con(
        tycon=TypeConName(module=module_ref, name=('DefGhi', )), args=()))
    cid_type = Type(
        prim=Type.Prim(prim=PrimType.CONTRACT_ID, args=(con_type, )))
    type_ = Type(prim=Type.Prim(prim=PrimType.UPDATE, args=(cid_type, )))

    expected = 'Update (ContractId ABC:DefGhi)'
    actual = str(type_)

    assert expected == actual
コード例 #5
0
# Copyright (c) 2017-2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

from asyncio import Event, ensure_future, get_event_loop, sleep
from typing import AbstractSet

from dazl.damlast import DarFile
from dazl.damlast.daml_lf_1 import PackageRef
from dazl.damlast.lookup import MultiPackageLookup
from dazl.ledger.aio import PackageLoader
import pytest

from .dars import AllKindsOf

ALL_KINDS_OF_PKG_REF = PackageRef(
    "e32da8a173e9667e1cd6557a12bf3edbbb6e5a9eb017c3363280ba0b22100bc4")


def load_some_bytes():
    with DarFile(AllKindsOf) as dar:
        # noinspection PyProtectedMember
        for a in dar._pb_archives():
            return a.hash, a.payload
    raise Exception()


@pytest.mark.asyncio
async def test_pkg_loader_only_fetches_once(executor):
    pkg_ref, contents = load_some_bytes()

    class MockPackageService: