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 setUp(self): xbridge_utils.generate_new_set_of_data( data_nature=xbridge_utils.INVALID_DATA, char_min_size=1, char_max_size=10000) # Valid data self.valid_txid = xbridge_utils.generate_random_valid_txid() self.valid_src_Address = xbridge_utils.generate_random_valid_address() self.valid_dest_Address = xbridge_utils.generate_random_valid_address() # Invalid data from garbage character classes self.invalid_txid = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 5000)) self.invalid_src_Address = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 5000)) self.invalid_dest_Address = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 5000)) self.long_txid = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(10000, 12000)) self.long_src_Address = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(10000, 12000)) self.long_dest_Address = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(10000, 12000)) # Invalid data from random character classes self.input_str_from_random_classes_1 = xbridge_utils.generate_input_from_random_classes_combinations( 1, 4000) self.input_str_from_random_classes_2 = xbridge_utils.generate_input_from_random_classes_combinations( 9000, 12000) self.input_str_from_random_classes_3 = xbridge_utils.generate_input_from_random_classes_combinations( 1, 100) valid_token = xbridge_utils.generate_random_valid_token() self.token_pool = [valid_token, xbridge_utils.c_src_Token] valid_address = xbridge_utils.generate_random_valid_address() invalid_address_short = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 40)) invalid_address_med = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 5000)) invalid_address_long = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(5000, 15000)) self.address_pool = [ valid_address, invalid_address_short, invalid_address_med, invalid_address_long ] # Test many combinations of 0 to 10 000 white spaces self.simple_whitespace = "" self.whitespace_str_1 = StringGenerator('[\s]{1:10000}').render() self.whitespace_str_2 = StringGenerator('[\s]{1:10000}').render() self.whitespace_str_3 = StringGenerator('[\s]{1:10000}').render() self.whitespace_pool = [ self.simple_whitespace, self.whitespace_str_1, self.whitespace_str_2, self.whitespace_str_3 ]
def setUp(self): xbridge_utils.generate_new_set_of_data( data_nature=xbridge_utils.INVALID_DATA, char_min_size=1, char_max_size=10000) # Valid data self.valid_src_Token = xbridge_utils.generate_random_valid_token() self.valid_dest_Token = xbridge_utils.generate_random_valid_token() # Common pools from which parameters will be randomnly picked self.valid_token = xbridge_utils.generate_random_valid_token() self.token_pool = [self.valid_token, xbridge_utils.c_src_Token] self.invalid_short_str = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 40)) self.invalid_med_str = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 5000)) self.invalid_long_str = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(5000, 15000))
def setUp(self): xbridge_utils.generate_new_set_of_data( data_nature=xbridge_utils.INVALID_DATA, char_min_size=1, char_max_size=10000) # Valid data self.valid_txid = xbridge_utils.generate_random_valid_txid() self.valid_src_Token = xbridge_utils.generate_random_valid_token() self.valid_dest_Token = xbridge_utils.generate_random_valid_token() self.valid_src_Address = xbridge_utils.generate_random_valid_address() self.valid_dest_Address = xbridge_utils.generate_random_valid_address() self.valid_positive_nb_1 = xbridge_utils.generate_random_number( 1, 10000) self.valid_positive_nb_2 = xbridge_utils.generate_random_number( 1, 10000) # Invalid data self.invalid_neg_nb = xbridge_utils.generate_random_number( -99999999999999999999999999999999999999999999999, -0.0000000000000000000000000000000000000000000000000001) self.invalid_sm_positive_nb = xbridge_utils.generate_random_number( 0.000000000000000000000000001, 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 ) self.invalid_lg_positive_nb = xbridge_utils.generate_random_number( 9999999999999999999999999999999999, 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 ) self.invalid_src_Address = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 5000)) self.invalid_dest_Address = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 5000)) self.invalid_src_Token = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 500)) self.invalid_dest_Token = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 500)) self.nb_with_leading_zeros_1 = xbridge_utils.generate_random_number_with_leading_zeros( ) self.nb_with_leading_zeros_2 = xbridge_utils.generate_random_number_with_leading_zeros( ) # Common pools from which parameters will be randomnly picked valid_token = xbridge_utils.generate_random_valid_token() self.token_pool = [valid_token, xbridge_utils.c_src_Token] valid_address = xbridge_utils.generate_random_valid_address() invalid_address_short = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 40)) invalid_address_med = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(1, 5000)) invalid_address_long = xbridge_utils.generate_garbage_input( xbridge_utils.generate_random_number(5000, 15000)) self.address_pool = [ valid_address, invalid_address_short, invalid_address_med, invalid_address_long ] self.amount_pool = [ xbridge_utils.invalid_random_positive_float, xbridge_utils.valid_random_positive_float, -xbridge_utils.invalid_random_positive_float, -xbridge_utils.valid_random_positive_float, xbridge_utils.fixed_small_positive_float, xbridge_utils.fixed_large_positive_int, 0 ]
def setUp(self): xbridge_utils.generate_new_set_of_data( data_nature=xbridge_utils.INVALID_DATA, char_min_size=1, char_max_size=10000)
def test_autocombinerewards_valid(self): try: if xbridge_config.get_wallet_decryption_passphrase() == "": return valid_passphrase = xbridge_config.get_wallet_decryption_passphrase( ) random_int = xbridge_utils.generate_random_int( -999999999999, 999999999999) xbridge_rpc.walletpassphrase(valid_passphrase, random_int, False) log_json = "" success_str = "Auto Combine Rewards Threshold Set" xbridge_utils.generate_new_set_of_data( data_nature=xbridge_utils.VALID_DATA) self.assertEqual( xbridge_rpc.rpc_connection.autocombinerewards(False), success_str) self.assertEqual( xbridge_rpc.rpc_connection.autocombinerewards( False, -99999999999999), success_str) self.assertEqual( xbridge_rpc.rpc_connection.autocombinerewards(True, 0), success_str) self.assertEqual( xbridge_rpc.rpc_connection.autocombinerewards( True, xbridge_utils.valid_random_positive_int), success_str) self.assertEqual( xbridge_rpc.rpc_connection.autocombinerewards( True, -xbridge_utils.valid_random_positive_int), success_str) log_json = { "group": "test_autocombinerewards_valid", "success": 1, "failure": 0, "error": 0 } xbridge_utils.ERROR_LOG.append(log_json) except AssertionError as ass_err: log_json = { "group": "test_autocombinerewards_valid", "success": 0, "failure": 1, "error": 0 } xbridge_utils.ERROR_LOG.append(log_json) xbridge_logger.logger.info( 'test_autocombinerewards_valid FAILED: %s' % ass_err) if MAX_LOG_LENGTH > 0: xbridge_logger.logger.info( 'fixed_positive_int: %s \n' % str(xbridge_utils.fixed_positive_int)) xbridge_logger.logger.info( 'fixed_negative_int: %s \n' % str(xbridge_utils.fixed_negative_int)) xbridge_logger.logger.info( 'valid_random_positive_int: %s \n' % str(xbridge_utils.valid_random_positive_int)) except JSONRPCException as json_excpt: log_json = { "group": "test_autocombinerewards_valid", "success": 0, "failure": 0, "error": 1 } xbridge_utils.ERROR_LOG.append(log_json) xbridge_logger.logger.info( 'test_autocombinerewards_valid ERROR: %s' % json_excpt)