def register_producers_candidates(self):

        global result
        result = False
        for i in range(
                self.params.ela_params.crc_number + 1,
                self.params.ela_params.number - round(self.params.ela_params.later_start_number / 2) + 1
        ):
            ela_node = self.node_manager.ela_nodes[i]
            public_key = ela_node.node_account.public_key()
            ret = self.register_producer(ela_node)
            if not ret:
                return False
            rpc.discrete_mining(7)

            status = rpc.producer_status(public_key)
            Logger.debug("After mining 7 blocks, register status: {}".format(status))
            result = status == "Active"
            if not result:
                Logger.error("{} register producer {} failed".format(self.tag, ela_node.name))
                break

            Logger.info("{} register node-{} to be a producer on success!\n".format(self.tag, i))

        return result
 def cancel_producers_candidates(self):
     global result
     for producer in self.register_producers_list:
         ret = self.cancel_producer(producer)
         if not ret:
             return False
         rpc.discrete_mining(1)
         status = rpc.producer_status(producer.node.owner_keystore.public_key.hex())
         result = status is "Cancelled"
     return result
def test_content():

    controller = Controller(config)
    will_register_producer = controller.node_manager.ela_nodes[2]
    rpc_port = controller.node_manager.ela_nodes[0].rpc_port
    current_height = controller.get_current_height()
    Logger.debug("current height: {}".format(current_height))

    controller.tx_manager.register_producer(will_register_producer)
    controller.discrete_mining_blocks(1)
    list_producers_nickname = controller.get_list_producers_names()
    producer_status_resp = rpc.producer_status(
        will_register_producer.owner_account.public_key())
    Logger.debug("producers status: {}".format(producer_status_resp))
    producer = controller.tx_manager.register_producers_list[0]
    ret = producer.cancel(rpc_port)
    Logger.debug("cancel producer result: {}".format(ret))
    Logger.info("before cancel list producers: {}".format(list_producers_nickname))
    Logger.info("after cancel list producers:  {}".format(controller.get_list_producers_names()))

    result = len(controller.get_list_producers_names()) != 2
    controller.check_result("cancel pending register list producer has two same nicknames", result)
    controller.terminate_all_process(result)