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

Function test_cli

tests/test_misc.py:1023–1202  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

1021
1022
1023def test_cli(node_factory):
1024 l1 = node_factory.get_node(options={'log-level': 'io'})
1025
1026 out = subprocess.check_output(['cli/lightning-cli',
1027 '--network={}'.format(TEST_NETWORK),
1028 '--lightning-dir={}'
1029 .format(l1.daemon.lightning_dir),
1030 'help']).decode('utf-8')
1031 # Test some known output.
1032 assert 'addgossip message\n\naddoutpointwatch' in out
1033
1034 # Check JSON id is as expected
1035 l1.daemon.wait_for_log(r'jsonrpc#[0-9]*: "cli:help#[0-9]*"\[IN\]')
1036
1037 # Test JSON output.
1038 out = subprocess.check_output(['cli/lightning-cli',
1039 '--network={}'.format(TEST_NETWORK),
1040 '--lightning-dir={}'
1041 .format(l1.daemon.lightning_dir),
1042 '-J',
1043 'help']).decode('utf-8')
1044 j, _ = json.JSONDecoder().raw_decode(out)
1045 assert j['help'][0]['command'] is not None
1046
1047 # Test keyword input (autodetect)
1048 out = subprocess.check_output(['cli/lightning-cli',
1049 '--network={}'.format(TEST_NETWORK),
1050 '--lightning-dir={}'
1051 .format(l1.daemon.lightning_dir),
1052 '-J',
1053 'help', 'command=help']).decode('utf-8')
1054 j, _ = json.JSONDecoder().raw_decode(out)
1055 assert 'help [command]' in j['help'][0]['command']
1056
1057 # Test keyword input (forced)
1058 out = subprocess.check_output(['cli/lightning-cli',
1059 '--network={}'.format(TEST_NETWORK),
1060 '--lightning-dir={}'
1061 .format(l1.daemon.lightning_dir),
1062 '-J', '-k',
1063 'help', 'command=help']).decode('utf-8')
1064 j, _ = json.JSONDecoder().raw_decode(out)
1065 assert 'help [command]' in j['help'][0]['command']
1066
1067 # Test ordered input (autodetect)
1068 out = subprocess.check_output(['cli/lightning-cli',
1069 '--network={}'.format(TEST_NETWORK),
1070 '--lightning-dir={}'
1071 .format(l1.daemon.lightning_dir),
1072 '-J',
1073 'help', 'help']).decode('utf-8')
1074 j, _ = json.JSONDecoder().raw_decode(out)
1075 assert 'help [command]' in j['help'][0]['command']
1076
1077 # Test ordered input (forced)
1078 out = subprocess.check_output(['cli/lightning-cli',
1079 '--network={}'.format(TEST_NETWORK),
1080 '--lightning-dir={}'

Callers

nothing calls this directly

Calls 5

only_oneFunction · 0.90
wait_for_logMethod · 0.80
get_nodeMethod · 0.45
decodeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected