Beispiel #1
0
 def cancel_trade(self, symbol, rate, type, amount, tradePassword, source,
                  user_id, asset, table):
     try:
         old_asset = DB.DB().get_balance(user_id, asset)
         trade_price = round(DB.DB().get_current_price(symbol) * rate, 8)
         response_trade = Service.Service().trade(trade_price, amount, type,
                                                  tradePassword, symbol,
                                                  source)
         allm = response_trade['data']['allMoney']
         order_id = response_trade['data']['id']
         new_lock_asset = DB.DB().get_balance(user_id, asset)[1]
         if type == 1:
             self.assertEqual(float(allm),
                              round(new_lock_asset - old_asset[1], 8),
                              msg="冻结金额错误。")
         else:
             self.assertEqual(amount,
                              round(new_lock_asset - old_asset[1], 8),
                              msg="冻结金额错误。。")
         time.sleep(1)
         response = Service.Service().cancel_buyorder(
             order_id, symbol, source)
         print(response)
         Common.search_str(str(response), [self.SUCCESS_RESULT])
         order = DB.DB().get_order(table, order_id)
         self.assertEqual(order[2], -1, msg="订单信息错误")
         self.assertEqual(DB.DB().get_balance(user_id, asset)[1],
                          old_asset[1],
                          msg="冻结金额未解冻")
         self.assertEqual(DB.DB().get_balance(user_id, asset)[0],
                          old_asset[0],
                          msg="账户资金错误")
     except Exception as ex:
         raise ex
Beispiel #2
0
 def get_code_noali(self, type, phone):
     try:
         Service.Service().get_phone_code(None, None, None, None, None,
                                          type)
         return DB.DB().get_phoneCode(phone)
     except Exception as ex:
         raise ex
Beispiel #3
0
 def test201_finance(self):
     '''账户资产'''
     print('finance')
     try:
         response = Service.Service().get_finance(1)
         Common.search_str(str(response), [self.SUCCESS_RESULT])
         print(response)
     except Exception as ex:
         raise ex
Beispiel #4
0
 def test212_finance_limit(self):
     '''获取提现额度'''
     print('finance_limit')
     try:
         response = Service.Service().get_finance_limit()
         Common.search_str(str(response), [self.SUCCESS_RESULT])
         print(response)
     except Exception as ex:
         raise ex
Beispiel #5
0
 def login(self, username):
     try:
         response = Service.Service().login(username, Common.pwdOne)
         token = response['data']['token']
         Utils.Utils.headers['headerToken'] = token
         print(token)
         return response
     except Exception as ex:
         raise ex
Beispiel #6
0
 def test204_address(self):
     '''地址管理'''
     print('address')
     try:
         response = Service.Service().get_address(1)
         Common.search_str(str(response), [self.SUCCESS_RESULT])
         print(response)
     except Exception as ex:
         raise ex
Beispiel #7
0
 def test202_account_record(self):
     '''资金流水'''
     print('account_record')
     try:
         response = Service.Service().get_account_recorde(
             -1, -1, '2018-5-01', '2018-5-31', 1, 10)
         Common.search_str(str(response), [self.SUCCESS_RESULT])
         print(response)
     except Exception as ex:
         raise ex
Beispiel #8
0
 def test205_disable_address(self):
     '''删除地址'''
     print('disable_address')
     try:
         response = Service.Service().disable_coin_address(
             DB.DB().get_address(354558, 1)[0])
         Common.search_str(str(response), [self.SUCCESS_RESULT])
         print(response)
     except Exception as ex:
         raise ex
Beispiel #9
0
 def test207_get_recharge_record(self):
     '''获取充值记录'''
     print('get_recharge_record')
     try:
         response = Service.Service().get_recharge_recorde(
             58, '2018-01-01 00:00:00', '2018-08-14 00:00:00', 1, 100)
         Common.search_str(str(response), [self.SUCCESS_RESULT])
         print(response)
     except Exception as ex:
         raise ex
Beispiel #10
0
 def test208_get_withdraw_record(self):
     '''提现记录'''
     print('get_withdraw_record')
     try:
         response = Service.Service().get_withdraw_recorde(
             58, '2018-01-01 00:00:00', '2018-05-01 00:00:00', 1, 100)
         Common.search_str(str(response), [self.SUCCESS_RESULT])
         print(response)
     except Exception as ex:
         raise ex
Beispiel #11
0
 def get_code_regist_email(self, email, type, lang):
     try:
         Service.Service().get_email_code(Common.Aliyun_list[0].strip('\n'),
                                          Common.Aliyun_list[1].strip('\n'),
                                          Common.Aliyun_list[2].strip('\n'),
                                          'register', email, type, lang)
         for i in range(3):
             del Common.Aliyun_list[0]
         return DB.DB().get_emailCode(email)
     except Exception as ex:
         raise ex
Beispiel #12
0
 def get_code(self, phone, type):
     try:
         Service.Service().get_phone_code(Common.Aliyun_list[0].strip('\n'),
                                          Common.Aliyun_list[1].strip('\n'),
                                          Common.Aliyun_list[2].strip('\n'),
                                          'register', phone, type)
         for i in range(3):
             del Common.Aliyun_list[0]
         return DB.DB().get_phoneCode(phone)
     except Exception as ex:
         raise ex
Beispiel #13
0
 def test210_cancel_withdraw(self):
     '''取消提现'''
     print('cancle_withdraw')
     try:
         response = Service.Service().cancel_withdraw(
             1,
             DB.DB().get_withdraw_record('out_coin_transaction', 354558, 1,
                                         1)[0])
         Common.search_str(str(response), [self.SUCCESS_RESULT])
         print(response)
     except Exception as ex:
         raise ex
Beispiel #14
0
 def test203_add_address(self):
     '''添加地址'''
     print('add_address')
     try:
         response = Service.Service().add_address(
             '19kAqGjL8qQeoXJw6xQ6KSCMKoVDnJeeeo', 1, 'coinfex', 'false',
             Common.pwdTwo, Common.generate_otp('ZMUMVRAY6XEBGSOB'),
             ComMeth.ComMeth().get_code(13866666666, 24), 24)
         Common.search_str(str(response), [self.SUCCESS_RESULT])
         print(response)
     except Exception as ex:
         raise ex
Beispiel #15
0
 def test206_makeCoinAddress(self):
     '''生成火币地址'''
     try:
         print('makeCoinAddress')
         response = Service.Service().get_coin_address(
             Common.Aliyun_list[0].strip('\n'),
             Common.Aliyun_list[1].strip('\n'),
             Common.Aliyun_list[2].strip('\n'), 'register', 73)
         print(response)
         Common.search_str(str(response), [self.SUCCESS_RESULT])
     except Exception as ex:
         raise ex
Beispiel #16
0
 def test209_apply_withdraw(self):
     '''申请提现'''
     print('apply_withdraw')
     try:
         response = Service.Service().apply_withdraw(
             1, 6264, 0.001, 0.01, 0,
             Common.generate_otp('HZTERXEO7C2655JP'),
             ComMeth.ComMeth().get_code_noali(1, 13866666666), 1,
             Common.pwdTwo)
         Common.search_str(str(response), [self.SUCCESS_RESULT])
         print(response)
     except Exception as ex:
         raise ex
Beispiel #17
0
 def trade(self,
           symbol,
           rate,
           type,
           amount,
           tradePassword,
           source,
           user_id,
           symbol_asset,
           base_asset,
           table,
           tabel_pending=None,
           flag=None):
     try:
         old_balance_symbol = DB.DB().get_balance(user_id, symbol_asset)[0]
         old_balance_base = DB.DB().get_balance(user_id, base_asset)[0]
         trade_price = round(DB.DB().get_current_price(symbol) * rate, 8)
         response = Service.Service().trade(trade_price, amount, type,
                                            tradePassword, symbol, source)
         print(response)
         Common.search_str(str(response), [self.SUCCESS_RESULT])
         order_id = response['data']['id']
         order = DB.DB().get_order(table, order_id)
         self.assertEqual(order[2], 2, msg="订单信息错误")
         new_balance_symbol = DB.DB().get_balance(user_id, symbol_asset)[0]
         new_balance_base = DB.DB().get_balance(user_id, base_asset)[0]
         amount_record_base = DB.DB().get_balance_flow(
             order_id, base_asset, user_id, tabel_pending)
         amount_record_symbol = DB.DB().get_balance_flow(
             order_id, symbol_asset, user_id, tabel_pending)
         if type == 1:
             if flag != 'option':
                 self.assertEqual(abs(amount_record_symbol[1]),
                                  round(DB.DB().get_fee(symbol) * amount,
                                        8),
                                  msg="手续费错误")
             self.assertEqual(new_balance_symbol,
                              old_balance_symbol + order[1] -
                              abs(amount_record_symbol[1]),
                              msg="账户资产错误。")
             self.assertEqual(new_balance_base,
                              round(old_balance_base - order[0], 11),
                              msg="账户资产错误。。")
         elif type == 2:
             self.assertEqual(abs(amount_record_base[1]),
                              round(DB.DB().get_fee(symbol) * order[0], 8),
                              msg="手续费错误")
             self.assertEqual(new_balance_symbol,
                              old_balance_symbol - order[1],
                              msg="账户资产错误。")
             self.assertEqual(new_balance_base,
                              old_balance_base + order[0] -
                              abs(amount_record_base[1]),
                              msg="账户资产错误。。")
         self.assertEqual(round(
             amount_record_symbol[0] - amount_record_symbol[2], 8),
                          abs(amount_record_symbol[1]),
                          msg="资金流水错误。")
         self.assertEqual(round(
             amount_record_base[0] - amount_record_base[2], 8),
                          abs(amount_record_base[1]),
                          msg="资金流水错误。。")
     except Exception as ex:
         raise ex