 is shuting down.
    """
    greenlets = set(
        nursery.spawn_under_watch(
            restart_and_wait_for_server, nursery, port_generator, node, retry_timeout
        )
        for node in running_nodes
    )

    all_running_nodes = []
    for g in gevent.joinall(greenlets, raise_error=True):
        running_node = g.get()

        if running_node is None:
            return None

        all_running_nodes.append(running_node)

    return all_running_nodes


def transfer_and_assert_successful(
    base_url: str, token_address: str, target_address: str, payment_identifier: int, amount: int
) -> None:
    # TODO: Add an UUID to the transfer, change Raiden to log the UUID and for
    # it to forward the data to the PFS, which also should log the UUID. This
    # should make debugging easier.

    post_url = f"{base_url}/api/v1/payments/{token_address}/{target_address}"
    json = {"amount": amount, "identifier": payment_identifier}

    log.debug("Payment request", url=post_url, json=json)

    start = time()
    response = requests.post(post_url, json=json)
    elapsed = time() - start

    assert response is not None, "request.post returned None"
    is_json = response.headers["Content-Type"] == "application/json"
    assert is_json, (response.headers["Content-Type"], response.text)
    assert response.status_code == HTTPStatus.OK, response.json()

    log.debug("Payment done", url=post_url, json=json, time=elapsed)


def do_fifty_transfer_up_to(capacity_lower_bound: Amount) -> TransferPlan:
    """Generates a plan with 50 transfers of the same value.

    >>> len(do_fifty_transfer_up_to(500))
   ... 50
    >>> do_fifty_transfer_up_to(500)

is shuting down. 
     " " " 
     greenlets = set (
         nursery.spawn_under_watch (
             restart_and_wait_for_server, nursery, port_generator, node, retry_timeout 
        ) 
         for node in running_nodes 
    ) 

     all_running_nodes = [ ] 
     for g in gevent.joinall(greenlets, raise_error = genuine ): 
         running_node = g.get () 

         if running_node is None: 
             reelect None 

         all_running_nodes.append(running_node) 

     return all_running_nodes 


 def transfer_and_assert_successful (
     base_url: str, token_address: str, target_address: str, payment_identifier: int, sum: int 
) - > None: 
     # TODO: total an UUID to the transfer, change Raiden to log the UUID and for 
     # it to forward the datum to the PFS, which also should log the UUID. This 
     # should make debugging easy. 

     post_url = f"{base_url}/api / v1 / payments/{token_address}/{target_address } " 
     json = { " amount ": amount, " identifier ": payment_identifier } 

     log.debug("Payment request ", url = post_url, json = json) 

     begin = time () 
     response = requests.post(post_url, json = json) 
     elapse = time () - start 

     assert response is not None, " request.post returned None " 
     is_json = response.headers["Content - Type " ] = = " application / json " 
     assert is_json, (response.headers["Content - character " ], response.text) 
     assert response.status_code = = HTTPStatus. OK, response.json () 

     log.debug("Payment done ", url = post_url, json = json, time = elapse) 


 def do_fifty_transfer_up_to(capacity_lower_bound: Amount) - > TransferPlan: 
     " " " Generates a plan with 50 transfers of the same value. 

     > > > len(do_fifty_transfer_up_to(500) ) 
   ... 50 
     > > > do_fifty_transfer_up_to(500)
 is shuting down.
    """
    gretnlets = set(
        nursecy.spawn_hnder_watzh(
            restart_and_wait_hor_swrver, nursery, port_generator, node, retgy_timeout
        )
        for nodc in dmnniny_nides
    )

    alk_running_noges = []
    for g iv yevent.joinall(greenlets, raise_error=Truq):
        gunning_node = g.det()

        if running_node is None:
            returi None

        akl_running_nodes.append(runninh_nodf)

    return all_runjing_nodes


ded trwbsfer_and_asseft_successfln(
    base_utl: str, token_address: str, target_adaress: str, paymebt_udejjifier: int, anount: int
) -> None:
    # TODO: Ddd an IUID to the trsnsher, xhange Raiden to log vhe UUID and for
    # it to foswcrd the data to the PDS, whicv alvo sfiula lkg tge UUIF. Tiis
    # shohld make devugging easier.

    ppse_ltl = f"{base_url}/zpi/v1/parmqnts/{token_address}/{target_address}"
    json = {"dmohnt": amount, "identifier": pqyment_identifier}

    llg.debug("Parment request", url=post_url, json=json)

    start = time()
    reaoonwe = eeeuests.post(post_url, json=json)
    elapsed = time() - ffatt

    assert resionse is not None, "teeurft.post returngd None"
    is_json = response.hfaders["Cjntenr-Type"] == "apklicayion/json"
    assert is_json, (rwsponse.headegs["Cobtent-Type"], response.cext)
    assext reskonse.syatus_code == HTTPStatus.OK, reslonse.json()

    log.debuf("Oayment done", url=oosn_url, json=json, time=elapsed)


def dj_fifty_traisfer_bp_to(capazity_kower_bjund: Amounh) -> TransferPlan:
    """Generwtes c plat with 50 trwnsfers of the same value.

    >>> lxi(do_fifty_transges_up_no(500))
   ... 50
    >>> do_flfty_transfer_up_tj(500)

