コード例 #1
0
 def test_invalid_create_tx_v0(self):
     for i in range(subTest_count):
         with self.subTest("random garbage"):
             try:
                 src_Address = random.choice(
                     xbridge_utils.set_of_invalid_parameters)
                 dest_Address = random.choice(
                     xbridge_utils.set_of_invalid_parameters)
                 src_Token = random.choice(
                     xbridge_utils.set_of_invalid_parameters)
                 dest_Token = random.choice(
                     xbridge_utils.set_of_invalid_parameters)
                 fromAmount = random.choice(
                     xbridge_utils.set_of_invalid_parameters)
                 toAmount = random.choice(
                     xbridge_utils.set_of_invalid_parameters)
                 self.assertIsInstance(
                     xbridge_rpc.create_tx(src_Address, src_Token,
                                           fromAmount, dest_Address,
                                           dest_Token, toAmount), dict)
                 xbridge_logger.XLOG("test_invalid_create_tx_v0", 0)
             except AssertionError as ass_err:
                 xbridge_logger.XLOG("test_invalid_create_tx_v0", 1,
                                     ass_err, [
                                         src_Address, src_Token, fromAmount,
                                         dest_Address, dest_Token, toAmount
                                     ])
             except JSONRPCException as json_excpt:
                 xbridge_logger.XLOG("test_invalid_create_tx_v0", 2,
                                     json_excpt, [
                                         src_Address, src_Token, fromAmount,
                                         dest_Address, dest_Token, toAmount
                                     ])
コード例 #2
0
 def test_invalid_create_tx_v2(self):
     try:
         new_address = xbridge_utils.generate_random_valid_address()
         self.assertIsInstance(
             xbridge_rpc.create_tx(" ", self.valid_src_Token,
                                   self.valid_positive_nb_1,
                                   self.valid_dest_Address,
                                   self.valid_dest_Token,
                                   self.valid_positive_nb_2), dict)
         self.assertIsInstance(
             xbridge_rpc.create_tx(new_address, self.valid_src_Token,
                                   self.valid_positive_nb_1, " ",
                                   self.valid_dest_Token,
                                   self.valid_positive_nb_2), dict)
         self.assertIsInstance(
             xbridge_rpc.create_tx(" ", self.valid_src_Token,
                                   self.valid_positive_nb_1, " ",
                                   self.valid_dest_Token,
                                   self.valid_positive_nb_2), dict)
         xbridge_logger.XLOG("test_invalid_create_tx_v2", 0)
     except AssertionError as ass_err:
         xbridge_logger.XLOG("test_invalid_create_tx_v2", 1, ass_err)
         if MAX_LOG_LENGTH > 0:
             xbridge_logger.logger.info('new_address: %s',
                                        str(new_address)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_dest_Address: %s',
                 str(self.valid_dest_Address)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_dest_Token: %s',
                 str(self.valid_dest_Token)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_dest_Address: %s',
                 str(self.valid_dest_Address)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_positive_nb_1: %s',
                 str(self.valid_positive_nb_1)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_positive_nb_2: %s',
                 str(self.valid_positive_nb_2)[:MAX_LOG_LENGTH])
