コード例 #1
0
def test_chain_config_nodekey_loading(nodekey_bytes, nodekey_path):
    chain_config = ChainConfig(
        network_id=1,
        nodekey_path=nodekey_path,
    )

    assert chain_config.nodekey.to_bytes() == nodekey_bytes
コード例 #2
0
def test_chain_config_explictely_provided_nodekey(nodekey_bytes, as_bytes):
    chain_config = ChainConfig(
        network_id=1,
        nodekey=nodekey_bytes if as_bytes else keys.PrivateKey(nodekey_bytes),
    )

    assert chain_config.nodekey.to_bytes() == nodekey_bytes
コード例 #3
0
def test_chain_config_explicit_properties():
    chain_config = ChainConfig(network_id=1,
                               data_dir='./data-dir',
                               nodekey_path='./nodekey')

    assert chain_config.data_dir == Path('./data-dir').resolve()
    assert chain_config.nodekey_path == Path('./nodekey').resolve()
コード例 #4
0
def get_chain_context(base_db, privkey):
    chain = FakeAsyncTestnetChain(base_db,
                                  privkey.public_key.to_canonical_address(),
                                  privkey)
    chaindb = FakeAsyncChainDB(base_db)
    chain_head_db = FakeAsyncChainHeadDB.load_from_saved_root_hash(base_db)
    consensus_db = FakeAsyncConsensusDB(chaindb)

    chain_config = ChainConfig(network_id=TESTNET_NETWORK_ID)
    chain_config._node_private_helios_key = privkey
    chain_config.num_chain_processes = 1

    network_id = TESTNET_NETWORK_ID
    vm_configuration = tuple()

    chain_context = ChainContext(
        base_db=base_db,
        chains=[chain],
        chaindb=chaindb,
        chain_head_db=chain_head_db,
        consensus_db=consensus_db,
        chain_config=chain_config,
        network_id=network_id,
        vm_configuration=vm_configuration,
    )
    return chain_context
コード例 #5
0
def test_chain_config_computed_properties(xdg_helios_root):
    data_dir = get_local_data_dir('muffin', xdg_helios_root)
    chain_config = ChainConfig(network_id=1234, data_dir=data_dir)

    assert chain_config.network_id == 1234
    assert chain_config.data_dir == data_dir
    assert chain_config.database_dir == data_dir / DATABASE_DIR_NAME / "full"
    assert chain_config.nodekey_path == get_nodekey_path(data_dir)
コード例 #6
0
def test_chain_config_computed_properties_custom_xdg(tmpdir, xdg_helios_root):
    alt_xdg_root = tmpdir.mkdir('helios-custom')
    assert not is_under_path(alt_xdg_root, xdg_helios_root)

    data_dir = get_data_dir_for_network_id(1, alt_xdg_root)
    chain_config = ChainConfig(helios_root_dir=alt_xdg_root, network_id=1)

    assert chain_config.network_id == 1
    assert chain_config.data_dir == data_dir
    assert chain_config.database_dir == data_dir / DATABASE_DIR_NAME / "full"
    assert chain_config.nodekey_path == get_nodekey_path(data_dir)
コード例 #7
0
def database_server_ipc_path():
    core_db = AtomicDB()
    core_db[b'key-a'] = b'value-a'

    chaindb = ChainDB(core_db)
    # TODO: use a custom chain class only for testing.
    chaindb.persist_header(ROPSTEN_GENESIS_HEADER)

    with tempfile.TemporaryDirectory() as temp_dir:
        chain_config = ChainConfig(network_id=ROPSTEN_NETWORK_ID, max_peers=1, data_dir=temp_dir)

        manager = get_chaindb_manager(chain_config, core_db)
        chaindb_server_process = multiprocessing.Process(
            target=serve_chaindb,
            args=(manager,),
        )
        chaindb_server_process.start()

        wait_for_ipc(chain_config.database_ipc_path)

        try:
            yield chain_config.database_ipc_path
        finally:
            kill_process_gracefully(chaindb_server_process, logging.getLogger())
コード例 #8
0
def chain_config():
    return ChainConfig(network_id=1, max_peers=1)
コード例 #9
0
def chain_config():
    _chain_config = ChainConfig(network_id=1, max_peers=1)
    initialize_data_dir(_chain_config)
    return _chain_config