def test_did_resolver_library(publisher_account, aquarius): did_registry = keeper().did_registry checksum_test = Web3.sha3(text='checksum') value_test = aquarius.root_url did_resolver = DIDResolver(keeper().did_registry) sample_ddo_path = get_resource_path('ddo', 'ddo_sample1.json') assert sample_ddo_path.exists(), "{} does not exist!".format( sample_ddo_path) asset1 = DDO(json_filename=sample_ddo_path) asset1._did = DID.did({"0": "0x1098098"}) did_registry.register(asset1.asset_id, checksum_test, url=value_test, account=publisher_account) aquarius.publish_asset_ddo(asset1) did_resolved = did_resolver.resolve(asset1.did) assert did_resolved assert did_resolved.did == asset1.did with pytest.raises(ValueError): did_resolver.resolve(asset1.asset_id) aquarius.retire_asset_ddo(asset1.did)
def get_ddo_sample(datatoken_address): did = f'did:op:{remove_0x_prefix(datatoken_address)}' sample_ddo_path = get_resource_path('ddo', 'ddo_sa_sample.json') assert sample_ddo_path.exists(), "{} does not exist!".format(sample_ddo_path) asset = DDO(json_filename=sample_ddo_path) asset.metadata['main']['files'][0]['checksum'] = str(uuid.uuid4()) checksum_dict = dict() for service in asset.services: checksum_dict[str(service.index)] = checksum(service.main) asset.add_proof(checksum_dict, get_publisher_wallet()) asset._did = did return asset
def get_ddo_sample(datatoken_address): """Helper function to get a sample ddo for testing.""" did = f"did:op:{remove_0x_prefix(datatoken_address)}" sample_ddo_path = get_resource_path("ddo", "ddo_sa_sample.json") assert sample_ddo_path.exists(), "{} does not exist!".format(sample_ddo_path) asset = DDO(json_filename=sample_ddo_path) asset.metadata["main"]["files"][0]["checksum"] = str(uuid.uuid4()) checksum_dict = dict() for service in asset.services: checksum_dict[str(service.index)] = checksum(service.main) asset.add_proof(checksum_dict, get_publisher_wallet()) asset._did = did return asset