示例#1
0
    def setUp(self):
        super().setUp()

        deadline_offset = 10
        message_timestamp = get_current_utc_timestamp() + deadline_offset
        compute_task_def = message.ComputeTaskDef()
        compute_task_def['task_id'] = '8'
        compute_task_def['subtask_id'] = '8'
        compute_task_def['deadline'] = message_timestamp
        task_to_compute = tasks.TaskToComputeFactory(
            compute_task_def=compute_task_def,
            requestor_public_key=encode_hex(REQUESTOR_PUBLIC_KEY),
            provider_public_key=encode_hex(PROVIDER_PUBLIC_KEY),
            price=0,
        )
        task_to_compute = load(
            dump(
                task_to_compute,
                REQUESTOR_PRIVATE_KEY,
                settings.CONCENT_PUBLIC_KEY,
            ),
            settings.CONCENT_PRIVATE_KEY,
            REQUESTOR_PUBLIC_KEY,
            check_time=False,
        )
        report_computed_task = tasks.ReportComputedTaskFactory(
            task_to_compute=task_to_compute)
        self.force_report_computed_task = message.ForceReportComputedTask(
            report_computed_task=report_computed_task)
示例#2
0
    def setUp(self):
        super().setUp()

        deadline_offset = 10
        message_timestamp = get_current_utc_timestamp() + deadline_offset
        self.compute_task_def = ComputeTaskDefFactory()
        self.compute_task_def['deadline'] = message_timestamp
        want_to_compute_task = WantToComputeTaskFactory(
            provider_public_key=encode_hex(PROVIDER_PUBLIC_KEY), )
        want_to_compute_task = sign_message(want_to_compute_task,
                                            PROVIDER_PRIVATE_KEY)
        task_to_compute = tasks.TaskToComputeFactory(
            compute_task_def=self.compute_task_def,
            requestor_public_key=encode_hex(REQUESTOR_PUBLIC_KEY),
            requestor_ethereum_public_key=encode_hex(
                REQUESTOR_ETHERUM_PUBLIC_KEY),
            want_to_compute_task=want_to_compute_task,
            price=1,
        )
        task_to_compute.generate_ethsig(REQUESTOR_ETHEREUM_PRIVATE_KEY)
        task_to_compute.sign_all_promissory_notes(
            deposit_contract_address=settings.GNT_DEPOSIT_CONTRACT_ADDRESS,
            private_key=REQUESTOR_ETHEREUM_PRIVATE_KEY,
        )
        self.task_to_compute = load(
            dump(
                task_to_compute,
                REQUESTOR_PRIVATE_KEY,
                settings.CONCENT_PUBLIC_KEY,
            ),
            settings.CONCENT_PRIVATE_KEY,
            REQUESTOR_PUBLIC_KEY,
            check_time=False,
        )
        report_computed_task = tasks.ReportComputedTaskFactory(
            task_to_compute=self.task_to_compute)
        self.report_computed_task = load(
            dump(
                report_computed_task,
                PROVIDER_PRIVATE_KEY,
                settings.CONCENT_PUBLIC_KEY,
            ),
            settings.CONCENT_PRIVATE_KEY,
            PROVIDER_PUBLIC_KEY,
            check_time=False,
        )
        self.force_report_computed_task = message.concents.ForceReportComputedTask(
            report_computed_task=self.report_computed_task)

        self.force_get_task_result = message.concents.ForceGetTaskResult(
            report_computed_task=self.report_computed_task)
示例#3
0
 def gen_ttc_kwargs(self, prefix=''):
     kwargs = {
         'sign__privkey':
         self.requestor_priv_key,
         'requestor_public_key':
         msg_utils.encode_hex(self.requestor_pub_key, ),
         'requestor_ethereum_public_key':
         msg_utils.encode_hex(self.requestor_pub_key, ),
         'want_to_compute_task__provider_public_key':
         msg_utils.encode_hex(self.provider_pub_key),
         'want_to_compute_task__sign__privkey':
         self.provider_keys.raw_privkey
     }
     return {prefix + k: v for k, v in kwargs.items()}
