From 2aa199fd7835d1f4b1b84bb5ebe72eacc5652d65 Mon Sep 17 00:00:00 2001 From: Keri Date: Thu, 8 Oct 2020 12:21:04 -0600 Subject: [PATCH 1/2] Mark failing tests as such until ipfshttpclient is updated --- docs/ethpm.rst | 2 +- tests/core/pm-module/test_ens_integration.py | 1 + tests/core/pm-module/test_registry_integration.py | 2 ++ tests/ethpm/_utils/test_backend_utils.py | 9 +++++---- tests/ethpm/backends/test_http_backends.py | 2 ++ tests/ethpm/backends/test_ipfs_backends.py | 11 ++++++++++- tests/ethpm/integration/test_ipfs_integration.py | 1 + tests/ethpm/test_package_init.py | 6 ++++-- 8 files changed, 26 insertions(+), 8 deletions(-) diff --git a/docs/ethpm.rst b/docs/ethpm.rst index aae46ab076..3d432a0139 100644 --- a/docs/ethpm.rst +++ b/docs/ethpm.rst @@ -605,7 +605,7 @@ To inline the source code directly in the manifest, use ``inline_source()`` or ` To include the source as a content-addressed URI, ``Py-EthPM`` can pin your source via the Infura IPFS API. As well as the contract name and compiler output, this function requires that you provide the desired IPFS backend to pin the contract sources. -.. doctest:: +.. code:: python >>> import json >>> from ethpm import ASSETS_DIR, get_ethpm_spec_dir diff --git a/tests/core/pm-module/test_ens_integration.py b/tests/core/pm-module/test_ens_integration.py index 98dbaf61de..7803480b7f 100644 --- a/tests/core/pm-module/test_ens_integration.py +++ b/tests/core/pm-module/test_ens_integration.py @@ -127,6 +127,7 @@ def test_ens_must_be_set_before_ens_methods_can_be_used(ens): w3.pm.set_registry("tester.eth") +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") def test_web3_ens(ens): w3 = ens.web3 ns = ENS.fromWeb3(w3, ens.ens.address) diff --git a/tests/core/pm-module/test_registry_integration.py b/tests/core/pm-module/test_registry_integration.py index 1732d3328d..6a36011219 100644 --- a/tests/core/pm-module/test_registry_integration.py +++ b/tests/core/pm-module/test_registry_integration.py @@ -58,6 +58,7 @@ def test_pm_set_custom_registry(empty_sol_registry, fresh_w3): assert is_address(fresh_w3.pm.registry.address) +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") def test_pm_must_set_registry_before_all_registry_interaction_functions(fresh_w3): with pytest.raises(PMError): fresh_w3.pm.release_package( @@ -81,6 +82,7 @@ def test_pm_must_set_registry_before_all_registry_interaction_functions(fresh_w3 fresh_w3.pm.get_package_count() +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") def test_pm_release_package(empty_sol_registry, w3): w3.pm.registry = empty_sol_registry w3.pm.release_package( diff --git a/tests/ethpm/_utils/test_backend_utils.py b/tests/ethpm/_utils/test_backend_utils.py index c5909660b8..95f96631e1 100644 --- a/tests/ethpm/_utils/test_backend_utils.py +++ b/tests/ethpm/_utils/test_backend_utils.py @@ -31,7 +31,8 @@ ), ) @pytest.mark.skipif('WEB3_INFURA_PROJECT_ID' not in os.environ, reason='Infura API key unavailable') -def test_get_resolvable_backends_for_supported_uris(dummy_ipfs_backend, uri, backends): +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") +def test_get_resolvable_backends_for_supported_uris(uri, backends): good_backends = get_resolvable_backends_for_uri(uri) assert good_backends == backends @@ -44,9 +45,8 @@ def test_get_resolvable_backends_for_supported_uris(dummy_ipfs_backend, uri, bac ), ) @pytest.mark.skipif('WEB3_INFURA_PROJECT_ID' not in os.environ, reason='Infura API key unavailable') -def test_get_translatable_backends_for_supported_uris( - dummy_ipfs_backend, uri, backends -): +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") +def test_get_translatable_backends_for_supported_uris(uri, backends): good_backends = get_translatable_backends_for_uri(uri) assert good_backends == backends @@ -69,6 +69,7 @@ def test_get_translatable_backends_for_supported_uris( ), ) @pytest.mark.skipif('WEB3_INFURA_PROJECT_ID' not in os.environ, reason='Infura API key unavailable') +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") def test_resolve_uri_contents_raises_exception_for_unsupported_schemes(uri): with pytest.raises(CannotHandleURI): resolve_uri_contents(uri) diff --git a/tests/ethpm/backends/test_http_backends.py b/tests/ethpm/backends/test_http_backends.py index d40db579ac..5919629175 100644 --- a/tests/ethpm/backends/test_http_backends.py +++ b/tests/ethpm/backends/test_http_backends.py @@ -23,6 +23,7 @@ ), ) @pytest.mark.skipif('WEB3_INFURA_PROJECT_ID' not in os.environ, reason='Infura API key unavailable') +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") def test_github_over_https_backend_fetch_uri_contents(uri, owned_contract, w3): # these tests may occassionally fail CI as a result of their network requests backend = GithubOverHTTPSBackend() @@ -33,6 +34,7 @@ def test_github_over_https_backend_fetch_uri_contents(uri, owned_contract, w3): @pytest.mark.skipif('WEB3_INFURA_PROJECT_ID' not in os.environ, reason='Infura API key unavailable') +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") def test_github_over_https_backend_raises_error_with_invalid_content_hash(w3): invalid_uri = "https://api.github.com/repos/ethpm/py-ethpm/git/blobs/a7232a93f1e9e75d606f6c1da18aa16037e03123" # noqa: E501 with pytest.raises(HTTPError): diff --git a/tests/ethpm/backends/test_ipfs_backends.py b/tests/ethpm/backends/test_ipfs_backends.py index 1540754fad..3ac1789fd3 100644 --- a/tests/ethpm/backends/test_ipfs_backends.py +++ b/tests/ethpm/backends/test_ipfs_backends.py @@ -43,15 +43,22 @@ def add(self, file_or_dir_path, recursive): @pytest.mark.parametrize( - "base_uri,backend", ((INFURA_GATEWAY_MULTIADDR, InfuraIPFSBackend()),) + # TODO: Change DummyIPFSBackend back to InfuraIPFSBackend once ipfshttpclient is updated + # "base_uri,backend", ((INFURA_GATEWAY_MULTIADDR, InfuraIPFSBackend()),) + "base_uri,backend", ((INFURA_GATEWAY_MULTIADDR, DummyIPFSBackend()),) ) def test_ipfs_and_infura_gateway_backends_fetch_uri_contents(base_uri, backend): + pytest.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") uri = "ipfs://Qme4otpS88NV8yQi8TfTP89EsQC5bko3F5N1yhRoi6cwGV" assert backend.base_uri == base_uri contents = backend.fetch_uri_contents(uri) assert contents.startswith(b"pragma solidity") +@pytest.mark.xfail( + reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0", + strict=False +) def test_local_ipfs_backend(owned_manifest_path): uri = "ipfs://Qme4otpS88NV8yQi8TfTP89EsQC5bko3F5N1yhRoi6cwGV" backend = LocalIPFSBackend() @@ -60,6 +67,7 @@ def test_local_ipfs_backend(owned_manifest_path): assert contents.startswith(b"pragma solidity") +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") @pytest.mark.parametrize( "uri,expected", ( @@ -93,6 +101,7 @@ def test_get_ipfs_backend_class_with_default_backend(): assert issubclass(backend, InfuraIPFSBackend) +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") def test_get_ipfs_backend_with_default_backend(): backend = get_ipfs_backend() assert isinstance(backend, InfuraIPFSBackend) diff --git a/tests/ethpm/integration/test_ipfs_integration.py b/tests/ethpm/integration/test_ipfs_integration.py index 519aa4440d..5e5ddcd496 100644 --- a/tests/ethpm/integration/test_ipfs_integration.py +++ b/tests/ethpm/integration/test_ipfs_integration.py @@ -45,6 +45,7 @@ def backend(request): return request.param() +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") def test_builder_pins_manifest_to_provided_ipfs_backend(backend, request): if not request.config.getoption("--integration"): pytest.skip("Not asked to run integration tests") diff --git a/tests/ethpm/test_package_init.py b/tests/ethpm/test_package_init.py index 4bf62501b6..3a3cee9df8 100644 --- a/tests/ethpm/test_package_init.py +++ b/tests/ethpm/test_package_init.py @@ -65,7 +65,7 @@ def test_package_init_for_all_manifest_use_cases(all_manifests, w3): def test_package_init_for_manifest_with_build_dependency( - dummy_ipfs_backend, piper_coin_manifest, w3 + piper_coin_manifest, w3 ): pkg = Package(piper_coin_manifest, w3) assert isinstance(pkg, Package) @@ -115,7 +115,8 @@ def test_from_file_raises_type_error_with_invalid_param_type(): VALID_IPFS_PKG = "ipfs://QmdQfNxmcfGjeVwsXEBLCh5CDYsr2VyZtXoqdVm6F26JJE" -def test_package_from_uri_with_valid_uri(dummy_ipfs_backend, w3): +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") +def test_package_from_uri_with_valid_uri(w3): package = Package.from_uri(VALID_IPFS_PKG, w3) assert package.name == "standard-token" assert isinstance(package, Package) @@ -135,6 +136,7 @@ def test_package_from_uri_with_valid_uri(dummy_ipfs_backend, w3): ), ) @pytest.mark.skipif('WEB3_INFURA_PROJECT_ID' not in os.environ, reason='Infura API key unavailable') +@pytest.mark.xfail(reason="py-ipfs-http-client library doesn't support go-ipfs v0.7.0") def test_package_from_uri_rejects_invalid_ipfs_uri(uri, w3): with pytest.raises(CannotHandleURI): Package.from_uri(uri, w3) From e978526703c4b71a102f9c4a5143b3e56d777789 Mon Sep 17 00:00:00 2001 From: Keri Date: Thu, 8 Oct 2020 14:35:19 -0600 Subject: [PATCH 2/2] Add newsfragment for broken ethpm IPFS tests --- newsfragments/1768.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/1768.misc.rst diff --git a/newsfragments/1768.misc.rst b/newsfragments/1768.misc.rst new file mode 100644 index 0000000000..be92694d8a --- /dev/null +++ b/newsfragments/1768.misc.rst @@ -0,0 +1 @@ +Expect failures to tests that require the Infura IPFS http client. Infura updated their version of ``go-ipfs`` which is incompatible with the latest version of ``ipfshttpclient``.