Browse Source

tests: new helper to get pid of a particular subdaemon.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
498ad91318
  1. 7
      tests/test_lightningd.py
  2. 5
      tests/utils.py

7
tests/test_lightningd.py

@ -4250,16 +4250,13 @@ class LightningDTests(BaseLightningDTests):
# Fundchannel manually so we get channeld pid. # Fundchannel manually so we get channeld pid.
self.give_funds(l1, 10**6 + 1000000) self.give_funds(l1, 10**6 + 1000000)
l1.rpc.fundchannel(l2.info['id'], 10**6)['tx'] l1.rpc.fundchannel(l2.info['id'], 10**6)['tx']
# Get pid of channeld, eg 'lightning_channeld(...): pid 13933, msgfd 12' pid1 = l1.subd_pid('channeld')
pidline = l1.daemon.wait_for_log(r'lightning_channeld.*: pid [0-9]*,')
pid1 = re.search(r'pid ([0-9]*),', pidline).group(1)
l1.daemon.wait_for_log('sendrawtx exit 0') l1.daemon.wait_for_log('sendrawtx exit 0')
l1.bitcoin.generate_block(1) l1.bitcoin.generate_block(1)
l1.daemon.wait_for_log(' to CHANNELD_NORMAL') l1.daemon.wait_for_log(' to CHANNELD_NORMAL')
pidline = l2.daemon.wait_for_log(r'lightning_channeld.*: pid [0-9]*,') pid2 = l2.subd_pid('channeld')
pid2 = re.search(r'pid ([0-9]*),', pidline).group(1)
l2.daemon.wait_for_log(' to CHANNELD_NORMAL') l2.daemon.wait_for_log(' to CHANNELD_NORMAL')
# Send it sigusr1: should turn on logging. # Send it sigusr1: should turn on logging.

5
tests/utils.py

@ -470,6 +470,11 @@ class LightningNode(object):
decoded2 = self.bitcoin.rpc.decoderawtransaction(tx) decoded2 = self.bitcoin.rpc.decoderawtransaction(tx)
raise ValueError("Can't find {} payment in {} (1={} 2={})".format(amount, tx, decoded, decoded2)) raise ValueError("Can't find {} payment in {} (1={} 2={})".format(amount, tx, decoded, decoded2))
def subd_pid(self, subd):
"""Get the process id of the given subdaemon, eg channeld or gossipd"""
pidline = self.daemon.is_in_log('lightning_{}.*: pid [0-9]*,'.format(subd))
return re.search(r'pid ([0-9]*),', pidline).group(1)
def is_channel_active(self, chanid): def is_channel_active(self, chanid):
channels = self.rpc.listchannels()['channels'] channels = self.rpc.listchannels()['channels']
active = [(c['short_channel_id'], c['flags']) for c in channels if c['active']] active = [(c['short_channel_id'], c['flags']) for c in channels if c['active']]

Loading…
Cancel
Save