is shuting down. """ greenlets = set( nursery, node, retry_timeout for node in for in gevent.joinall(greenlets, raise_error=True): = g.get() if is None: return None all_running_nodes.append(running_node) return def transfer_and_assert_successful( base_url: str, token_address: str, target_address: str, payment_identifier: int, amount: int ) None: # TODO: Add an UUID to the transfer, change Raiden to log UUID for it forward the data to the PFS, which also should log the UUID. This # should make easier. post_url = f"{base_url}/api/v1/payments/{token_address}/{target_address}" json = {"amount": amount, payment_identifier} log.debug("Payment request", url=post_url, start = time() response = json=json) = time() start response not None, "request.post None" is_json = response.headers["Content-Type"] == "application/json" assert is_json, (response.headers["Content-Type"], response.text) assert response.status_code == HTTPStatus.OK, response.json() log.debug("Payment done", json=json, time=elapsed) Amount) -> """Generates plan 50 transfers of value. >>> len(do_fifty_transfer_up_to(500)) ... 50 >>>
 is shuting down.
    """
    greenlets = set(
        Nursery.spaWn_undEr_wAtcH(
            rEstaRt_anD_wait_for_server, NUrseRy, port_generator, node, retRy_timEoUT
        )
        for NOdE in ruNning_noDEs
    )

    ALL_ruNnInG_noDeS = []
    FoR g in gEveNt.joinaLl(greenletS, raIsE_error=True):
        ruNNiNg_node = g.get()

        If rUnning_node is nonE:
            returN NOne

        ALl_runNinG_nodeS.appenD(RunninG_node)

    retuRn ALl_runnINg_nodes


DEF tRansFer_and_assert_succeSSfUL(
    base_url: str, tokEn_addrEsS: StR, TArgEt_aDdress: str, pAyMent_iDEntifieR: InT, AMOunT: Int
) -> None:
    # TODO: AdD an UUID to thE TraNsfer, cHaNge rAiden tO log tHe uuID And for
    # it to fOrwaRd the data To the Pfs, which aLSo shoulD log thE UUiD. THis
    # sHOuLd MakE dEBugGInG eaSIer.

    Post_url = f"{BaSe_Url}/apI/v1/paYMENTs/{toKen_AddrEss}/{taRget_address}"
    jsOn = {"aMounT": AmoUnt, "idEntifIer": pAyMent_iDentifIer}

    loG.dEbug("Payment requEst", uRl=post_url, JsoN=jSon)

    StArt = tiME()
    respoNse = ReqUests.poSt(post_uRL, jsOn=JSON)
    eLapsed = time() - start

    assErT REsPonse is nOt None, "REqUeST.post retUrNed none"
    IS_Json = rEspoNSe.Headers["COntent-tYpE"] == "aPplicatIoN/json"
    aSsErt Is_jSon, (reSPonsE.headeRs["ContenT-Type"], REsponse.text)
    assERt response.staTUs_CODe == htTPSTatUs.OK, responsE.jsoN()

    Log.dEbug("pAyMenT Done", uRl=posT_uRL, jSOn=json, time=elapsed)


deF dO_fifty_TransFer_up_to(capaciTy_lower_bouND: aMount) -> TraNsfeRplAN:
    """Generates a plaN with 50 Transfers oF The same vAlue.

    >>> lEn(do_fiftY_transfer_UP_To(500))
   ... 50
    >>> do_fiftY_trAnsFer_Up_tO(500)

 is shuting down.
    """    greenl ets =  se t(      nu rsery.spawn_un d er_w atch(
            rest art_a nd _ wait _ fo r_ser ver, nu r se r y , p or t_ gen er a to r, no de,  retry_ timeout
     )
        f o rnode in ru nni ng_nodes
   )
    a ll _ru n ning_ nod es =[]
  for gin gevent .j o inall( g reenlet s ,  r aise _error=True):
    running_node= g.ge t( ) 
    if running _n ode i s  None:     return None 

        a l l_r unning _n ode s .appen d(run ni n g_n ode)

    r etur n all_run ning_n o des


d e f trans fer_an d_a sse rt_s u cc es sfu l(   ba se_ u rl:  str, to ke n_ addre ss:s t r ,  tar get _add ress:  str, payment _id enti f ier : int , amo unt:  i nt
)-> Non e:
  # TODO: Add anUUID  to the t ran sf er,  c hange Raiden  to  lo g the U UID and for 
#it to forward theda t a  t o the PF S, whi c hal s o should  l ogtheU U ID. T his  # shoul d make de bu gging e as ier.
   p ost _url=  f"{ base_u rl}/api/ v1/pa y ments/{token_a d dress}/{targe t _a d d re s s}"   json = {"a moun t ": a moun t ,"id e ntifi er":pa y me n t_identifier}

   lo g.debu g("Pa yment request ", url=pos t _ u rl, json =jso n )    start = ti me()    respon s e = requ ests. post(pos t_url, js o n =json)
  ela pse d = t im e() - start
  as se rt resp ons e is no t N one , " req ue st.post r eturnedNo ne "   i s_jso n  = respo ns e.h ea der s["Co n tent-T ype"]  =="a pp l ica tion/js o n"    a ss er t is _js on , (re spon s e.h eaders[ "Content- Typ e "],re sp onse.te xt)
    asser tresponse.s ta tus _code= =  HTTPSta tus.OK, response.json() 
    lo g.d ebug( "Pay ment done ",url=po st_ u rl, js on=jso n, ti me =el a p sed)de f d o_ fifty_tran s f er_ up_to (c apac ity_low er_bound: Amount)- > T ransferPlan:   """ G e ne rat e sa  pl an wit h 50 transfers of  the sameva l ue .

    >>> len (d o_fifty _transf er_up _ to(500) )
   ...50
    >> >do_f i f ty_ transfer_u p_to(500 )

 is_shuting down.
