def test_network_gen_operations_and_add_nodes(self, sandbox_multibranch, session): node_add_period = NUM_CYCLES // NEW_NODES for cycle in range(NUM_CYCLES): i = random.randrange(NUM_NODES) client = sandbox_multibranch.client(i) try: transfer = random_op(client) session[f'op{cycle}'] = transfer.operation_hash except subprocess.CalledProcessError: # some operations may be invalid, e.g. the client sends # several operation with the same counter print('# IGNORED INVALID OPERATION') if cycle % node_add_period == 0: # add node running_nodes = list(sandbox_multibranch.nodes.keys()) new_node = max(running_nodes) + 1 if REPLACE: running_nodes.remove(0) running_nodes.remove(1) sandbox_multibranch.rm_node(random.choice(running_nodes)) sandbox_multibranch.add_node(new_node, params=params(new_node)) proto = ALPHA assert utils.check_protocol( sandbox_multibranch.client(new_node), proto) time.sleep(TIME_BETWEEN_CYCLE)
def clients(sandbox: Sandbox, request) -> Iterator[List[Client]]: """N node with protocol alpha. Parameterized by the number of nodes. Number of nodes is specified as a class annotation. @pytest.mark.parametrize('clients', [N], indirect=True) Activate protocol alpha one year in the past. (see fixture client). """ assert request.param is not None num_nodes = request.param for i in range(num_nodes): # Large number may increases peers connection time sandbox.add_node(i, params=constants.NODE_PARAMS) parameters = protocol.get_parameters() parameters['consensus_threshold'] = 0 parameters['round_durations'] = {"round0": '1', "round1": '1'} protocol.activate( sandbox.client(0), parameters=parameters, activate_in_the_past=True ) clients = sandbox.all_clients() for client in clients: proto = protocol.HASH assert utils.check_protocol(client, proto) yield clients
def clients(sandbox: Sandbox, request) -> Iterator[List[Client]]: """N node with protocol alpha. Parameterized by the number of nodes. Number of nodes is specified as a class annotation. @pytest.mark.parametrize('clients', [N], indirect=True) """ assert request.param is not None num_nodes = request.param for i in range(num_nodes): # Large number may increases peers connection time sandbox.add_node(i, params=constants.NODE_PARAMS) utils.activate_alpha(sandbox.client(0)) clients = sandbox.all_clients() for client in clients: proto = constants.ALPHA assert utils.check_protocol(client, proto) yield clients
def test_check_protocol(self, clients, session): proto = session['proto_hash'] params = ['-p', 'ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im'] for client in clients: assert utils.check_protocol(client, proto, params=params)
def test_wait_sync_proto(self, sandbox, session): session['head_hash'] = sandbox.client(0).get_head()['hash'] clients = sandbox.all_clients() for client in clients: proto = constants.ALPHA assert utils.check_protocol(client, proto)
def test_wait_for_alpha(self, sandbox_multibranch): clients = sandbox_multibranch.all_clients() for client in clients: proto = ALPHA assert utils.check_protocol(client, proto)
def test_wait_for_protocol(self, sandbox: Sandbox): clients = sandbox.all_clients() for client in clients: proto = protocol.HASH assert utils.check_protocol(client, proto) assert client.get_level() == 1
def test_check_protocol(self, clients: List[Client], session: dict): proto = session['proto_hash'] for client in clients: assert utils.check_protocol(client, proto, params=PARAMS)
def test_wait_sync_proto(self, sandbox): clients = sandbox.all_clients() for client in clients: proto = constants.ALPHA assert utils.check_protocol(client, proto)
def test_wait_for_alpha(self, sandbox: Sandbox): clients = sandbox.all_clients() for client in clients: proto = protocol.HASH assert utils.check_protocol(client, proto)