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

Function update_example

tests/autogenerate-rpc-examples.py:398–420  ·  view source on GitHub ↗

Add example request, response and other details in json array for future use

(node, method, params, response=None, description=None)

Source from the content-addressed store, hash-verified

396
397
398def update_example(node, method, params, response=None, description=None):
399 """Add example request, response and other details in json array for future use"""
400 method_examples = EXAMPLES_JSON.get(method, {'examples': []})
401 method_id = len(method_examples['examples']) + 1
402 req = {
403 'id': f'example:{method}#{method_id}',
404 'method': method,
405 'params': params
406 }
407 logger.info(f'Method \'{method}\', Params {params}')
408 # Execute the RPC call and get the response
409 if response is None:
410 response = node.rpc.call(method, params)
411 logger.info(f'{method} response: {response}')
412 # Return response without updating the file because user doesn't want to update the example
413 # Executing the method and returning the response is useful for further example updates
414 if method not in REGENERATING_RPCS:
415 return response
416 else:
417 method_examples['examples'].append({'request': req, 'response': response} if description is None else {'description': description, 'request': req, 'response': response})
418 EXAMPLES_JSON[method] = method_examples
419 logger.info(f'Updated {method}#{method_id} example json')
420 return response
421
422
423def setup_test_nodes(node_factory, bitcoind):

Callers 15

setup_test_nodesFunction · 0.85
generate_runes_examplesFunction · 0.85
generate_wait_examplesFunction · 0.85
generate_utils_examplesFunction · 0.85
generate_splice_examplesFunction · 0.85

Calls 2

getMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected