new_contents: import pytest
  from plenum.common.messages.node_messages import NewView
  from plenum.test.helper import sdk_send_random_and_check, waitForViewChange
  from plenum.test.node_catchup.helper import ensure_all_nodes_have_same_data
  from plenum.test.node_request.helper import sdk_ensure_pool_functional
  
  call_count = 0
  
  
  @pytest.fixture(scope='function', params=range(1, 3))
  def lost_count(request):
      return request.param
  
  
  def test_view_change_with_lost_new_view(txnPoolNodeSet,
                                           looper,
                                           sdk_pool_handle,
                                           sdk_wallet_steward,
                                           tconf,
                                           tdir,
                                           allPluginsPath,
                                           monkeypatch,
                                           lost_count):
      '''
      Skip processing of lost_count Message Responses with NewView
      in view change; test makes sure that the node eventually finishes view change
      '''
  
      node_to_disconnect = txnPoolNodeSet[-1]
      initial_view_no = txnPoolNodeSet[0].viewNo
  
      sdk_send_random_and_check(looper, txnPoolNodeSet,
                                sdk_pool_handle, sdk_wallet_steward, 5)
  
      def unpatch_after_call(msg, frm):
          global call_count
          call_count += 1
  
          if call_count >= lost_count:
              # unpatch sendToReplica for NewView after lost_count calls
              node_to_disconnect.nodeMsgRouter.add((NewView, node_to_disconnect.sendToReplica))
              call_count = 0
  
      # patch sendToReplica for routing NewView
      node_to_disconnect.nodeMsgRouter.add((NewView, unpatch_after_call))
  
      # trigger view change on all nodes
      for n in txnPoolNodeSet:
          n.view_changer.on_master_degradation()
      waitForViewChange(looper, txnPoolNodeSet, expectedViewNo=initial_view_no + 1)
      ensure_all_nodes_have_same_data(looper, nodes=txnPoolNodeSet)
  
      # make sure that the pool is functional
      sdk_ensure_pool_functional(looper, txnPoolNodeSet, sdk_wallet_steward, sdk_pool_handle)
  
subject: add test_view_change_with_lost_new_view