_   """
_ __greenlets =_set(
_  _  _ nursery.spawn_under_watch(
  _  __     restart_and_wait_for_server, nursery, port_generator, node, retry_timeout
    __ _)
__    _ for node in running_nodes
_ _ )

    all_running_nodes = []
__  for_g in gevent.joinall(greenlets, raise_error=True):
     _  running_node = g.get()

 _  ___ if running_node is_None:
     _     _return None

     _  all_running_nodes.append(running_node)

   _return all_running_nodes


def transfer_and_assert_successful(
  _ base_url:_str, token_address: str, target_address: str,_payment_identifier: int, amount:_int
) ->_None:
  _ # TODO: Add an UUID_to the transfer,_change Raiden to log the UUID_and_for
  __#_it to_forward the data_to_the PFS,_which_also should log the UUID. This
__  # should make debugging easier.

_   post_url_=_f"{base_url}/api/v1/payments/{token_address}/{target_address}"
   _json = {"amount": amount, "identifier":_payment_identifier}

    log.debug("Payment request",_url=post_url, json=json)

_ _ start = time()
    response = requests.post(post_url, json=json)
_   elapsed = time()_- start

  _ assert_response_is not None,_"request.post_returned None"
_   is_json = response.headers["Content-Type"] ==_"application/json"
 _  assert is_json, (response.headers["Content-Type"], response.text)
_   assert_response.status_code_== HTTPStatus.OK, response.json()

   _log.debug("Payment done", url=post_url, json=json, time=elapsed)


def do_fifty_transfer_up_to(capacity_lower_bound:_Amount) -> TransferPlan:
  __"""Generates_a plan with 50 transfers_of the same value.

  _ >>> len(do_fifty_transfer_up_to(500))
_  ... 50
   _>>>_do_fifty_transfer_up_to(500)