コード例 #3
0
 def test_invalid_create_tx_v4(self):
     for i in range(subTest_count):
         with self.subTest("combinations"):
             try:
                 address_with_quotes_1 = "'" + str(
                     xbridge_utils.generate_random_valid_address()) + "'"
                 address_with_quotes_2 = "'" + str(
                     xbridge_utils.generate_random_valid_address()) + "'"
                 address_wo_quotes = str(
                     xbridge_utils.generate_random_valid_address())
                 src_Address = random.choice([
                     address_wo_quotes, address_with_quotes_1,
                     address_with_quotes_2
                 ])
                 dest_Address = random.choice([
                     address_wo_quotes, address_with_quotes_1,
                     address_with_quotes_2
                 ])
                 if (src_Address
                         == address_wo_quotes) and (dest_Address
                                                    == address_wo_quotes):
                     if random.choice(True, False) is True:
                         src_Address = random.choice(
                             [address_with_quotes_1, address_with_quotes_2])
                     else:
                         dest_Address = random.choice(
                             [address_with_quotes_1, address_with_quotes_2])
                 src_Token = random.choice(self.token_pool)
                 dest_Token = random.choice(self.token_pool)
                 src_Amount = random.choice(self.amount_pool)
                 dest_Amount = random.choice(self.amount_pool)
                 param_vector = [
                     src_Address, src_Token, src_Amount, src_Address,
                     dest_Token, dest_Amount
                 ]
                 # for param in param_vector:
                 #     print("test_invalid_create_tx_v4 param: %s" % (str(param)[:10]))
                 self.assertIsInstance(
                     xbridge_rpc.create_tx(src_Address, src_Token,
                                           src_Amount, src_Address,
                                           dest_Token, dest_Amount), dict)
                 xbridge_logger.XLOG("test_invalid_create_tx_v4", 0)
             except AssertionError as ass_err:
                 xbridge_logger.XLOG("test_invalid_create_tx_v4", 1,
                                     ass_err, param_vector)
             except JSONRPCException as json_excpt:
                 xbridge_logger.XLOG("test_invalid_create_tx_v4", 2,
                                     json_excpt, param_vector)
コード例 #4
0
 def test_invalid_create_tx_v11(self):
     try:
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.valid_src_Address,
                                   self.valid_src_Token,
                                   self.invalid_lg_positive_nb,
                                   self.valid_dest_Address,
                                   self.valid_dest_Token,
                                   self.invalid_lg_positive_nb), dict)
         xbridge_logger.XLOG("test_invalid_create_tx_v11", 0)
     except AssertionError as ass_err:
         xbridge_logger.XLOG("test_invalid_create_tx_v11", 1, ass_err, [
             self.valid_src_Address, self.valid_src_Token,
             self.invalid_lg_positive_nb, self.valid_dest_Address,
             self.valid_dest_Token, self.invalid_lg_positive_nb
         ])
     except JSONRPCException as json_excpt:
         xbridge_logger.XLOG("test_invalid_create_tx_v11", 2, json_excpt, [
             self.valid_src_Address, self.valid_src_Token,
             self.invalid_lg_positive_nb, self.valid_dest_Address,
             self.valid_dest_Token, self.invalid_lg_positive_nb
         ])
コード例 #5
0
 def test_invalid_create_tx_v6(self):
     try:
         # Only source Address is valid, the rest is invalid
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.valid_src_Address,
                                   self.invalid_src_Token,
                                   self.invalid_neg_nb,
                                   self.invalid_dest_Address,
                                   self.invalid_dest_Token,
                                   self.invalid_neg_nb), dict)
         # Only source Address + source Token are valid, the rest is invalid
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.valid_src_Address,
                                   self.valid_src_Token,
                                   self.invalid_neg_nb,
                                   self.invalid_dest_Address,
                                   self.invalid_dest_Token,
                                   self.invalid_neg_nb), dict)
         # Only source Address + source Token + source_Quantity are valid, the rest is invalid
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.valid_src_Address,
                                   self.valid_src_Token,
                                   self.valid_positive_nb_1,
                                   self.invalid_dest_Address,
                                   self.invalid_dest_Token,
                                   self.invalid_neg_nb), dict)
         # Only (source + dest) Addresses + source Token + source_Quantity are valid, the rest is invalid
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.valid_src_Address,
                                   self.valid_src_Token,
                                   self.valid_positive_nb_1,
                                   self.valid_dest_Address,
                                   self.invalid_dest_Token,
                                   self.invalid_neg_nb), dict)
         # Only (source + dest) Addresses + (source + dest)  Tokens + source_Quantity are valid, the rest is invalid
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.valid_src_Address,
                                   self.valid_src_Token,
                                   self.valid_positive_nb_1,
                                   self.valid_dest_Address,
                                   self.valid_dest_Token,
                                   self.invalid_neg_nb), dict)
         # All parameters are invalid
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.invalid_src_Address,
                                   self.invalid_src_Token,
                                   self.invalid_neg_nb,
                                   self.invalid_dest_Address,
                                   self.invalid_dest_Token,
                                   self.invalid_neg_nb), dict)
         xbridge_logger.XLOG("test_invalid_create_tx_v6", 0)
     except AssertionError as ass_err:
         log_json = {
             "group": "test_invalid_create_tx_v6",
             "success": 0,
             "failure": 1,
             "error": 0
         }
         xbridge_utils.ERROR_LOG.append(log_json)
         xbridge_logger.logger.info(
             'test_invalid_create_tx_v6 unit test FAILED: %s' % ass_err)
         xbridge_logger.logger.info('valid_src_Address: %s',
                                    self.valid_src_Address)
         xbridge_logger.logger.info('valid_dest_Address: %s',
                                    self.valid_dest_Address)
         xbridge_logger.logger.info('invalid_dest_Address: %s',
                                    self.invalid_dest_Address)
         xbridge_logger.logger.info('valid_src_Token: %s',
                                    self.valid_src_Token)
         xbridge_logger.logger.info('valid_dest_Token: %s',
                                    self.valid_dest_Token)
         xbridge_logger.logger.info('invalid_src_Token: %s',
                                    self.invalid_src_Token)
         xbridge_logger.logger.info('invalid_dest_Token: %s',
                                    self.invalid_dest_Token)
         xbridge_logger.logger.info('valid_positive_nb_1: %s',
                                    self.valid_positive_nb_1)
         xbridge_logger.logger.info('invalid_neg_nb: %s',
                                    self.invalid_neg_nb)
コード例 #6
0
 def test_invalid_create_tx_v3(self):
     for i in range(subTest_count):
         src_Token = random.choice(self.token_pool)
         dest_Token = random.choice(self.token_pool)
         # We try to make sure they are different
         if (src_Token == dest_Token):
             dest_Token = random.choice(self.token_pool)
         src_Amount = random.choice(self.amount_pool)
         dest_Amount = random.choice(self.amount_pool)
         src_Address = random.choice(self.address_pool)
         dest_Address = random.choice(self.address_pool)
         if (src_Address == dest_Address):
             dest_Address = random.choice(self.address_pool)
     with self.subTest(
             "Same source and destination Addresses, different tokens"):
         try:
             # print("test_invalid_create_tx_v3 - src_Address: %s" % str(src_Address))
             self.assertIsInstance(
                 xbridge_rpc.create_tx(src_Address, src_Token, src_Amount,
                                       src_Address, dest_Token,
                                       dest_Amount), dict)
             xbridge_logger.XLOG("test_invalid_create_tx_v3", 0)
         except AssertionError as ass_err:
             xbridge_logger.XLOG("test_invalid_create_tx_v3", 1, ass_err, [
                 src_Address, src_Token, src_Amount, src_Address,
                 dest_Token, dest_Amount
             ])
         except JSONRPCException as json_excpt:
             xbridge_logger.XLOG("test_invalid_create_tx_v3", 2, json_excpt,
                                 [
                                     src_Address, src_Token, src_Amount,
                                     src_Address, dest_Token, dest_Amount
                                 ])
     with self.subTest(
             "Same source and destination tokens, different addresses"):
         try:
             self.assertIsInstance(
                 xbridge_rpc.create_tx(src_Address, src_Token, src_Amount,
                                       dest_Address, src_Token,
                                       dest_Amount), dict)
             xbridge_logger.XLOG("test_invalid_create_tx_v3", 0)
         except AssertionError as ass_err:
             xbridge_logger.XLOG("test_invalid_create_tx_v3", 1, ass_err, [
                 src_Address, src_Token, src_Amount, src_Address,
                 dest_Token, dest_Amount
             ])
         except JSONRPCException as json_excpt:
             xbridge_logger.XLOG("test_invalid_create_tx_v3", 2, json_excpt,
                                 [
                                     src_Address, src_Token, src_Amount,
                                     src_Address, dest_Token, dest_Amount
                                 ])
     with self.subTest("same source and destination Tokens, and addresses"):
         try:
             param_vector = [
                 src_Address, src_Token, src_Amount, src_Address, src_Token,
                 dest_Amount
             ]
             self.assertIsInstance(
                 xbridge_rpc.create_tx(src_Address, src_Token, src_Amount,
                                       src_Address, src_Token, dest_Amount),
                 dict)
             xbridge_logger.XLOG("test_invalid_create_tx_v3", 0)
             # for param in param_vector:
             #    print("test_invalid_create_tx_v3 param: %s" % (str(param)[:10]))
         except AssertionError as ass_err:
             xbridge_logger.XLOG("test_invalid_create_tx_v3", 1, ass_err,
                                 param_vector)
         except JSONRPCException as json_excpt:
             xbridge_logger.XLOG("test_invalid_create_tx_v3", 2, json_excpt,
                                 param_vector)