示例#4
0
    def setUp(self):
        self.request_factory = RequestFactory()
        self.want_to_compute = message.WantToComputeTask(
            node_name=1,
            task_id=2,
            perf_index=3,
            price=4,
            max_resource_size=5,
            max_memory_size=6,
            num_cores=7,
        )
        self.message_to_view = {
            "node_name": self.want_to_compute.node_name,  # pylint: disable=no-member
            "task_id": self.want_to_compute.task_id,  # pylint: disable=no-member
            "perf_index": self.want_to_compute.perf_index,  # pylint: disable=no-member
            "price": self.want_to_compute.price,  # pylint: disable=no-member
            "max_resource_size": self.want_to_compute.max_resource_size,  # pylint: disable=no-member
            "max_memory_size": self.want_to_compute.max_memory_size,  # pylint: disable=no-member
            "num_cores": self.want_to_compute.num_cores,  # pylint: disable=no-member
        }
        deadline_offset = 10
        message_timestamp = get_current_utc_timestamp() + deadline_offset
        compute_task_def = tasks.ComputeTaskDefFactory(
            task_id='8',
            subtask_id='8',
            deadline=message_timestamp,
        )
        task_to_compute = tasks.TaskToComputeFactory(
            compute_task_def=compute_task_def,
            requestor_public_key=encode_hex(REQUESTOR_PUBLIC_KEY),
            provider_public_key=encode_hex(PROVIDER_PUBLIC_KEY),
            price=0,
        )
        task_to_compute = load(
            dump(
                task_to_compute,
                REQUESTOR_PRIVATE_KEY,
                settings.CONCENT_PUBLIC_KEY,
            ),
            settings.CONCENT_PRIVATE_KEY,
            REQUESTOR_PUBLIC_KEY,
            check_time=False,
        )

        self.force_report_computed_task = message.ForceReportComputedTask()
        self.force_report_computed_task.report_computed_task = message.tasks.ReportComputedTask(
        )
        self.force_report_computed_task.report_computed_task.task_to_compute = task_to_compute
示例#5
0
 def test_validate_owner_requestor(self):
     requestor_keys = cryptography.ECCx(None)
     arct = self.FACTORY(
         report_computed_task__task_to_compute__requestor_public_key=encode_hex(requestor_keys.raw_pubkey),  # noqa pylint:disable=line-too-long
         sign__privkey=requestor_keys.raw_privkey,
     )
     self.assertTrue(arct.validate_ownership())
示例#6
0
    def test_concent_disabled_wtct_concent_flag_none(self, send_mock):
        task_manager = self.task_session.task_manager
        self.msg.concent_enabled = None
        task_session = self.task_session
        task_session.concent_service.enabled = False
        task_manager = task_session.task_manager
        task_manager.check_next_subtask.return_value = True
        task_manager.is_my_task.return_value = True
        task_manager.should_wait_for_node.return_value = False
        ctd = factories.tasks.ComputeTaskDefFactory()
        task_manager.get_next_subtask.return_value = ctd

        task = mock.MagicMock()
        task_state = mock.MagicMock(package_hash='123', package_size=42)
        task.header.task_owner.key = encode_hex(self.requestor_keys.raw_pubkey)
        task_manager.tasks = {ctd['task_id']: task}
        task_manager.tasks_states = {ctd['task_id']: task_state}

        with mock.patch(
            'golem.task.tasksession.taskkeeper.compute_subtask_value',
            mock.Mock(return_value=667),
        ):
            task_session._react_to_want_to_compute_task(self.msg)

        send_mock.assert_called()
        ttc = send_mock.call_args_list[0][0][0]
        self.assertIsInstance(ttc, message.tasks.TaskToCompute)
        self.assertFalse(ttc.concent_enabled)
示例#7
0
 def test_that_if_different_requestor_ethereum_public_keys_are_given_method_should_return_false(
         self):
     self.task_to_compute_2.requestor_ethereum_public_key = encode_hex(
         DIFFERENT_REQUESTOR_PUB_ETH_KEY)
     subtask_results_accepted_list = self.create_subtask_results_accepted_list(
         self.task_to_compute_1, self.task_to_compute_2)
     result = are_keys_and_addresses_unique_in_message_subtask_results_accepted(
         subtask_results_accepted_list)
     assert_that(result).is_false()
示例#8
0
 def test_that_if_different_provider_public_keys_are_given_method_should_return_false(
         self):
     self.task_to_compute_2.provider_public_key = encode_hex(
         DIFFERENT_PROVIDER_PUBLIC_KEY)
     subtask_results_accepted_list = self.create_subtask_results_accepted_list(
         self.task_to_compute_1, self.task_to_compute_2)
     result = are_keys_and_addresses_unique_in_message_subtask_results_accepted(
         subtask_results_accepted_list)
     assert_that(result).is_false()
