Beispiel #1
0
async def setup_n_nodes(consensus_constants: ConsensusConstants, n: int):
    """
    Setup and teardown of n full nodes, with blockchains and separate DBs.
    """
    port_start = 21244
    node_iters = []
    keyrings_to_cleanup = []
    for i in range(n):
        keyring = TempKeyring()
        keyrings_to_cleanup.append(keyring)
        node_iters.append(
            setup_full_node(
                consensus_constants,
                f"blockchain_test_{i}.db",
                port_start + i,
                await create_block_tools_async(constants=test_constants, keychain=keyring.get_keychain()),
                simulator=False,
            )
        )
    nodes = []
    for ni in node_iters:
        nodes.append(await ni.__anext__())

    yield nodes

    await _teardown_nodes(node_iters)

    for keyring in keyrings_to_cleanup:
        keyring.cleanup()
Beispiel #2
0
from tests.blockchain.blockchain_test_utils import (
    _validate_and_add_block,
    _validate_and_add_block_multi_result,
    _validate_and_add_block_no_error,
)
from tests.setup_nodes import test_constants as test_constants_original
from tests.util.blockchain import create_blockchain
from tests.util.keyring import TempKeyring


def cleanup_keyring(keyring: TempKeyring):
    keyring.cleanup()


temp_keyring = TempKeyring()
keychain = temp_keyring.get_keychain()
atexit.register(cleanup_keyring,
                temp_keyring)  # Attempt to cleanup the temp keychain
test_constants = test_constants_original.replace(
    **{
        "DISCRIMINANT_SIZE_BITS": 32,
        "SUB_SLOT_ITERS_STARTING": 2**12
    })
bt = create_block_tools(constants=test_constants, keychain=keychain)


@pytest.fixture(scope="session")
def event_loop():
    loop = asyncio.get_event_loop()
    yield loop
Beispiel #3
0
import atexit
import json

import aiohttp
import pytest


def cleanup_keyring(keyring: TempKeyring):
    keyring.cleanup()


temp_keyring1 = TempKeyring()
temp_keyring2 = TempKeyring()
atexit.register(cleanup_keyring, temp_keyring1)
atexit.register(cleanup_keyring, temp_keyring2)
b_tools = create_block_tools(constants=test_constants_modified, keychain=temp_keyring1.get_keychain())
b_tools_1 = create_block_tools(constants=test_constants_modified, keychain=temp_keyring2.get_keychain())
new_config = b_tools._config
new_config["daemon_port"] = 55401
b_tools.change_config(new_config)


class TestDaemon:
    @pytest.fixture(scope="function")
    async def get_daemon(self):
        async for _ in setup_daemon(btools=b_tools):
            yield _

    @pytest.fixture(scope="function")
    async def simulation(self):
        async for _ in setup_full_system(