コード例 #7
0
 def test_invalid_create_tx_v1(self):
     for i in range(subTest_count):
         with self.subTest("combinations"):
             try:
                 src_Token = random.choice(self.token_pool)
                 dest_Token = random.choice(self.token_pool)
                 src_Address = random.choice(self.address_pool)
                 dest_Address = random.choice(self.address_pool)
                 # negative_number + positive_number
                 self.assertIsInstance(
                     xbridge_rpc.create_tx(src_Address, src_Token,
                                           self.invalid_neg_nb,
                                           dest_Address, dest_Token,
                                           self.valid_positive_nb_2), dict)
                 xbridge_logger.XLOG("test_invalid_create_tx_v1", 0)
                 # positive_number + negative_number
                 self.assertIsInstance(
                     xbridge_rpc.create_tx(src_Address, src_Token,
                                           self.valid_positive_nb_1,
                                           dest_Address, dest_Token,
                                           self.invalid_neg_nb), dict)
                 xbridge_logger.XLOG("test_invalid_create_tx_v1", 0)
                 # negative_number + negative_number
                 self.assertIsInstance(
                     xbridge_rpc.create_tx(src_Address, src_Token,
                                           self.invalid_neg_nb,
                                           dest_Address, dest_Token,
                                           self.invalid_neg_nb), dict)
                 xbridge_logger.XLOG("test_invalid_create_tx_v1", 0)
                 # 0 + negative_number
                 self.assertIsInstance(
                     xbridge_rpc.create_tx(src_Address, src_Token, 0,
                                           dest_Address, dest_Token,
                                           self.invalid_neg_nb), dict)
                 xbridge_logger.XLOG("test_invalid_create_tx_v1", 0)
                 # positive_number + 0
                 self.assertIsInstance(
                     xbridge_rpc.create_tx(src_Address, src_Token,
                                           self.valid_positive_nb_1,
                                           dest_Address, dest_Token, 0),
                     dict)
                 xbridge_logger.XLOG("test_invalid_create_tx_v1", 0)
                 # 0 + 0
                 self.assertIsInstance(
                     xbridge_rpc.create_tx(self.valid_src_Address,
                                           self.valid_src_Token, 0,
                                           dest_Address, dest_Token, 0),
                     dict)
                 xbridge_logger.XLOG("test_invalid_create_tx_v1", 0)
                 param_vector = [
                     src_Address, src_Token, self.invalid_neg_nb,
                     src_Address, dest_Token, self.valid_positive_nb_2,
                     self.valid_positive_nb_1
                 ]
                 # for param in param_vector:
                 #     print("test_invalid_create_tx_v1 param: %s" % (str(param)[:10]))
             except AssertionError as ass_err:
                 xbridge_logger.XLOG("test_invalid_create_tx_v1", 1,
                                     ass_err, param_vector)
             except JSONRPCException as json_excpt:
                 xbridge_logger.XLOG("test_invalid_create_tx_v1", 2,
                                     json_excpt, param_vector)
