Ejemplo n.º 1
0
    def test_ignore_block(self):
        self.mock_stream.send.return_value = self._make_future(
            message_type=Message.CONSENSUS_IGNORE_BLOCK_RESPONSE,
            content=consensus_pb2.ConsensusIgnoreBlockResponse(
                status=consensus_pb2.ConsensusIgnoreBlockResponse.OK))

        self.service.ignore_block(block_id=b'test')

        self.mock_stream.send.assert_called_with(
            message_type=Message.CONSENSUS_IGNORE_BLOCK_REQUEST,
            content=consensus_pb2.ConsensusIgnoreBlockRequest(
                block_id=b'test').SerializeToString())
Ejemplo n.º 2
0
    def ignore_block(self, block_id):
        request = consensus_pb2.ConsensusIgnoreBlockRequest(block_id=block_id)

        response_type = consensus_pb2.ConsensusIgnoreBlockResponse

        response = self._send(
            request=request,
            message_type=Message.CONSENSUS_IGNORE_BLOCK_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))