示例#9
0
    def setUp(self):
        super().setUp()

        deadline_offset = 10
        message_timestamp = get_current_utc_timestamp() + deadline_offset
        compute_task_def = message.ComputeTaskDef()
        compute_task_def['task_id'] = '8'
        compute_task_def['subtask_id'] = '8'
        compute_task_def['deadline'] = message_timestamp
        compute_task_def['extra_data'] = {
            'frames': [1],
            'output_format': 'PNG',
            'scene_file': 'kitten.blend',
        }
        task_to_compute = tasks.TaskToComputeFactory(
            compute_task_def=compute_task_def,
            requestor_public_key=encode_hex(REQUESTOR_PUBLIC_KEY),
            provider_public_key=encode_hex(PROVIDER_PUBLIC_KEY),
            price=0,
        )
        task_to_compute = load(
            dump(
                task_to_compute,
                REQUESTOR_PRIVATE_KEY,
                settings.CONCENT_PUBLIC_KEY,
            ),
            settings.CONCENT_PRIVATE_KEY,
            REQUESTOR_PUBLIC_KEY,
            check_time=False,
        )
        report_computed_task = tasks.ReportComputedTaskFactory(
            task_to_compute=task_to_compute)
        report_computed_task = load(
            dump(
                report_computed_task,
                PROVIDER_PRIVATE_KEY,
                settings.CONCENT_PUBLIC_KEY,
            ),
            settings.CONCENT_PRIVATE_KEY,
            PROVIDER_PUBLIC_KEY,
            check_time=False,
        )
        self.force_report_computed_task = message.ForceReportComputedTask(
            report_computed_task=report_computed_task)
示例#10
0
    def setUp(self):
        super().setUp()

        deadline_offset = 10
        message_timestamp = get_current_utc_timestamp() + deadline_offset
        self.compute_task_def = ComputeTaskDefFactory()
        self.compute_task_def['deadline'] = message_timestamp
        want_to_compute_task = WantToComputeTaskFactory(
            provider_public_key=encode_hex(PROVIDER_PUBLIC_KEY), )
        want_to_compute_task = sign_message(want_to_compute_task,
                                            PROVIDER_PRIVATE_KEY)
        task_to_compute = tasks.TaskToComputeFactory(
            compute_task_def=self.compute_task_def,
            requestor_public_key=encode_hex(REQUESTOR_PUBLIC_KEY),
            want_to_compute_task=want_to_compute_task,
            price=1,
        )
        self.task_to_compute = load(
            dump(
                task_to_compute,
                REQUESTOR_PRIVATE_KEY,
                settings.CONCENT_PUBLIC_KEY,
            ),
            settings.CONCENT_PRIVATE_KEY,
            REQUESTOR_PUBLIC_KEY,
            check_time=False,
        )
        report_computed_task = tasks.ReportComputedTaskFactory(
            task_to_compute=self.task_to_compute)
        self.report_computed_task = load(
            dump(
                report_computed_task,
                PROVIDER_PRIVATE_KEY,
                settings.CONCENT_PUBLIC_KEY,
            ),
            settings.CONCENT_PRIVATE_KEY,
            PROVIDER_PUBLIC_KEY,
            check_time=False,
        )
        self.force_report_computed_task = message.concents.ForceReportComputedTask(
            report_computed_task=self.report_computed_task)

        self.force_get_task_result = message.concents.ForceGetTaskResult(
            report_computed_task=self.report_computed_task)
示例#11
0
 def setUp(self):
     (REQUESTOR_ETHEREUM_PRIVATE_KEY,
      REQUESTOR_ETHERUM_PUBLIC_KEY) = generate_ecc_key_pair()
     self.task_to_compute = TaskToComputeFactory(
         requestor_ethereum_public_key=encode_hex(
             REQUESTOR_ETHERUM_PUBLIC_KEY))
     self.task_to_compute.generate_ethsig(REQUESTOR_ETHEREUM_PRIVATE_KEY)
     self.task_to_compute.sign_all_promissory_notes(
         deposit_contract_address=settings.GNT_DEPOSIT_CONTRACT_ADDRESS,
         private_key=REQUESTOR_ETHEREUM_PRIVATE_KEY,
     )
