def defined_seq_market_actions_api_calls(nb_of_runs):
    time_distribution = []
    total_elapsed_seconds = 0
    for i in range(1, nb_of_runs):
        xbridge_utils.generate_new_set_of_data()
        func_str = ""
        ts = time.time()
        if i % 3 == 0:
            xbridge_client.CHECK_CREATE_TX(xbridge_utils.c_src_Address,
                                           xbridge_utils.c_src_Token,
                                           xbridge_utils.source_nb,
                                           xbridge_utils.c_dest_Address,
                                           xbridge_utils.c_dest_Token,
                                           xbridge_utils.dest_nb)
            func_str = "CHECK_CREATE_TX"
        if i % 3 == 1:
            xbridge_client.CHECK_ACCEPT_TX(xbridge_utils.a_random_tx_id,
                                           xbridge_utils.a_src_Address,
                                           xbridge_utils.a_dest_Address)
            func_str = "CHECK_ACCEPT_TX"
        if i % 3 == 2:
            xbridge_client.CHECK_CANCEL_TX(xbridge_utils.ca_random_tx_id)
            func_str = "CHECK_CANCEL_TX"
        te = time.time()
        total_elapsed_seconds += te - ts
        json_str = {"time": te - ts, "API": func_str}
        time_distribution.append(json_str)
    xbridge_utils.export_data("defined_seq_market_actions_api_calls.xlsx",
                              time_distribution)
 def test_invalid_accept_tx_2(self):
     # Test many combinations of 0 to 10 000 white spaces
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(
             StringGenerator('[\s]{0:10000}').render(),
             StringGenerator('[\s]{0:10000}').render(),
             StringGenerator('[\s]{0:10000}').render()), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX("", self.valid_src_Address,
                                        self.valid_dest_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(self.valid_txid, "",
                                        self.valid_dest_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(self.valid_txid,
                                        self.invalid_src_Address, ""), dict)
     self.assertIsInstance(xbridge_client.CHECK_ACCEPT_TX("", "", ""), dict)
 def invalid_accept_tx_4(self):
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(self.valid_txid,
                                        self.long_src_Address,
                                        self.valid_dest_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(self.long_txid,
                                        self.long_src_Address,
                                        self.valid_dest_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(self.valid_txid,
                                        self.valid_src_Address,
                                        self.long_dest_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(self.long_txid,
                                        self.valid_src_Address,
                                        self.long_dest_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(self.valid_txid,
                                        self.long_src_Address,
                                        self.long_dest_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(self.long_txid,
                                        self.long_src_Address,
                                        self.long_dest_Address), dict)
 def test_invalid_accept_tx_3(self):
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(
             xbridge_utils.generate_input_from_random_classes_combinations(
                 1, 500), self.valid_src_Address, self.valid_dest_Address),
         dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(
             self.valid_txid,
             xbridge_utils.generate_input_from_random_classes_combinations(
                 1, 500), self.valid_dest_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(
             self.valid_txid, self.valid_src_Address,
             xbridge_utils.generate_input_from_random_classes_combinations(
                 1, 500)), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(
             xbridge_utils.generate_input_from_random_classes_combinations(
                 1, 500),
             xbridge_utils.generate_input_from_random_classes_combinations(
                 1, 500),
             xbridge_utils.generate_input_from_random_classes_combinations(
                 1, 500)), dict)
def test_accept_valid_load(nb_of_runs):
    time_distribution = []
    total_elapsed_seconds = 0
    for i in range(1, nb_of_runs):
        tx_id_str = xbridge_utils.generate_random_valid_txid()
        src_Address_str = xbridge_utils.generate_random_valid_address()
        dest_Address_str = xbridge_utils.generate_random_valid_address()
        ts = time.time()
        xbridge_client.CHECK_ACCEPT_TX(tx_id_str, src_Address_str,
                                       dest_Address_str)
        te = time.time()
        total_elapsed_seconds += te - ts
        json_str = {"time": te - ts, "API": "dxAcceptTransaction"}
        time_distribution.append(json_str)
    xbridge_utils.export_data("test_accept_tx_valid_load.xlsx",
                              time_distribution)
def test_accept_garbage_load_v2(nb_of_runs):
    time_distribution = []
    total_elapsed_seconds = 0
    for i in range(1, nb_of_runs):
        tx_id_str = xbridge_utils.generate_input_from_random_classes_combinations(
            1, 10000)
        src_Address_str = xbridge_utils.generate_input_from_random_classes_combinations(
            1, 10000)
        dest_Address_str = xbridge_utils.generate_input_from_random_classes_combinations(
            1, 10000)
        ts = time.time()
        xbridge_client.CHECK_ACCEPT_TX(tx_id_str, src_Address_str,
                                       dest_Address_str)
        te = time.time()
        total_elapsed_seconds += te - ts
        json_str = {"time": te - ts, "API": "dxAcceptTransaction"}
        time_distribution.append(json_str)
    xbridge_utils.export_data("test_accept_garbage_load_v2.xlsx",
                              time_distribution)
 def test_invalid_accept_tx_5(self):
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(invalid_txid,
                                        self.valid_src_Address,
                                        self.valid_src_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(self.valid_txid,
                                        self.valid_src_Address,
                                        self.valid_src_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX("", self.valid_src_Address,
                                        self.valid_src_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(invalid_txid,
                                        self.invalid_src_Address,
                                        self.invalid_src_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX(self.valid_txid,
                                        self.invalid_src_Address,
                                        self.invalid_src_Address), dict)
     self.assertIsInstance(
         xbridge_client.CHECK_ACCEPT_TX("", self.invalid_src_Address,
                                        self.invalid_src_Address), dict)