Пример #1
0
def test_check_token(web3_instance):
    ocn_auth = OceanAuth(':memory:')
    wallet = get_publisher_wallet()

    token = ocn_auth.get(wallet)
    address = ocn_auth.check(token)
    assert address != '0x0', 'Verifying token failed.'

    sig = token.split('-')[0]
    assert ocn_auth.check(sig) == '0x0'
Пример #2
0
def test_check_token(web3_instance):
    ocn_auth = OceanAuth(":memory:")
    wallet = get_publisher_wallet()

    token = ocn_auth.get(wallet)
    address = ocn_auth.check(token)
    assert address != "0x0", "Verifying token failed."

    sig = token.split("-")[0]
    assert ocn_auth.check(sig) == "0x0"
Пример #3
0
def test_get_token():
    ocn_auth = OceanAuth(':memory:')
    wallet = get_publisher_wallet()
    token = ocn_auth.get(wallet)
    assert isinstance(token, str), 'Invalid auth token type.'
    assert token.startswith('0x'), 'Invalid auth token.'
    parts = token.split('-')
    assert len(parts) == 2, 'Invalid token, timestamp separator is not found.'

    address = ocn_auth.check(token)
    assert address != '0x0', 'Verifying token failed.'
Пример #4
0
def test_get_token():
    ocn_auth = OceanAuth(":memory:")
    wallet = get_publisher_wallet()
    token = ocn_auth.get(wallet)
    assert isinstance(token, str), "Invalid auth token type."
    assert token.startswith("0x"), "Invalid auth token."
    parts = token.split("-")
    assert len(parts) == 2, "Invalid token, timestamp separator is not found."

    address = ocn_auth.check(token)
    assert address != "0x0", "Verifying token failed."
Пример #5
0
def trying_algorithm_run(did, wallet, order_tx_id, nonce):
    load_dotenv(".env")
    config = Config(os.getenv('config.ini'))
    print(config.network_url)
    # config.network_url="https://rinkeby.infura.io/v3/31d95be121a545b688a0e07e4de4d256"
    ConfigProvider.set_config(config)
    ocean_auth = OceanAuth("./storage_tokens")
    token = ocean_auth.get(wallet)
    print(config.provider_url)
    ocean_compute = OceanCompute(ocean_auth, config, config.provider_url)

    job_id = ocean_compute.start(did,
                                 wallet,
                                 order_tx_id,
                                 nonce,
                                 algorithm_meta=algo_metadata)
    return job_id
Пример #6
0
def trying_compute(wallet):
    load_dotenv(".env")
    config = Config(os.getenv('config.ini'))
    print(config.network_url)
    # config.network_url="https://rinkeby.infura.io/v3/31d95be121a545b688a0e07e4de4d256"
    ConfigProvider.set_config(config)
    ocean_auth = OceanAuth("./storage_tokens")
    token = ocean_auth.get(wallet)
    # config=ConfigProvider()
    print(config.provider_url)
    ocean_compute = OceanCompute(ocean_auth, config, config.provider_url)
    build_server_attributes = OceanCompute.build_server_attributes(
        server_id="1",
        server_type="homemade",
        cpu=2,
        gpu=0,
        memory=2,
        disk=10,
        max_run_time=5000)
    compute_service_cluster_attribute = OceanCompute.build_cluster_attributes(
        cluster_type="Kubernetes", url="http://10.96.0.1/")
    compute_service_container_attributes = OceanCompute.build_container_attributes(
        image="patanae", tag="patanae", entrypoint="python")

    compute_service_provider_attributes = OceanCompute.build_service_provider_attributes(
        "forgeeks",
        description="providecompute",
        cluster=compute_service_cluster_attribute,
        containers=compute_service_container_attributes,
        servers=build_server_attributes)
    created_compute_service_attributes = OceanCompute.create_compute_service_attributes(
        creator="hello",
        provider_attributes=compute_service_provider_attributes,
        date_published="",
        timeout=20000)
    compute_service_descriptor = ocean_compute.create_compute_service_descriptor(
        created_compute_service_attributes)
Пример #7
0
def auth_ocean_token(wallet):
    ocean_auth = OceanAuth("./storage_tokens")
    token = ocean_auth.get(wallet)
    return ocean_auth