示例#12
0
 def get_vrct(self):
     ttc = msg_factories.tasks.TaskToComputeFactory(
         requestor_public_key=msg_utils.encode_hex(
             self.requestor_keys.raw_pubkey, ),
         sign__privkey=self.requestor_keys.raw_privkey,
         want_to_compute_task__provider_public_key=msg_utils.encode_hex(
             self.provider_keys.raw_pubkey),
         want_to_compute_task__sign__privkey=self.provider_keys.raw_privkey,
     )
     frct = msg_factories.concents.ForceReportComputedTaskFactory(
         report_computed_task__task_to_compute=ttc,
         report_computed_task__sign__privkey=self.provider_keys.raw_privkey,
         sign__privkey=self.provider_keys.raw_privkey,
     )
     msg = msg_factories.concents.VerdictReportComputedTaskFactory(
         force_report_computed_task=frct, )
     msg.ack_report_computed_task.sign_message(
         self.concent_keys.raw_privkey)
     msg.sign_message(self.concent_keys.raw_privkey)
     return msg
def test_case_2b_not_enough_funds(cluster_consts, cluster_url, test_id):
    #  Test CASE 2B - Send ForceSubtaskResults with not enough amount of funds on account
    current_time = get_current_utc_timestamp()
    (task_id, subtask_id) = get_task_id_and_subtask_id(test_id, '2B')
    api_request(
        cluster_url,
        'send',
        PROVIDER_PRIVATE_KEY,
        CONCENT_PUBLIC_KEY,
        force_subtask_results(
            timestamp=timestamp_to_isoformat(current_time),
            ack_report_computed_task=ack_report_computed_task(
                timestamp=timestamp_to_isoformat(current_time),
                report_computed_task=report_computed_task(
                    task_to_compute=create_signed_task_to_compute(
                        timestamp=calculate_timestamp(
                            current_time,
                            cluster_consts.concent_messaging_time,
                            cluster_consts.concent_upload_rate),
                        task_id=task_id,
                        subtask_id=subtask_id,
                        deadline=calculate_deadline(
                            current_time,
                            cluster_consts.concent_messaging_time,
                            cluster_consts.concent_upload_rate),
                        requestor_ethereum_public_key=encode_hex(
                            b'0' * GOLEM_PUBLIC_KEY_LENGTH),
                        provider_ethereum_public_key=encode_hex(
                            b'1' * GOLEM_PUBLIC_KEY_LENGTH),
                        price=0,
                    )))),
        headers={
            'Content-Type': 'application/octet-stream',
        },
        expected_status=200,
        expected_message_type=message.concents.ServiceRefused.TYPE,
        expected_content_type='application/octet-stream',
    )
示例#14
0
def convert_public_key_to_hex(client_key: Union[bytes, str, None]) -> str:
    if client_key is None:
        decoded_key = '-not available-'
    elif isinstance(client_key, bytes):
        decoded_key = encode_hex(client_key)
    elif isinstance(client_key, str):
        if client_key == '-not available-':
            decoded_key = client_key
        elif len(client_key) == 88:
            decoded_key = encode_hex(b64decode(client_key))
        elif len(client_key) == 128:
            decoded_key = client_key
        else:
            raise TypeError(
                f'Cannot convert client key given as string to hex. Client key: {client_key}'
            )
    else:
        raise TypeError(
            f'Unsupported type of client public key.  Client key: {client_key}.  Type of client key: {type(client_key)}'
        )

    assert len(decoded_key) == 128 or decoded_key == '-not available-'
    return decoded_key
示例#15
0
    def setUp(self):
        self.provider_private_key, self.provider_public_key = generate_ecc_key_pair(
        )
        self.deposit_contract_address = '0xcfB81A6EE3ae6aD4Ac59ddD21fB4589055c13DaD'

        want_to_compute_task = WantToComputeTaskFactory(
            provider_public_key=encode_hex(self.provider_public_key))
        arguments = {
            'subtask_results_rejected__'
            'report_computed_task__'
            'task_to_compute__'
            'want_to_compute_task':
            want_to_compute_task
        }
        self.subtask_results_verify: SubtaskResultsVerify = SubtaskResultsVerifyFactory(
            **arguments)
