Exemplo n.º 1
0
def test_builder_with_source_inliner(owned_package, monkeypatch):
    root, _, compiler_output = owned_package

    monkeypatch.chdir(root)
    inliner = source_inliner(compiler_output)
    manifest = build(BASE_MANIFEST, inliner("Owned"), validate())

    expected = assoc(
        BASE_MANIFEST,
        "sources",
        {
            "./Owned.sol":
            """pragma solidity ^0.4.24;\n\ncontract Owned {\n    address"""
            """ owner;\n    \n    modifier onlyOwner { require(msg.sender == owner); _; }\n\n    """
            """constructor() public {\n        owner = msg.sender;\n    }\n}"""
        },
    )
    assert manifest == expected
Exemplo n.º 2
0
def test_builder_with_source_inliner(owned_package, monkeypatch):
    root, _, compiler_output = owned_package

    monkeypatch.chdir(root)
    inliner = source_inliner(compiler_output)
    manifest = build(BASE_MANIFEST, inliner("Owned"), validate())
    expected = assoc(
        BASE_MANIFEST,
        "sources",
        {
            "./Owned.sol": {
                "content": OWNED_CONTRACT,
                "installPath": "./Owned.sol",
                "type": "solidity",
            }
        },
    )
    assert manifest == expected
Exemplo n.º 3
0
def test_builder_with_link_references(registry_package, dummy_ipfs_backend,
                                      monkeypatch):
    root, expected_manifest, compiler_output = registry_package
    monkeypatch.chdir(root)
    inliner = source_inliner(compiler_output)
    manifest = build(
        {},
        package_name("solidity-registry"),
        manifest_version("2"),
        version("2.0.0"),
        inliner("Authorized"),
        inliner("IndexedOrderedSetLib"),
        inliner("PackageDB"),
        inliner("PackageRegistry"),
        inliner("PackageRegistryInterface"),
        inliner("ReleaseDB"),
        inliner("ReleaseValidator"),
        contract_type(
            "AuthorityInterface",
            compiler_output,
            abi=True,
            deployment_bytecode=True,
            runtime_bytecode=True,
            natspec=True,
        ),
        contract_type(
            "Authorized",
            compiler_output,
            abi=True,
            deployment_bytecode=True,
            runtime_bytecode=True,
            natspec=True,
            compiler=True,
        ),
        contract_type(
            "AuthorizedInterface",
            compiler_output,
            abi=True,
            deployment_bytecode=True,
            runtime_bytecode=True,
            natspec=True,
        ),
        contract_type(
            "WhitelistAuthority",
            compiler_output,
            abi=True,
            deployment_bytecode=True,
            runtime_bytecode=True,
            natspec=True,
            compiler=True,
        ),
        contract_type(
            "WhitelistAuthorityInterface",
            compiler_output,
            abi=True,
            deployment_bytecode=True,
            runtime_bytecode=True,
            natspec=True,
        ),
        contract_type(
            "IndexedOrderedSetLib",
            compiler_output,
            abi=True,
            deployment_bytecode=True,
            runtime_bytecode=True,
            natspec=True,
            compiler=True,
        ),
        contract_type(
            "PackageDB",
            compiler_output,
            abi=True,
            deployment_bytecode=True,
            runtime_bytecode=True,
            natspec=True,
            compiler=True,
        ),
        contract_type(
            "PackageRegistry",
            compiler_output,
            abi=True,
            deployment_bytecode=True,
            runtime_bytecode=True,
            natspec=True,
            compiler=True,
        ),
        contract_type(
            "PackageRegistryInterface",
            compiler_output,
            abi=True,
            deployment_bytecode=True,
            runtime_bytecode=True,
            natspec=True,
        ),
        contract_type(
            "ReleaseDB",
            compiler_output,
            abi=True,
            deployment_bytecode=True,
            runtime_bytecode=True,
            natspec=True,
            compiler=True,
        ),
        contract_type(
            "ReleaseValidator",
            compiler_output,
            abi=True,
            deployment_bytecode=True,
            runtime_bytecode=True,
            natspec=True,
            compiler=True,
        ),
        validate(),
    )
    assert manifest == expected_manifest