示例#1
0
class GetNodeInfoRequestFilterTestCase(BaseFilterTestCase):
    filter_type = GetNodeInfoCommand(MockAdapter()).get_request_filter
    skip_value_check = True

    def test_pass_empty(self):
        """
    The incoming request is (correctly) empty.
    """
        request = {}

        filter_ = self._filter(request)

        self.assertFilterPasses(filter_)
        self.assertDictEqual(filter_.cleaned_data, request)

    def test_fail_unexpected_parameters(self):
        """
    The incoming request contains unexpected parameters.
    """
        self.assertFilterErrors(
            {
                # All you had to do was nothing!  How did you screw that up?!
                'foo': 'bar',
            },
            {
                'foo': [f.FilterMapper.CODE_EXTRA_KEY],
            },
        )
示例#2
0
    def _execute(self, request):
        hashes = request['hashes']  # type: List[TransactionHash]

        gni_response = GetNodeInfoCommand(self.adapter)()

        gis_response = GetInclusionStatesCommand(self.adapter)(
            transactions=hashes,
            tips=[gni_response['latestSolidSubtangleMilestone']],
        )

        return {
            'states': dict(zip(hashes, gis_response['states'])),
        }
示例#3
0
class GetNodeInfoRequestFilterTestCase(BaseFilterTestCase):
    filter_type = GetNodeInfoCommand(MockAdapter()).get_request_filter
    skip_value_check = True

    def test_pass_empty(self):
        """
    The incoming response is (correctly) empty.
    """
        request = {}

        # "def _filter()" below is going to be defined in
        # # site-packages/filters/test.py
        filter_ = self._filter(request)

        print_var_type_n_val(
            var001=filter_,
            pointer="#SDFGHhgfd123456666DFFdd")  #SDFGHhgfd123456666DFFdd
        # Value:
        # # GetNodeInfoRequestFilter(FilterChain(Type(Mapping, allow_subclass=True) | FilterMapper()))

        # Type: <class 'filters.handlers.FilterRunner'>

        self.assertFilterPasses(filter_)
        self.assertDictEqual(filter_.cleaned_data, request)

    def test_fail_unexpected_parameters(self):
        """
    The incoming response contains unexpected parameters.
    """
        self.assertFilterErrors(
            {
                # All you had to do was nothing!  How did you screw that up?!
                'foo': 'bar',
            },
            {
                'foo': [f.FilterMapper.CODE_EXTRA_KEY],
            },
        )
示例#4
0
class GetNodeInfoResponseFilterTestCase(BaseFilterTestCase):
    filter_type = GetNodeInfoCommand(MockAdapter()).get_response_filter
    skip_value_check = True

    def test_pass_happy_path(self):
        """
    The incoming response contains valid values.
    """
        response = {
            'appName':
            'IRI',
            'appVersion':
            '1.0.8.nu',
            'coordinatorAddress':
            'BUPQSYFUFMUOJVGVFKPCOULCQNTJPYJOTATSILTN'
            'ZKOPQWHENIDIH9HJEUOTNV9LNGHCTHMHWOPLZOJCJ',
            'duration':
            1,
            'jreAvailableProcessors':
            4,
            'jreFreeMemory':
            91707424,
            'jreMaxMemory':
            1908932608,
            'jreTotalMemory':
            122683392,
            'latestMilestoneIndex':
            107,
            'latestSolidSubtangleMilestoneIndex':
            107,
            'neighbors':
            2,
            'packetsQueueSize':
            0,
            'time':
            1477037811737,
            'tips':
            3,
            'transactionsToRequest':
            0,
            'latestMilestone':
            'VBVEUQYE99LFWHDZRFKTGFHYGDFEAMAEBGUBTTJR'
            'FKHCFBRTXFAJQ9XIUEZQCJOQTZNOOHKUQIKOY9999',
            'latestSolidSubtangleMilestone':
            'VBVEUQYE99LFWHDZRFKTGFHYGDFEAMAEBGUBTTJR'
            'FKHCFBRTXFAJQ9XIUEZQCJOQTZNOOHKUQIKOY9999',
        }

        filter_ = self._filter(response)

        self.assertFilterPasses(filter_)
        self.assertDictEqual(
            filter_.cleaned_data,
            {
                'appName':
                'IRI',
                'appVersion':
                '1.0.8.nu',
                'coordinatorAddress':
                Address(b'BUPQSYFUFMUOJVGVFKPCOULCQNTJPYJOTATSILTN'
                        b'ZKOPQWHENIDIH9HJEUOTNV9LNGHCTHMHWOPLZOJCJ'),
                'duration':
                1,
                'jreAvailableProcessors':
                4,
                'jreFreeMemory':
                91707424,
                'jreMaxMemory':
                1908932608,
                'jreTotalMemory':
                122683392,
                'latestMilestoneIndex':
                107,
                'latestSolidSubtangleMilestoneIndex':
                107,
                'neighbors':
                2,
                'packetsQueueSize':
                0,
                'time':
                1477037811737,
                'tips':
                3,
                'transactionsToRequest':
                0,
                'latestMilestone':
                TransactionHash(
                    b'VBVEUQYE99LFWHDZRFKTGFHYGDFEAMAEBGUBTTJR'
                    b'FKHCFBRTXFAJQ9XIUEZQCJOQTZNOOHKUQIKOY9999', ),
                'latestSolidSubtangleMilestone':
                TransactionHash(
                    b'VBVEUQYE99LFWHDZRFKTGFHYGDFEAMAEBGUBTTJR'
                    b'FKHCFBRTXFAJQ9XIUEZQCJOQTZNOOHKUQIKOY9999', ),
            },
        )
