示例#1
0
    def test_cancel_block(self):
        self.mock_stream.send.return_value = self._make_future(
            message_type=Message.CONSENSUS_CANCEL_BLOCK_RESPONSE,
            content=consensus_pb2.ConsensusCancelBlockResponse(
                status=consensus_pb2.ConsensusCancelBlockResponse.OK))

        self.service.cancel_block()

        request = consensus_pb2.ConsensusCancelBlockRequest()

        self.mock_stream.send.assert_called_with(
            message_type=Message.CONSENSUS_CANCEL_BLOCK_REQUEST,
            content=request.SerializeToString())
示例#2
0
    def cancel_block(self):
        request = consensus_pb2.ConsensusCancelBlockRequest()

        response_type = consensus_pb2.ConsensusCancelBlockResponse

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

        status = response.status

        if status == response_type.INVALID_STATE:
            raise exceptions.InvalidState(
                'Cannot cancel block in current state')

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