old_contents: from plenum.test.helper import checkViewNoForNodes, sendRandomRequests
  from stp_core.common.log import getlogger
  from stp_core.loop.eventually import eventually
  from plenum.test import waits
  
  logger = getlogger()
  
  
  def provoke_and_check_view_change(nodes, newViewNo, wallet, client):
  
      if {n.viewNo for n in nodes} == {newViewNo}:
          return True
  
      # If throughput of every node has gone down then check that
      # view has changed
      tr = [n.monitor.isMasterThroughputTooLow() for n in nodes]
      if all(tr):
          logger.info('Throughput ratio gone down, its {}'.format(tr))
          checkViewNoForNodes(nodes, newViewNo)
      else:
          logger.info('Master instance has not degraded yet, '
                       'sending more requests')
          sendRandomRequests(wallet, client, 10)
          assert False
  
  
  def provoke_and_wait_for_view_change(looper,
                                       nodeSet,
                                       expectedViewNo,
                                       wallet,
                                       client,
                                       customTimeout=None):
      timeout = customTimeout or waits.expectedPoolViewChangeStartedTimeout(len(nodeSet))
      timeout *= 30
      return looper.run(eventually(provoke_and_check_view_change,
                                   nodeSet,
                                   expectedViewNo,
                                   wallet,
                                   client,
                                   timeout=timeout))
  
  
new_contents: from plenum.test.helper import checkViewNoForNodes, sendRandomRequests
  from stp_core.common.log import getlogger
  from stp_core.loop.eventually import eventually
  from plenum.test import waits
  
  logger = getlogger()
  
  
  def provoke_and_check_view_change(nodes, newViewNo, wallet, client):
  
      if {n.viewNo for n in nodes} == {newViewNo}:
          return True
  
      # If throughput of every node has gone down then check that
      # view has changed
      tr = [n.monitor.isMasterThroughputTooLow() for n in nodes]
      if all(tr):
          logger.info('Throughput ratio gone down, its {}'.format(tr))
          checkViewNoForNodes(nodes, newViewNo)
      else:
          logger.info('Master instance has not degraded yet, '
                       'sending more requests')
          sendRandomRequests(wallet, client, 10)
          assert False
  
  
  def provoke_and_wait_for_view_change(looper,
                                       nodeSet,
                                       expectedViewNo,
                                       wallet,
                                       client,
                                       customTimeout=None):
      timeout = customTimeout or waits.expectedPoolViewChangeStartedTimeout(len(nodeSet))
      # timeout *= 30
      return looper.run(eventually(provoke_and_check_view_change,
                                   nodeSet,
                                   expectedViewNo,
                                   wallet,
                                   client,
                                   timeout=timeout))
  
  
subject: decrease timeout to fix provoke_and_wait_for_view_change