示例#5
0
class GetNodeInfoResponseFilterTestCase(BaseFilterTestCase):
    filter_type = GetNodeInfoCommand(MockAdapter()).get_response_filter
    skip_value_check = True

    # noinspection SpellCheckingInspection
    def test_pass_happy_path(self):
        """
    The incoming response contains valid values.
    """
        response = {
            'appName':
            'IRI',
            'appVersion':
            '1.0.8.nu',
            'duration':
            1,
            'jreAvailableProcessors':
            4,
            'jreFreeMemory':
            91707424,
            'jreMaxMemory':
            1908932608,
            'jreTotalMemory':
            122683392,
            'latestMilestoneIndex':
            107,
            'latestSolidSubtangleMilestoneIndex':
            107,
            'neighbors':
            2,
            'packetsQueueSize':
            0,
            'time':
            1477037811737,
            'tips':
            3,
            'transactionsToRequest':
            0,
            'latestMilestone':
            'VBVEUQYE99LFWHDZRFKTGFHYGDFEAMAEBGUBTTJR'
            'FKHCFBRTXFAJQ9XIUEZQCJOQTZNOOHKUQIKOY9999',
            'latestSolidSubtangleMilestone':
            'VBVEUQYE99LFWHDZRFKTGFHYGDFEAMAEBGUBTTJR'
            'FKHCFBRTXFAJQ9XIUEZQCJOQTZNOOHKUQIKOY9999',
        }

        filter_ = self._filter(response)
        # "def _filter()" below is going to be defined in
        # # site-packages/filters/test.py
        print_var_type_n_val(
            var001=filter_,
            pointer="#SDFGHhgfBVCdfg1234555")  #SDFGHhgfBVCdfg1234555
        # Value:
        # # GetNodeInfoResponseFilter(FilterChain(Type(Mapping, allow_subclass=True) | FilterMapper(latestMilestone=FilterChain(ByteString(encoding='ascii') | Trytes()), latestSolidSubtangleMilestone=FilterChain(ByteString(encoding='ascii') | Trytes()))))

        # Type: <class 'filters.handlers.FilterRunner'>

        self.assertFilterPasses(filter_)
        self.assertDictEqual(
            filter_.cleaned_data,
            {
                'appName':
                'IRI',
                'appVersion':
                '1.0.8.nu',
                'duration':
                1,
                'jreAvailableProcessors':
                4,
                'jreFreeMemory':
                91707424,
                'jreMaxMemory':
                1908932608,
                'jreTotalMemory':
                122683392,
                'latestMilestoneIndex':
                107,
                'latestSolidSubtangleMilestoneIndex':
                107,
                'neighbors':
                2,
                'packetsQueueSize':
                0,
                'time':
                1477037811737,
                'tips':
                3,
                'transactionsToRequest':
                0,
                'latestMilestone':
                TransactionHash(
                    b'VBVEUQYE99LFWHDZRFKTGFHYGDFEAMAEBGUBTTJR'
                    b'FKHCFBRTXFAJQ9XIUEZQCJOQTZNOOHKUQIKOY9999', ),
                'latestSolidSubtangleMilestone':
                TransactionHash(
                    b'VBVEUQYE99LFWHDZRFKTGFHYGDFEAMAEBGUBTTJR'
                    b'FKHCFBRTXFAJQ9XIUEZQCJOQTZNOOHKUQIKOY9999', ),
            },
        )