MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / run_testshell_doc_example

Function run_testshell_doc_example

test/functional/feature_framework_testshell.py:20–48  ·  view source on GitHub ↗
(functional_tests_dir)

Source from the content-addressed store, hash-verified

18# Test matching the minimal example from the documentation. Should be kept
19# in sync with the interactive shell instructions ('>>> ') in test-shell.md.
20def run_testshell_doc_example(functional_tests_dir):
21 import sys
22 sys.path.insert(0, functional_tests_dir)
23 from test_framework.test_shell import TestShell
24 from test_framework.util import assert_equal
25
26 test = TestShell().setup(num_nodes=2, setup_clean_chain=True)
27 try:
28 assert test is not None
29 stdout_buf = StringIO()
30 with redirect_stdout(stdout_buf):
31 test2 = TestShell().setup()
32 assert test2 is None
33 assert_equal(stdout_buf.getvalue().rstrip(), "TestShell is already running!")
34 assert_equal(test.nodes[0].getblockchaininfo()["blocks"], 0)
35 if test.is_wallet_compiled():
36 res = test.nodes[0].createwallet('default')
37 assert_equal(res, {'name': 'default'})
38 address = test.nodes[0].getnewaddress()
39 res = test.generatetoaddress(test.nodes[0], 101, address)
40 assert_equal(len(res), 101)
41 test.sync_blocks()
42 assert_equal(test.nodes[1].getblockchaininfo()["blocks"], 101)
43 assert_equal(test.nodes[0].getbalance(), Decimal('50.0'))
44 test.nodes[0].log.info("Successfully mined regtest chain!")
45 finally:
46 test.shutdown()
47 test.reset()
48 assert test.num_nodes is None
49
50
51if __name__ == "__main__":

Callers 1

Calls 11

TestShellClass · 0.90
assert_equalFunction · 0.90
is_wallet_compiledMethod · 0.80
getnewaddressMethod · 0.80
sync_blocksMethod · 0.80
infoMethod · 0.80
insertMethod · 0.45
setupMethod · 0.45
generatetoaddressMethod · 0.45
shutdownMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected