def test_network_gen_operations_and_add_nodes( self, sandbox_multibranch: SandboxMultiBranch, session: dict): 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 test_setup_network(self, sandbox_multibranch: SandboxMultiBranch): # Set appropriate time to avoid double-baking for i in range(NUM_NODES): sandbox_multibranch.add_node(i, params=params(i)) parameters = dict(constants.ALPHA_PARAMETERS) parameters["time_between_blocks"] = ["10", "0"] sandbox_multibranch.client(0).activate_protocol_json(ALPHA, parameters) sandbox_multibranch.add_baker(0, 'bootstrap5', proto=ALPHA_DAEMON) sandbox_multibranch.add_baker(1, 'bootstrap4', proto=ALPHA_DAEMON) sandbox_multibranch.add_endorser(0, account='bootstrap1', endorsement_delay=1, proto=ALPHA_DAEMON) sandbox_multibranch.add_endorser(1, account='bootstrap2', endorsement_delay=1, proto=ALPHA_DAEMON)