示例#16
0
def create_signed_task_to_compute(
    deadline: int,
    timestamp: Optional[Union[datetime.datetime, str]] = None,
    provider_public_key: Optional[bytes] = None,
    requestor_public_key: Optional[bytes] = None,
    requestor_ethereum_public_key: Optional[bytes] = None,
    requestor_ethereum_private_key: Optional[bytes] = None,
    provider_ethereum_public_key: Optional[bytes] = None,
    want_to_compute_task: Optional[WantToComputeTask] = None,
    price: int = 1,
    size: int = 1,
    package_hash: str = 'sha1:57786d92d1a6f7eaaba1c984db5e108c68b03f0d',
    script_src: Optional[str] = None,
) -> TaskToCompute:
    with freeze_time(timestamp):
        compute_task_def = ComputeTaskDefFactory(
            deadline=deadline,
            extra_data={
                'output_format': 'png',
                'scene_file': '/golem/resources/golem-header-light.blend',
                'frames': [1],
                'script_src': script_src,
            })
        if script_src is not None:
            compute_task_def['extra_data']['script_src'] = script_src
        want_to_compute_task = want_to_compute_task if want_to_compute_task is not None else WantToComputeTaskFactory(
            provider_public_key=encode_hex(provider_public_key)
            if provider_public_key is not None else
            _get_provider_hex_public_key(),
            provider_ethereum_public_key=encode_hex(
                provider_ethereum_public_key) if provider_ethereum_public_key
            is not None else encode_hex(PROVIDER_ETHEREUM_PUBLIC_KEY),
        )
        want_to_compute_task = sign_message(want_to_compute_task,
                                            PROVIDER_PRIVATE_KEY)
        task_to_compute = TaskToComputeFactory(
            requestor_public_key=encode_hex(requestor_public_key)
            if requestor_public_key is not None else
            _get_requestor_hex_public_key(),
            compute_task_def=compute_task_def,
            want_to_compute_task=want_to_compute_task,
            requestor_ethereum_public_key=encode_hex(
                requestor_ethereum_public_key) if requestor_ethereum_public_key
            is not None else encode_hex(REQUESTOR_ETHEREUM_PUBLIC_KEY),
            price=price,
            size=size,
            package_hash=package_hash,
        )
        task_to_compute.generate_ethsig(
            requestor_ethereum_private_key if requestor_ethereum_private_key
            is not None else REQUESTOR_ETHEREUM_PRIVATE_KEY)
        signed_task_to_compute: TaskToCompute = sign_message(
            task_to_compute, REQUESTOR_PRIVATE_KEY)
        return signed_task_to_compute
示例#17
0
def test_case_2_a_force_payment_with_subtask_result_accepted_where_ethereum_accounts_are_different(
        cluster_consts, cluster_url, test_id):
    # Test CASE 2A - Send ForcePayment with SubtaskResultsAccepted where ethereum accounts are different
    current_time = get_current_utc_timestamp()
    (task_id, subtask_id) = get_task_id_and_subtask_id(test_id, '2A')
    api_request(
        cluster_url,
        'send',
        PROVIDER_PRIVATE_KEY,
        CONCENT_PUBLIC_KEY,
        force_payment(
            timestamp=timestamp_to_isoformat(current_time),
            subtask_results_accepted_list=[
                subtask_results_accepted(
                    timestamp=timestamp_to_isoformat(current_time),
                    payment_ts=current_time - cluster_consts.payment_due_time -
                    AVERAGE_TIME_FOR_TWO_BLOCKS,
                    task_to_compute=create_signed_task_to_compute(
                        timestamp=parse_timestamp_to_utc_datetime(
                            current_time),
                        task_id=task_id + 'a',
                        subtask_id=subtask_id + 'A',
                        deadline=current_time,
                        price=15000,
                    )),
                subtask_results_accepted(
                    timestamp=timestamp_to_isoformat(current_time),
                    payment_ts=current_time - cluster_consts.payment_due_time -
                    AVERAGE_TIME_FOR_TWO_BLOCKS,
                    task_to_compute=create_signed_task_to_compute(
                        timestamp=parse_timestamp_to_utc_datetime(
                            current_time),
                        task_id=task_id + 'b',
                        subtask_id=subtask_id + 'B',
                        deadline=current_time,
                        price=15000,
                        requestor_ethereum_public_key=encode_hex(
                            b'0' * GOLEM_PUBLIC_KEY_LENGTH)))
            ]),
        headers={
            'Content-Type': 'application/octet-stream',
        },
        expected_status=200,
        expected_message_type=message.concents.ServiceRefused.TYPE,
        expected_content_type='application/octet-stream',
    )
