def test_fail_block(self): self.mock_stream.send.return_value = self._make_future( message_type=Message.CONSENSUS_FAIL_BLOCK_RESPONSE, content=consensus_pb2.ConsensusFailBlockResponse( status=consensus_pb2.ConsensusFailBlockResponse.OK)) self.service.fail_block(block_id=b'test') self.mock_stream.send.assert_called_with( message_type=Message.CONSENSUS_FAIL_BLOCK_REQUEST, content=consensus_pb2.ConsensusFailBlockRequest( block_id=b'test').SerializeToString())
def fail_block(self, block_id): request = consensus_pb2.ConsensusFailBlockRequest(block_id=block_id) response_type = consensus_pb2.ConsensusFailBlockResponse response = self._send( request=request, message_type=Message.CONSENSUS_FAIL_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))