def generate_go_ethereum_fixture(destination_dir):
    with contextlib.ExitStack() as stack:
        datadir = stack.enter_context(tempdir())

        keystore_dir = os.path.join(datadir, 'keystore')
        ensure_path_exists(keystore_dir)
        keyfile_path = os.path.join(keystore_dir, KEYFILE_FILENAME)
        with open(keyfile_path, 'w') as keyfile:
            keyfile.write(KEYFILE_DATA)
        genesis_file_path = os.path.join(datadir, 'genesis.json')
        with open(genesis_file_path, 'w') as genesis_file:
            genesis_file.write(json.dumps(GENESIS_DATA))

        geth_ipc_path_dir = stack.enter_context(tempdir())
        geth_ipc_path = os.path.join(geth_ipc_path_dir, 'geth.ipc')

        geth_port = get_open_port()
        geth_binary = get_geth_binary()

        with get_geth_process(
                geth_binary=geth_binary,
                datadir=datadir,
                genesis_file_path=genesis_file_path,
                geth_ipc_path=geth_ipc_path,
                geth_port=geth_port):

            wait_for_socket(geth_ipc_path)
            web3 = Web3(Web3.IPCProvider(geth_ipc_path))
            chain_data = setup_chain_state(web3)
            # close geth by exiting context
            # must be closed before copying data dir
            verify_chain_state(web3, chain_data)

        # verify that chain state is still valid after closing
        # and re-opening geth
        with get_geth_process(
                geth_binary=geth_binary,
                datadir=datadir,
                genesis_file_path=genesis_file_path,
                geth_ipc_path=geth_ipc_path,
                geth_port=geth_port):

            wait_for_socket(geth_ipc_path)
            web3 = Web3(Web3.IPCProvider(geth_ipc_path))
            verify_chain_state(web3, chain_data)

        static_data = {
            'raw_txn_account': RAW_TXN_ACCOUNT,
            'keyfile_pw': KEYFILE_PW,
        }
        config = merge(chain_data, static_data)
        pprint.pprint(config)
        write_config_json(config, datadir)

        shutil.make_archive(destination_dir, 'zip', datadir)
示例#2
0
    def setUp(self):
        port = get_open_port()
        self.jr = PoppyErgoJr(simulator='poppy-simu', use_ws=True, ws_port=port)

        self.ws_url = 'ws://127.0.0.1:{}'.format(port)

        while True:
            try:
                self.ws = websocket.WebSocket()
                self.ws.connect(self.ws_url)
                break
            except ConnectionError:
                time.sleep(1.0)
示例#3
0
    def setUp(self):
        port = get_open_port()

        self.jr = PoppyErgoJr(simulator='poppy-simu', use_snap=True, snap_port=port)
        self.base_url = 'http://127.0.0.1:{}'.format(port)

        # Make sure the Snap API is running before actually testing.
        while True:
            try:
                self.get('/')
                break
            except requests.exceptions.ConnectionError:
                time.sleep(1)
示例#4
0
    def setUp(self):
        port = get_open_port()
        self.jr = PoppyErgoJr(simulator='poppy-simu', use_ws=True, ws_port=port)

        self.ws_url = 'ws://127.0.0.1:{}'.format(port)

        while True:
            try:
                self.ws = websocket.WebSocket()
                self.ws.connect(self.ws_url)
                break
            except ConnectionError:
                time.sleep(1.0)
示例#5
0
    def setUp(self):
        port = get_open_port()

        self.jr = PoppyErgoJr(simulator='poppy-simu',
                              use_snap=True,
                              snap_port=port)
        self.base_url = 'http://127.0.0.1:{}'.format(port)

        # Make sure the Snap API is running before actually testing.
        while True:
            try:
                self.get('/')
                break
            except requests.exceptions.ConnectionError:
                time.sleep(1)
示例#6
0
Module for running tests on the functions contained in this package.

"""

import sys
from interface import getdata
from utils import get_open_port, add_sumo_tools_to_path
from runsim import launch_sumo_process

add_sumo_tools_to_path()

import traci

if __name__ == "__main__":

    traci_port = get_open_port()

    sumo_config_file = 'test_scenario/test.sumocfg'

    sumo_subprocess = launch_sumo_process(sumo_config_file,
                                          traci_port,
                                          sumo_binary="sumo-gui",
                                          gui_on=False)

    lane_sub = getdata.LaneSubscription()
    lane_sub.activate_subscription()

    # initialise the step
    step = 0

    # run the simulation
示例#7
0
                    type=str)
parser.add_argument('-f',
                    '--experiment_files',
                    help="(string) The path of an experiment file to open",
                    default=None,
                    type=str)
args = parser.parse_args()

if args.experiment_dir:
    doc.add_timeout_callback(
        lambda: display_directory_group(args.experiment_dir), 1000)
elif args.experiment_files:
    files = []
    for file_pattern in args.experiment_files:
        files.extend(glob.glob(args.experiment_files))
    doc.add_timeout_callback(lambda: display_files(files), 1000)

if __name__ == "__main__":
    from utils import get_open_port

    command = 'bokeh serve --show dashboard.py --port {}'.format(
        get_open_port())
    if args.experiment_dir or args.experiment_files:
        command += ' --args'
        if args.experiment_dir:
            command += ' --experiment_dir {}'.format(args.experiment_dir)
        if args.experiment_files:
            command += ' --experiment_files {}'.format(args.experiment_files)

    os.system(command)