示例#18
0
 def setUp(self):
     self.task_to_compute_1 = TaskToComputeFactory(
         requestor_ethereum_public_key=encode_hex(REQUESTOR_PUB_ETH_KEY),
         requestor_public_key=encode_hex(REQUESTOR_PUBLIC_KEY),
         want_to_compute_task=WantToComputeTaskFactory(
             provider_ethereum_public_key=encode_hex(PROVIDER_PUB_ETH_KEY),
             provider_public_key=encode_hex(PROVIDER_PUBLIC_KEY),
         ),
     )
     self.task_to_compute_1.generate_ethsig(REQUESTOR_PRIV_ETH_KEY)
     self.task_to_compute_2 = TaskToComputeFactory(
         requestor_ethereum_public_key=encode_hex(REQUESTOR_PUB_ETH_KEY),
         requestor_public_key=encode_hex(REQUESTOR_PUBLIC_KEY),
         want_to_compute_task=WantToComputeTaskFactory(
             provider_ethereum_public_key=encode_hex(PROVIDER_PUB_ETH_KEY),
             provider_public_key=encode_hex(PROVIDER_PUBLIC_KEY),
         ),
     )
     self.task_to_compute_2.generate_ethsig(REQUESTOR_PRIV_ETH_KEY)
示例#19
0
    def setUp(self):
        super().setUp()
        task_to_compute = self._get_deserialized_task_to_compute()
        self.payer_ethereum_address = task_to_compute.requestor_ethereum_address
        self.payee_ethereum_address = task_to_compute.provider_ethereum_address

        client = Client(public_key_bytes=self.REQUESTOR_PUBLIC_KEY)
        client.clean()
        client.save()

        self.payer_deposit_account = DepositAccount()
        self.payer_deposit_account.client = client
        self.payer_deposit_account.ethereum_address = task_to_compute.requestor_ethereum_address
        self.payer_deposit_account.clean()
        self.payer_deposit_account.save()

        self.deposit_claim = DepositClaim()
        self.deposit_claim.payer_deposit_account = self.payer_deposit_account
        self.deposit_claim.subtask_id = task_to_compute.subtask_id
        self.deposit_claim.payee_ethereum_address = self.payee_ethereum_address
        self.deposit_claim.concent_use_case = ConcentUseCase.FORCED_TASK_RESULT.value
        self.deposit_claim.amount = 1
        self.deposit_claim.tx_hash = encode_hex(MOCK_TRANSACTION.hash)
示例#20
0
 def _get_requestor_ethereum_hex_public_key_different(self):
     """ Returns requestor ethereum public key encoded. """
     return encode_hex(self.DIFFERENT_REQUESTOR_PUB_ETH_KEY)
示例#21
0
def _get_provider_hex_public_key():
    """ Returns provider hex public key """
    return encode_hex(PROVIDER_PUBLIC_KEY)
