(functional_tests_dir)
| 18 | # Test matching the minimal example from the documentation. Should be kept |
| 19 | # in sync with the interactive shell instructions ('>>> ') in test-shell.md. |
| 20 | def 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 | |
| 51 | if __name__ == "__main__": |
no test coverage detected