(node_factory)
| 1225 | |
| 1226 | |
| 1227 | def test_cli_commando(node_factory): |
| 1228 | l1, l2 = node_factory.line_graph(2, fundchannel=False, |
| 1229 | opts={'log-level': 'io'}) |
| 1230 | rune = l2.rpc.createrune()['rune'] |
| 1231 | |
| 1232 | # Invalid peer id. |
| 1233 | val = subprocess.run(['cli/lightning-cli', |
| 1234 | '--commando=00', |
| 1235 | '--network={}'.format(TEST_NETWORK), |
| 1236 | '--lightning-dir={}' |
| 1237 | .format(l1.daemon.lightning_dir), |
| 1238 | 'help']) |
| 1239 | assert val.returncode == 3 |
| 1240 | |
| 1241 | # Valid peer id, but needs rune! |
| 1242 | val = subprocess.run(['cli/lightning-cli', |
| 1243 | '--commando={}'.format(l2.info['id']), |
| 1244 | '--network={}'.format(TEST_NETWORK), |
| 1245 | '--lightning-dir={}' |
| 1246 | .format(l1.daemon.lightning_dir), |
| 1247 | 'help']) |
| 1248 | assert val.returncode == 1 |
| 1249 | |
| 1250 | # This works! |
| 1251 | out = subprocess.check_output(['cli/lightning-cli', |
| 1252 | '--commando={}:{}'.format(l2.info['id'], rune), |
| 1253 | '--network={}'.format(TEST_NETWORK), |
| 1254 | '--lightning-dir={}' |
| 1255 | .format(l1.daemon.lightning_dir), |
| 1256 | 'help']).decode('utf-8') |
| 1257 | # Test some known output. |
| 1258 | assert 'addgossip message\n\naddoutpointwatch' in out |
| 1259 | |
| 1260 | # Check JSON id is as expected |
| 1261 | l1.daemon.wait_for_log(r'jsonrpc#[0-9]*: "cli:help#[0-9]*"\[IN\]') |
| 1262 | |
| 1263 | # And through l2... |
| 1264 | l2.daemon.wait_for_log(r'jsonrpc#[0-9]*: "cli:help#[0-9]*/cln:commando#[0-9]*/commando:help#[0-9]*"\[IN\]') |
| 1265 | |
| 1266 | # Test keyword input (forced) |
| 1267 | out = subprocess.check_output(['cli/lightning-cli', |
| 1268 | '--commando={}:{}'.format(l2.info['id'], rune), |
| 1269 | '--network={}'.format(TEST_NETWORK), |
| 1270 | '--lightning-dir={}' |
| 1271 | .format(l1.daemon.lightning_dir), |
| 1272 | '-J', '-k', |
| 1273 | 'help', 'command=help']).decode('utf-8') |
| 1274 | j, _ = json.JSONDecoder().raw_decode(out) |
| 1275 | assert 'help [command]' in j['help'][0]['command'] |
| 1276 | |
| 1277 | # Test ordered input (forced) |
| 1278 | out = subprocess.check_output(['cli/lightning-cli', |
| 1279 | '--commando={}:{}'.format(l2.info['id'], rune), |
| 1280 | '--network={}'.format(TEST_NETWORK), |
| 1281 | '--lightning-dir={}' |
| 1282 | .format(l1.daemon.lightning_dir), |
| 1283 | '-J', '-o', |
| 1284 | 'help', 'help']).decode('utf-8') |
nothing calls this directly
no test coverage detected