示例#22
0
def create_signed_task_to_compute(
    deadline: int,
    timestamp: Optional[Union[datetime.datetime, str]] = None,
    provider_public_key: Optional[bytes] = None,
    provider_private_key: Optional[bytes] = None,
    requestor_public_key: Optional[bytes] = None,
    requestor_private_key: Optional[bytes] = None,
    price: int = 1,
    size: int = 1,
    package_hash: str = 'sha1:57786d92d1a6f7eaaba1c984db5e108c68b03f0d',
    render_parameters: Optional[Dict[str, Any]] = None,
) -> TaskToCompute:
    # Temporary workaround for requestor's and provider's keys until all Concent use cases will have payments
    # When we will have payments then all keys will be taken from SCIBaseTest class
    if provider_public_key is None and provider_private_key is None:
        provider_public_key = PROVIDER_PUBLIC_KEY
        provider_private_key = PROVIDER_PRIVATE_KEY
    if requestor_public_key is None and requestor_private_key is None:
        requestor_public_key = REQUESTOR_PUBLIC_KEY
        requestor_private_key = REQUESTOR_PRIVATE_KEY

    with freeze_time(timestamp):
        compute_task_def = ComputeTaskDefFactory(
            deadline=deadline,
            extra_data={
                'output_format':
                'png',
                'scene_file':
                '/golem/resources/golem-header-light.blend',
                'frames': [1],
                'resolution':
                render_parameters.get('resolution')
                if render_parameters is not None else [400, 400],
                'use_compositing':
                render_parameters.get('use_compositing')
                if render_parameters is not None else False,
                'samples':
                render_parameters.get('samples')
                if render_parameters is not None else 0,
                'crops': [{
                    'borders_x':
                    render_parameters['borders_x']
                    if render_parameters is not None else [0.0, 1.0],
                    'borders_y':
                    render_parameters['borders_y']
                    if render_parameters is not None else [0.0, 1.0],
                }]
            })

        task_header: TaskHeader = TaskHeaderFactory(
            task_id=compute_task_def['task_id'],
            sign__privkey=requestor_private_key,
        )

        want_to_compute_task = WantToComputeTaskFactory(
            provider_public_key=encode_hex(provider_public_key),
            task_header=task_header,
            sign__privkey=provider_private_key)

        task_to_compute = TaskToComputeFactory(
            requestor_public_key=encode_hex(requestor_public_key),
            compute_task_def=compute_task_def,
            want_to_compute_task=want_to_compute_task,
            requestor_ethereum_public_key=encode_hex(requestor_public_key),
            price=price,
            size=size,
            package_hash=package_hash,
        )
        task_to_compute.generate_ethsig(requestor_private_key)
        task_to_compute.sign_all_promissory_notes(
            deposit_contract_address=settings.GNT_DEPOSIT_CONTRACT_ADDRESS,
            private_key=requestor_private_key,
        )
        signed_task_to_compute: TaskToCompute = sign_message(
            task_to_compute, requestor_private_key)  # type: ignore
        return signed_task_to_compute
示例#23
0
 def _get_provider_ethereum_hex_public_key(self):
     """ Returns provider ethereum address """
     return encode_hex(self.PROVIDER_PUB_ETH_KEY)
示例#24
0
 def requestor_empty_account_eth_address(self) -> str:
     return to_checksum_address(
         encode_hex(
             privtoaddr(self.requestor_empty_account_keys.raw_privkey)))
示例#25
0
 def provider_eth_address(self) -> str:
     return to_checksum_address(
         encode_hex(privtoaddr(self.provider_keys.raw_privkey)))
示例#26
0
 def _get_provider_ethereum_hex_public_key_different(self):
     """ Returns provider ethereum diffrent address """
     return encode_hex(self.DIFFERENT_PROVIDER_PUB_ETH_KEY)
示例#27
0
def _get_requestor_hex_public_key():
    return encode_hex(REQUESTOR_PUBLIC_KEY)
示例#28
0
 def setUp(self):
     self.task_to_compute_1 = TaskToComputeFactory(
         requestor_ethereum_address=encode_hex(REQUESTOR_PUBLIC_KEY),
         requestor_ethereum_public_key=encode_hex(REQUESTOR_PUB_ETH_KEY),
         requestor_public_key=encode_hex(REQUESTOR_PUBLIC_KEY),
         provider_ethereum_address=encode_hex(PROVIDER_PUBLIC_KEY),
         provider_ethereum_public_key=encode_hex(PROVIDER_PUB_ETH_KEY),
         provider_public_key=encode_hex(PROVIDER_PUBLIC_KEY),
     )
     self.task_to_compute_2 = TaskToComputeFactory(
         requestor_ethereum_address=encode_hex(REQUESTOR_PUBLIC_KEY),
         requestor_ethereum_public_key=encode_hex(REQUESTOR_PUB_ETH_KEY),
         requestor_public_key=encode_hex(REQUESTOR_PUBLIC_KEY),
         provider_ethereum_address=encode_hex(PROVIDER_PUBLIC_KEY),
         provider_ethereum_public_key=encode_hex(PROVIDER_PUB_ETH_KEY),
         provider_public_key=encode_hex(PROVIDER_PUBLIC_KEY),
     )
示例#29
0
 def _get_diffrent_provider_hex_public_key(self):
     return encode_hex(self.DIFFERENT_PROVIDER_PUBLIC_KEY)
示例#30
0
 def _get_diffrent_requestor_hex_public_key(self):
     return encode_hex(self.DIFFERENT_REQUESTOR_PUBLIC_KEY)