MCPcopy Create free account
hub / github.com/ElementsProject/elements / run_test

Method run_test

test/functional/rpc_misc.py:24–101  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

22 self.supports_cli = False
23
24 def run_test(self):
25 node = self.nodes[0]
26
27 self.log.info("test CHECK_NONFATAL")
28 assert_raises_rpc_error(
29 -1,
30 'Internal bug detected: \'request.params[9].get_str() != "trigger_internal_bug"\'',
31 lambda: node.echo(arg9='trigger_internal_bug'),
32 )
33
34 self.log.info("test getmemoryinfo")
35 memory = node.getmemoryinfo()['locked']
36 assert_greater_than(memory['used'], 0)
37 assert_greater_than(memory['free'], 0)
38 assert_greater_than(memory['total'], 0)
39 # assert_greater_than_or_equal() for locked in case locking pages failed at some point
40 assert_greater_than_or_equal(memory['locked'], 0)
41 assert_greater_than(memory['chunks_used'], 0)
42 assert_greater_than(memory['chunks_free'], 0)
43 assert_equal(memory['used'] + memory['free'], memory['total'])
44
45 self.log.info("test mallocinfo")
46 try:
47 mallocinfo = node.getmemoryinfo(mode="mallocinfo")
48 self.log.info('getmemoryinfo(mode="mallocinfo") call succeeded')
49 tree = ET.fromstring(mallocinfo)
50 assert_equal(tree.tag, 'malloc')
51 except JSONRPCException:
52 self.log.info('getmemoryinfo(mode="mallocinfo") not available')
53 assert_raises_rpc_error(-8, 'mallocinfo mode not available', node.getmemoryinfo, mode="mallocinfo")
54
55 assert_raises_rpc_error(-8, "unknown mode foobar", node.getmemoryinfo, mode="foobar")
56
57 self.log.info("test logging rpc and help")
58
59 # Test toggling a logging category on/off/on with the logging RPC.
60 assert_equal(node.logging()['qt'], True)
61 node.logging(exclude=['qt'])
62 assert_equal(node.logging()['qt'], False)
63 node.logging(include=['qt'])
64 assert_equal(node.logging()['qt'], True)
65
66 # Test logging RPC returns the logging categories in alphabetical order.
67 sorted_logging_categories = sorted(node.logging())
68 assert_equal(list(node.logging()), sorted_logging_categories)
69
70 # Test logging help returns the logging categories string in alphabetical order.
71 categories = ', '.join(sorted_logging_categories)
72 logging_help = self.nodes[0].help('logging')
73 assert f"valid logging categories are: {categories}" in logging_help
74
75 self.log.info("test echoipc (testing spawned process in multiprocess build)")
76 assert_equal(node.echoipc("hello"), "hello")
77
78 self.log.info("test getindexinfo")
79 # Without any indices running the RPC returns an empty object
80 assert_equal(node.getindexinfo(), {})
81

Callers

nothing calls this directly

Calls 10

assert_raises_rpc_errorFunction · 0.90
assert_greater_thanFunction · 0.90
assert_equalFunction · 0.90
infoMethod · 0.80
echoMethod · 0.80
helpMethod · 0.80
joinMethod · 0.45
restart_nodeMethod · 0.45
wait_untilMethod · 0.45

Tested by

no test coverage detected