Example #1
0
    def test_check_blocks(self):
        self.mock_stream.send.return_value = self._make_future(
            message_type=Message.CONSENSUS_CHECK_BLOCKS_RESPONSE,
            content=consensus_pb2.ConsensusCheckBlocksResponse(
                status=consensus_pb2.ConsensusCheckBlocksResponse.OK))

        self.service.check_blocks(priority=[b'test1', b'test2'])

        self.mock_stream.send.assert_called_with(
            message_type=Message.CONSENSUS_CHECK_BLOCKS_REQUEST,
            content=consensus_pb2.ConsensusCheckBlocksRequest(
                block_ids=[b'test1', b'test2']).SerializeToString())
Example #2
0
    def check_blocks(self, priority):
        request = consensus_pb2.ConsensusCheckBlocksRequest(block_ids=priority)

        response_type = consensus_pb2.ConsensusCheckBlocksResponse

        response = self._send(
            request=request,
            message_type=Message.CONSENSUS_CHECK_BLOCKS_REQUEST,
            response_type=response_type)

        status = response.status

        if status == response_type.UNKNOWN_BLOCK:
            raise exceptions.UnknownBlock()

        if status != response_type.OK:
            raise exceptions.ReceiveError(
                'Failed with status {}'.format(status))