@@ -0,0 +1,2448 @@
+#!/usr/bin/env python3%0A# Copyright (c) 2019 The Bitcoin Core developers%0A# Distributed under the MIT software license, see the accompanying%0A# file COPYING or http://www.opensource.org/licenses/mit-license.php.%0A%0Afrom test_framework.test_framework import BitcoinTestFramework%0A%0A%0Aclass TestShell:%0A    %22%22%22Wrapper Class for BitcoinTestFramework.%0A%0A    The TestShell class extends the BitcoinTestFramework%0A    rpc & daemon process management functionality to external%0A    python environments.%0A%0A    It is a singleton class, which ensures that users only%0A    start a single TestShell at a time.%22%22%22%0A%0A    class __TestShell(BitcoinTestFramework):%0A        def set_test_params(self):%0A            pass%0A%0A        def run_test(self):%0A            pass%0A%0A        def setup(self, **kwargs):%0A            if self.running:%0A                print(%22TestShell is already running!%22)%0A                return%0A%0A            # Num_nodes parameter must be set%0A            # by BitcoinTestFramework child class.%0A            self.num_nodes = kwargs.get('num_nodes', 1)%0A            kwargs.pop('num_nodes', None)%0A%0A            # User parameters override default values.%0A            for key, value in kwargs.items():%0A                if hasattr(self, key):%0A                    setattr(self, key, value)%0A                elif hasattr(self.options, key):%0A                    setattr(self.options, key, value)%0A                else:%0A                    raise KeyError(key + %22 not a valid parameter key!%22)%0A%0A            super().setup()%0A            self.running = True%0A%0A        def shutdown(self):%0A            if not self.running:%0A                print(%22TestShell is not running!%22)%0A            else:%0A                super().shutdown()%0A                self.running = False%0A%0A        def reset(self):%0A            if self.running:%0A                print(%22Shutdown TestWrapper before resetting!%22)%0A            else:%0A                self.num_nodes = None%0A                super().__init__()%0A%0A    instance = None%0A%0A    def __new__(cls):%0A        # This implementation enforces singleton pattern, and will return the%0A        # previously initialized instance if available%0A        if not TestShell.instance:%0A            TestShell.instance = TestShell.__TestShell()%0A            TestShell.instance.running = False%0A        return TestShell.instance%0A%0A    def __getattr__(self, name):%0A        return getattr(self.instance, name)%0A%0A    def __setattr__(self, name, value):%0A        return setattr(self.instance, name, value)%0A

Add TestShell class