MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_io_logging

Function test_io_logging

tests/test_misc.py:768–814  ·  view source on GitHub ↗
(node_factory, executor)

Source from the content-addressed store, hash-verified

766
767
768def test_io_logging(node_factory, executor):
769 l1 = node_factory.get_node(options={'log-level': 'io'})
770 l2 = node_factory.get_node()
771 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
772
773 # Fundchannel manually so we get channeld pid.
774 l1.fundwallet(10**6 + 1000000)
775 l1.rpc.fundchannel(l2.info['id'], 10**6)['tx']
776
777 l1.daemon.wait_for_log('sendrawtx exit 0')
778 l1.bitcoin.generate_block(1)
779 l1.daemon.wait_for_log(' to CHANNELD_NORMAL')
780 l2.daemon.wait_for_log(' to CHANNELD_NORMAL')
781
782 fut = executor.submit(l1.pay, l2, 200000000)
783
784 # WIRE_UPDATE_ADD_HTLC = 128 = 0x0080
785 l1.daemon.wait_for_log(r'channeld.*: \[OUT\] 0080')
786 # WIRE_UPDATE_FULFILL_HTLC = 130 = 0x0082
787 l1.daemon.wait_for_log(r'channeld.*: \[IN\] 0082')
788 fut.result(10)
789
790 # Send it sigusr1: should turn off logging.
791 pid1 = l1.subd_pid('channeld')
792 subprocess.run(['kill', '-USR1', pid1])
793
794 l1.pay(l2, 200000000)
795
796 assert not l1.daemon.is_in_log(r'channeld.*: \[OUT\] 0080',
797 start=l1.daemon.logsearch_start)
798 assert not l1.daemon.is_in_log(r'channeld.*: \[IN\] 0082',
799 start=l1.daemon.logsearch_start)
800
801 # IO logs should not appear in peer logs.
802 peerlog = only_one(l2.rpc.listpeers(l1.info['id'], "io")['peers'])['log']
803 assert not any(l['type'] == 'IO_OUT' or l['type'] == 'IO_IN'
804 for l in peerlog)
805
806 # Turn on in l2 channel logging.
807 pid2 = l2.subd_pid('channeld')
808 subprocess.run(['kill', '-USR1', pid2])
809 l1.pay(l2, 200000000)
810
811 # Now it should find it.
812 peerlog = only_one(l2.rpc.listpeers(l1.info['id'], "io")['peers'])['log']
813 assert any(l['type'] == 'IO_OUT' for l in peerlog)
814 assert any(l['type'] == 'IO_IN' for l in peerlog)
815
816
817def test_address(node_factory):

Callers

nothing calls this directly

Calls 13

only_oneFunction · 0.90
fundwalletMethod · 0.80
wait_for_logMethod · 0.80
generate_blockMethod · 0.80
subd_pidMethod · 0.80
is_in_logMethod · 0.80
anyClass · 0.50
get_nodeMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45
runMethod · 0.45
payMethod · 0.45

Tested by

no test coverage detected