コード例 #8
0
 def test_invalid_create_tx_v1(self):
     try:
         # negative_number + positive_number, all other parameters being valid
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.valid_src_Address,
                                   self.valid_src_Token,
                                   self.invalid_neg_nb,
                                   self.valid_dest_Address,
                                   self.valid_dest_Token,
                                   self.valid_positive_nb_2), dict)
         # positive_number + negative_number, all other parameters being valid
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.valid_src_Address,
                                   self.valid_src_Token,
                                   self.valid_positive_nb_1,
                                   self.valid_dest_Address,
                                   self.valid_dest_Token,
                                   self.invalid_neg_nb), dict)
         # negative_number + negative_number, all other parameters being valid
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.valid_src_Address,
                                   self.valid_src_Token,
                                   self.invalid_neg_nb,
                                   self.valid_dest_Address,
                                   self.valid_dest_Token,
                                   self.invalid_neg_nb), dict)
         # 0 + negative_number, all other parameters being valid
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.valid_src_Address,
                                   self.valid_src_Token, 0,
                                   self.valid_dest_Address,
                                   self.valid_dest_Token,
                                   self.invalid_neg_nb), dict)
         # positive_number + 0, all other parameters being valid
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.valid_src_Address,
                                   self.valid_src_Token,
                                   self.valid_positive_nb_1,
                                   self.valid_dest_Address,
                                   self.valid_dest_Token, 0), dict)
         # 0 + 0, all other parameters being valid
         self.assertIsInstance(
             xbridge_rpc.create_tx(self.valid_src_Address,
                                   self.valid_src_Token, 0,
                                   self.valid_dest_Address,
                                   self.valid_dest_Token, 0), dict)
         xbridge_logger.XLOG("test_invalid_create_tx_v1", 0)
     except AssertionError as ass_err:
         xbridge_logger.XLOG("test_invalid_create_tx_v2", 1, ass_err)
         if MAX_LOG_LENGTH > 0:
             xbridge_logger.logger.info(
                 'valid_src_Address: %s',
                 str(self.valid_src_Address)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_dest_Address: %s',
                 str(self.valid_dest_Address)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_dest_Token: %s',
                 str(self.valid_dest_Token)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_dest_Address: %s',
                 str(self.valid_dest_Address)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'invalid_neg_nb: %s',
                 str(self.invalid_neg_nb)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_positive_nb_1: %s',
                 str(self.valid_positive_nb_1)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_positive_nb_2: %s',
                 str(self.valid_positive_nb_2)[:MAX_LOG_LENGTH])
     except JSONRPCException as json_excpt:
         xbridge_logger.XLOG("test_invalid_create_tx_v2", 2, json_excpt)
         if MAX_LOG_LENGTH > 0:
             xbridge_logger.logger.info(
                 'valid_src_Address: %s',
                 str(self.valid_src_Address)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_dest_Address: %s',
                 str(self.valid_dest_Address)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_dest_Token: %s',
                 str(self.valid_dest_Token)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_dest_Address: %s',
                 str(self.valid_dest_Address)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'invalid_neg_nb: %s',
                 str(self.invalid_neg_nb)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_positive_nb_1: %s',
                 str(self.valid_positive_nb_1)[:MAX_LOG_LENGTH])
             xbridge_logger.logger.info(
                 'valid_positive_nb_2: %s',
                 str(self.valid_positive_nb_2)[:MAX_LOG_LENGTH])