def test_load_without_public_key_should_load_message(self):
        """
        Test that message loaded with load_without_public_key function will be the same as load
        with golem_messages load function.
        """

        # Create and fill some data into ComputeTaskDef
        compute_task_def = tasks.ComputeTaskDefFactory(
            task_id=generate_uuid_for_tests(),
            subtask_id=generate_uuid_for_tests(),
            deadline=1510912800,
        )

        # Create TaskToCompute
        task_to_compute = tasks.TaskToComputeFactory(
            compute_task_def = compute_task_def,
            price=0,
        )

        # Dump TaskToCompute to make it signed
        dumped_task_to_compute = dump(task_to_compute, REQUESTOR_PRIVATE_KEY, CONCENT_PUBLIC_KEY)

        loaded_task_to_compute_with_utility_function    = load_without_public_key(
            dumped_task_to_compute,
            REQUESTOR_PUBLIC_KEY,
        )

        loaded_task_to_compute_with_golem_messages_load = load(
            dumped_task_to_compute,
            CONCENT_PRIVATE_KEY,
            REQUESTOR_PUBLIC_KEY,
        )

        self.assertEqual(loaded_task_to_compute_with_utility_function, loaded_task_to_compute_with_golem_messages_load)
 def setUp(self):
     self.size = 1048576
     self.address = "10.10.10.1"
     self.provider_ethereum_public_key = "b'A9LjJQJDc9ugt+kxA/r58chrekDr3VFZpfjU6Pv9dTP1gGLOvKEUxGwlB1ffDAbdWY8P0Pa37Mt6muFpJKC1mA=='=="
     self.provider_public_key = "PKn3TUiXdfeoHjoeu6PEDMD5JqrdmyeKlbG5rWUpgAs6qbKj7k9bm8vvkmhn40RkMykho6uAHsYVy72ZBYUelQ=="
     self.requestor_ethereum_public_key = "b'T8ER1hrI9hH0Zyu/m6u9H2K4rc1mC/dlCqK0PSzBSwvKBdHfysmrIIsQMyvecDU+TIkhDmq93Olfo5h2FSGRjw=='"
     self.requestor_public_key = "mrdOXP6Owe3i48G29RHPVU6wewvuUNuNxFB+kPTDnmI21+p5ShttCSUAbHOVm8OIUF9hEluc1+lICJZGkFSSOA=="
     self.deadline = 1510394400
     self.subtask_id = generate_uuid_for_tests()
     self.task_id = generate_uuid_for_tests()
Ejemplo n.º 3
0
    def setUp(self):
        self.request_factory = RequestFactory()
        self.want_to_compute = message.WantToComputeTask(
            node_name=1,
            task_id=generate_uuid_for_tests(),
            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(
            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.concents.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
Ejemplo n.º 4
0
    def setUp(self):
        super().setUp()
        self.frames = [1, 2]
        self.result_files_list = ['result_240001.png', 'result_240002.png']
        self.output_format = 'PNG'
        self.parsed_files_to_compare = {
            1: ['/tmp/result_240001.png'],
            2: ['/tmp/result_240002.png'],
        }
        self.scene_file = 'scene-Helicopter-27-internal.blend'
        self.subtask_id = generate_uuid_for_tests()
        self.correct_parsed_all_files = {
            1: [
                '/tmp/result_240001.png',
                '/tmp/out_scene-Helicopter-27-internal.blend_0001.png'
            ],
            2: [
                '/tmp/result_240002.png',
                '/tmp/out_scene-Helicopter-27-internal.blend_0002.png'
            ]
        }
        self.correct_blender_output_file_name_list = [
            '/tmp/out_scene-Helicopter-27-internal.blend_0001.png',
            '/tmp/out_scene-Helicopter-27-internal.blend_0002.png'
        ]
        self.image = mock.create_autospec(spec=ndarray, spec_set=True)
        self.image.shape = (2000, 3000, 3)
        self.image_diffrent_color_channel = mock.create_autospec(spec=ndarray,
                                                                 spec_set=True)
        self.image_diffrent_color_channel.shape = (2000, 3000)
        self.image_diffrent_size = mock.create_autospec(spec=ndarray,
                                                        spec_set=True)
        self.image_diffrent_size.shape = (3000, 4000, 3)

        self.ssim_list = [0.99, 0.95]
        self.image_pairs = [
            (self.image, self.image),
            (self.image, self.image),
        ]
        self.image_ones = ones(shape=(1920, 1080, 3), dtype='uint8')
        self.image_zeros = zeros(shape=(1920, 1080, 3), dtype='uint8')
        self.image_diffrent_size = zeros(shape=(1080, 1920, 3), dtype='uint8')
Ejemplo n.º 5
0
 def test_that_regex_matches_uuid(self):  # pylint: disable=no-self-use
     assert_that(generate_uuid_for_tests()).matches(REGEX_FOR_VALID_UUID)
Ejemplo n.º 6
0
        except Exception:  # pylint: disable=broad-except
            self.fail()

    def test_that_function_pass_when_in_list_are_two_same_report_computed_task(self):
        try:
            validate_all_messages_identical([self.report_computed_task, self.report_computed_task])
        except Exception:  # pylint: disable=broad-except
            self.fail()

    def test_that_function_raise_http400_when_any_slot_will_be_different_in_messages(self):
        different_report_computed_task = self._get_deserialized_report_computed_task(size = 10)
        with self.assertRaises(ConcentValidationError):
            validate_all_messages_identical([self.report_computed_task, different_report_computed_task])


UUID: str = generate_uuid_for_tests()


class TestValidateIdValue:

    @pytest.mark.parametrize('id_', [
        UUID.replace('-', ''),
        UUID,
    ])  # pylint: disable=no-self-use
    def test_that_function_should_pass_when_value_is_allowed(self, id_):

        try:
            validate_uuid(id_)
        except Exception as exception:  # pylint: disable=broad-except
            pytest.fail(f'{exception}')
Ejemplo n.º 7
0
 def setUp(self):
     self.scene_file = "kitten.blend"
     self.subtask_id = generate_uuid_for_tests()
     self.archives_list = ["source.zip", "result.zip"]