def test_revenue(self): admin_token = get_admin_token() api = AssetManagementApi() set_login_status(api, admin_token) res = api.asset_mgmt_revenue_get(coin_id="1") assert res.meta.requested_page == 1 assert res.query.coin_id == "1"
def test_limit_asset(self): """ /asset-mgmt/assets/restriction查询资产限制的用户 """ admin_token = get_admin_token() api = AssetManagementApi() set_login_status(api, admin_token) api.asset_mgmt_assets_restriction_id_put(id="463", body={ "withdraw": True, "otc": True }) res = api.asset_mgmt_assets_restriction_id_get(id="463") assert res.otc assert res.withdraw res = api.asset_mgmt_assets_restriction_get(withdraw=True, otc=True) assert res.meta.requested_page == 1 assert res.query.withdraw api.asset_mgmt_assets_restriction_id_delete(id="463") res = api.asset_mgmt_assets_restriction_get(withdraw=True, otc=True) assert not res.items
def test_add_market(self, with_login): user = self.data['user'] email, password = user['email'], user['password'] m_api = MarketManagementApi() e_api = ExchangeManagementApi() s_api = SponsorApi() venture_api = VentureApi() va_api = VentureAccountApi() project_api = ProjectApi() contacts_api = ContactsApi() tam_api = TenantAssetManagementApi() v_api = VerificationApi() ma_api = MainExchangeApi() vc = VentureContactsApi() pm = ProjectManagementApi() token = with_login('tenant', [ pm, vc, ma_api, v_api, contacts_api, project_api, m_api, e_api, va_api, s_api, venture_api, tam_api ], email, password) # 授权 res = PostPlatFormRegisterRequest() va_api.create_platform(body=res) # 交易币种 rv = e_api.exchange_exchange_coin_get() seller_coin = rv.seller_coin buyer_coin = rv.buyer_coin b_coin = buyer_coin[0] if seller_coin: s_coin = seller_coin[0] else: sponsor = get_sponsors() # 登录保健方 account, password = sponsor['account'], sponsor['password'] sponsor_api = SponsorApi() sponsor_token = get_sponsor_token(account, password, email='test') set_login_status(sponsor_api, sponsor_token) project = get_project(token) # req = ApplicationRequest(**project) rv = venture_api.applications_post(body=project) application_id = rv.id # 查看申请详情 rv = venture_api.applications_id_get(application_id) assert rv.status == 'undone' # 查看申请裂表 rv = venture_api.applications_get(page=1) assert len(rv.items) == 1 item = rv.items[0] assert item.project_name == project['projectName'] assert item.fullname == project['fullName'] assert item.short_name == project['shortName'] rv = venture_api.applications_num_get(status='under_review') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='passed') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='undone') assert int(rv.result) == 1 # 设置保健机构 venture_api.applications_id_set_sponsor_put( application_id, {'sponsorId': sponsor['id']}) rv = venture_api.applications_num_get(status='undone') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='under_review') assert int(rv.result) == 1 rv = venture_api.applications_num_get(status='passed') assert int(rv.result) == 0 rv = venture_api.applications_id_get(application_id) assert rv.status == 'under_review' project_name = project['projectName'] sponsor_project_api = SponsorsProjectApi() set_login_status(sponsor_project_api, sponsor_token) rv = sponsor_project_api.projects_get(page=1, project_name=project_name) assert len(rv.items) >= 1 rv = sponsor_project_api.projects_id_get(id=application_id) assert rv # 保健通过 sponsor_project_api.projects_sponsor_put({ 'id': application_id, 'status': 1, 'remark': 'test' }) rv = venture_api.applications_num_get(status='undone') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='under_review') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='passed') assert int(rv.result) == 1 rv = venture_api.applications_id_get(application_id) assert rv.status == 'passed' # 保鉴成功列表 rv = sponsor_project_api.sponsor_record_success_get( page=1, coin_name=project['shortName']) assert len(rv.items) == 1 assert rv.items[0].full_name == project['fullName'] # 项目列表 rv = venture_api.projects_get(page=1) project_id = rv.items[0].project_id self.data['project_id'] = project_id # 设置接入方式 setting = PutProjectRequestSetting(access_method='verification', open=True) req = PutProjectRequest() req.setting = setting venture_api.projects_id_put(project_id, 'setting', req) # 获取项目详情 rv = venture_api.projects_id_get(project_id) exchange_id = TestMarket1.data['exchange_id'] # 初始化项目 s_api = SystemManagementApi() staff_project_api = StaffProjectApi() asset_management_api = AssetManagementApi() admin_token = get_admin_token() set_login_status(staff_project_api, admin_token) set_login_status(asset_management_api, admin_token) set_login_status(s_api, admin_token) coin_name = project['shortName'] rv = asset_management_api.asset_mgmt_coins_get(coin_name=coin_name) coin_id = rv.items[0].coin_id coin_config_id = rv.items[0].id # 修改币种配置 res = PutSystemCoinsInitRequest() res.usdt_price = '1251' res.rc_times = 8 res.wc_times = 8 res.withdraw_rate = 0.1 res.min_withdraw = 100 res.min_withdraw_fee = 0.1 res.max_withdraw = 1000 res.min_recharge = 10 res.address_tag_switch = True res.day_withdraw_total = 125564 res.address_type = 'OX' res.address_url = 'http://unknown.com' res.txid_url = 'http://unknown.com' # asset_management_api.asset_mgmt_coins_id_put(coin_id, res) asset_management_api.asset_mgmt_coins_id_init_put( coin_config_id, res) rv = s_api.system_trading_pair_get(name=project['shortName'], partition_id=b_coin.id) # 对接币种 req = { 'exchangeId': exchange_id, 'projectId': project_id, 'sponsor': 'tenant' } contacts_api.contacts_post(req) rv = contacts_api.contacts_check_get(project_id, exchange_id) rv = pm.projects_id_contacts_get(project_id, 'tenant') # 处理对接邀请 contact_id = rv.items[0].contact_id vc.contacts_put({'contactId': contact_id, 'status': 'accepted'}) rv = contacts_api.contacts_check_get(project_id=project_id, exchange_id=exchange_id) assert rv.result rv = e_api.exchange_exchange_coin_get() seller_coin = rv.seller_coin s_coin = seller_coin[0] # 主平台获取买卖方币种列表 rv = ma_api.exchanges_exchange_coin_exchange_id_get(exchange_id) assert rv.seller_coin[0].name == project['shortName'] self.data['s_coin'] = s_coin self.data['b_coin'] = b_coin res = PostOrderMarketRequest() res.seller_coin_id = s_coin.id res.buyer_coin_id = b_coin.id res.allotted_time = AllottedTime._6month res.fee_rate = TestMarket1.fee_rate now = datetime.now() create_at = now.strftime("%Y-%m") disabled_at = now + relativedelta(months=AllottedTime._6month) disabled_at = disabled_at.strftime("%Y-%m") rv = e_api.exchange_exchange_coin_get() # 配置交易对市场 rv = e_api.exchange_order_market_post(res) order_id = rv.order_id usdt_id = b_coin.id # 充钱 free_charge(token, usdt_id, self.data['account_id']) rv = tam_api.asset_mgmt_assets_get() # 临时接口充币 rv = tam_api.asset_mgmt_balance_coin_id_get(usdt_id) data = { "challenge": "048ebbe51f829995db76ac4b81546403", "seccode": "048ebbe51f829995db76ac4b81546403", "validate": "true", "account": "mailto:[email protected]", "code": "666666", "secondCode": "Ls1w1w", "type": "pay" } rv = v_api.accounts_verify_post(data) p = PutOrderMarketRequest(order_id=order_id, token=rv.token) e_api.exchange_order_market_put(p) # 获取交易对市场 rv = m_api.markets_get() items = rv.items assert len(items) == 1 item = items[0] sell_coin_name = s_coin.name buy_coin_name = b_coin.name # total_rate = TestMarket1.fee_rate + float(TestMarket1.service_rate) # assert item.total_rate == 0.00011 # todo暂时不测这个 # assert item.fee_rate == TestMarket1.fee_rate # todo暂时不测这个 assert item.status == 'running' assert item.trading_pair == f'{sell_coin_name}/{buy_coin_name}' assert item.created_at.strftime('%Y-%m') == create_at assert item.disabled_at.strftime('%Y-%m') == disabled_at # 获取交易所总数据 rv = ma_api.exchanges_total_data_get() assert float(rv.exchange_amount) >= 1 # 批量修改交易币对单价 s_api.system_trading_pair_update_list_put(1111, True, True) rv = s_api.system_trading_pair_get(partition_id=b_coin.id) for each in rv.items: assert float(each.price) == 1111
def test_applications8(self): faker = Faker() manager = PlatformManager("venture") email = random_email() password = faker.password() country = random_get_country_ob() manager.register(email=email, password=password, promotion_code=None, verification_code="666666", nationality_code=country.get("k"), nick_name='fghfg') token = manager.login(account=email, password=password) # 个人实名认证 individual_verify(platform="venture", id_number=get_random_id_number(), token=token) # 申请项目 project_name = get_random_name(2, 16) short_name = "O" + str(random.randint(10000, 99999)) full_name = get_random_name(2, 16) project_api = ProjectApi() set_login_status(project_api, token) pay = copy.deepcopy(dict(payload)) pay.update({ 'project_name': project_name, 'short_name': short_name, 'full_name': full_name }) req = ApplicationRequest(**pay) res = project_api.applications_post(body=req) project_apply_id = res.id # 创建保健方账号 staff_api = SponsorsManagermentApi() staff_token = get_admin_token() set_login_status(staff_api, staff_token) sponsor = { "account": get_random_name(6, 25), "password": faker.password(), "name": faker.user_name(), "email": faker.email(), "phone": faker.phone_number() } staff_api.staff_sponsors_post(post_sponsor=sponsor) # 新建交易所标签 website_api = WebsiteManagementApi() set_login_status(website_api, staff_token) website = { "name": "交易所标签" + str(random.randint(10000, 99999)), "otherLanguage": [{ "key": "英语", "value": "public_chain" }, { "key": "法语", "value": "public_chain" }] } website_api.exchange_tags_post(body=website) # 项目方获取保健列表 venture_api = SMApi() set_login_status(venture_api, token) res = venture_api.sponsors_get(page=1, name=sponsor.get("name")) item = res.items.pop() sponsor_id = item.id # 项目方设置保健方 project_api.applications_id_set_sponsor_put( id=project_apply_id, sponsor_request={"sponsorId": sponsor_id}) # 保健方登 # 保健项目 sponsor_api = SponsorsProjectApi() get_sponsor_token(account=sponsor.get("account"), password=sponsor.get("password"), email=sponsor.get("email"), api_list=[sponsor_api]) sponsor_api.projects_sponsor_put(put_project_sponsor_request={ "id": project_apply_id, "status": 1, "remark": "remark" }) # 币种配置列表 asset_api = AssetManagementApi() set_login_status(asset_api, staff_token) res = asset_api.asset_mgmt_coins_get(page=1, coin_name=short_name) coin_id = '' assert res.meta.total_count == 1 for item in res.items: assert item.coin_name == short_name coin_id = item.id # 初始化币种配置 payload1 = { "usdtPrice": "1", "rcTimes": 0, "wcTimes": 0, "withdrawRate": "1", "minWithdrawFee": "1", "minWithdraw": "1", "maxWithdraw": "1", "dayWithdrawTotal": "1", "minRecharge": "1", "addressTagSwitch": True, "addressType": "1", "addressUrl": "1", "txidUrl": "1" } asset_api.asset_mgmt_coins_id_init_put(id=coin_id, body=payload1) # 授权登录 api = AccountApi() set_login_status(api, token) api.create_platform() # 提交交易所申请 exchange_api = ExchangeManagementApi() set_login_status(exchange_api, token) exchange = { "email": email, "logo": "gdfgdvdfvdf", "name": "交易所" + str(random.randint(10000, 99999)), "nationality": "+86", "phone": '+86135678' + str(random.randint(10000, 99999)), "tags": website['name'] } exchange_api.exchange_post(exchange) # 交易所账号审核列表 audit_api = AuditApi() set_login_status(audit_api, staff_token) res = audit_api.tenant_audits_get(exchange_name=exchange['name']) audit_id = '' for item in res.items: audit_id = item.id # 交易所初审 audit = { "failureType": "string", "id": audit_id, "isDataReceived": True, "status": "approved" } audit_api.tenant_audits_audit_post(body=audit) # 交易所账号审核列表 res = audit_api.tenant_audits_get(exchange_name=exchange['name']) re_audit_id = '' for item in res.items: re_audit_id = item.id # 交易所账号复审 re_audit = { "failureType": "string", "id": re_audit_id, "status": "approved" } audit_api.tenant_audits_re_audit_post(body=re_audit) # 获取交易所id exchange_id_ = '' res = exchange_api.exchange_exchange_id_get() exchange_id_ = res.id # 获取项目列表 exchange_project_api = ExchangeProject() set_login_status(exchange_project_api, token) project_id = '' res = exchange_project_api.projects_get(coin_name=short_name) for item in res.items: project_id = item.project_id # 申请对接 contacts_api = ExchangeContacts() set_login_status(contacts_api, token) contacts = { "exchangeId": exchange_id_, "projectId": project_id, "sponsor": "tenant" } contacts_api.contacts_post(contacts) # 获取项目未处理的邀请记录数量 contacts_project_api = ContactsApi() set_login_status(contacts_project_api, token) res = contacts_project_api.contacts_invite_number_get(id=project_id) assert res.result == '1' # 获取交易所对接的项目列表 api = ProjectManagementApi() set_login_status(api, token) contacts_id = '' res = api.projects_id_contacts_get(id=project_id, sponsor="pending") for item in res.items: if item.exchange_name == exchange['name']: contacts_id = item.contact_id # 处理对接邀请 payload2 = {"contactId": contacts_id, "status": "accepted"} contacts_project_api.contacts_put(body=payload2) # 判断项目方与交易所是否已经申请对接 res = contacts_project_api.contacts_check_get(project_id=project_id, exchange_id=exchange_id_) assert res.result
def test_staff_venture_case1(self): faker = Faker() manager = PlatformManager("venture") email = random_email() password = faker.password() country = random_get_country_ob() manager.register(email=email, password=password, promotion_code=None, verification_code="666666", nationality_code=country.get("k")) token = manager.login(account=email, password=password) # 个人实名认证 individual_verify(platform="venture", id_number=get_random_id_number(), token=token) # 申请项目 project_name = get_random_name(2, 16) short_name = "WE" + str(random.randint(1000, 9999)) full_name = get_random_name(2, 16) project_api = ProjectApi() set_login_status(project_api, token) pay = copy.deepcopy(dict(payload)) pay.update({ 'project_name': project_name, 'short_name': short_name, 'full_name': full_name }) req = ApplicationRequest(**pay) res = project_api.applications_post(body=req) project_apply_id = res.id # 创建保健方账号 staff_api = SponsorsManagermentApi() staff_token = get_admin_token() set_login_status(staff_api, staff_token) sponsor = { "account": get_random_name(6, 25), "password": faker.password(), "name": faker.user_name(), "email": email, "phone": faker.phone_number() } staff_api.staff_sponsors_post(post_sponsor=sponsor) # 项目方获取保健列表 venture_api = SMApi() set_login_status(venture_api, token) res = venture_api.sponsors_get(page=1, name=sponsor.get("name")) item = res.items.pop() sponsor_id = item.id # 项目方设置保健方 project_api.applications_id_set_sponsor_put( id=project_apply_id, sponsor_request={"sponsorId": sponsor_id}) # 保健方登 # 保健项目 sponsor_api = SponsorsProjectApi() get_sponsor_token(account=sponsor.get("account"), password=sponsor.get("password"), email=sponsor.get("email"), api_list=[sponsor_api]) sponsor_api.projects_sponsor_put(put_project_sponsor_request={ "id": project_apply_id, "status": 1, "remark": "remark" }) # 币种配置列表 asset_api = AssetManagementApi() set_login_status(asset_api, staff_token) res = asset_api.asset_mgmt_coins_get(page=1, coin_name=short_name) coin_id = '' assert res.meta.total_count == 1 for item in res.items: assert item.coin_name == short_name coin_id = item.id # 初始化币种配置 payload1 = { "usdtPrice": "1", "rcTimes": 0, "wcTimes": 0, "withdrawRate": "1", "minWithdrawFee": "1", "minWithdraw": "1", "maxWithdraw": "1", "dayWithdrawTotal": "1", "minRecharge": "1", "addressTagSwitch": True, "addressType": "1", "addressUrl": "1", "txidUrl": "1" } asset_api.asset_mgmt_coins_id_init_put(id=coin_id, body=payload1) # 后台查询项目方用户列表 staff_venture_api = VentureManagementApi() set_login_status(staff_venture_api, token) res = staff_venture_api.accounts_ventures_get(email=email) assert res.meta.total_count == 1 uid = '' for item in res.items: assert item.email == email assert item.venture_id uid = item.uid # 获取项目方用户信息 res = staff_venture_api.accounts_ventures_id_get(id=uid) assert res.email == email assert res.account_id assert res.venture_id
def test_withdraw_patch(self, platform, with_login): (coin_id, coin_id_, coin_name, rc_confirmed_time, wc_confirmed_time) = create_venture() manager = PlatformManager(platform) asset_api = manager.asset_api verify_api = manager.verify_api account_api = manager.account_api user = register_with_login(platform, with_login, [asset_api, verify_api, account_api]) admin_token = get_admin_token() asset_manage_api = AssetManagementApi() set_login_status(asset_manage_api, admin_token) # 账户实名认证 id_number = get_random_id_number() individual_verify(platform, id_number, user["token"]) # 设置可以充币 asset_manage_api.asset_mgmt_coins_id_recharge_put(id=coin_id, rechargeable=True) # 获取冲币地址 res = asset_api.asset_mgmt_recharge_addresses_get(coin_id=coin_id_) assert res.coin_id == coin_id_ # 通知冲币 recharge_address = res.coin_address recharge_amount = 100 recharge_notify(coin_name, 30, recharge_address, amount=recharge_amount) # 设置资金密码 faker = Faker() asset_password = faker.password() res = manager.verify({ "challenge": "048ebbe51f829995db76ac4b81546403", "seccode": "048ebbe51f829995db76ac4b81546403", "validate": "true", "account": "mailto:" + user.get("email"), "code": DEFAULT_VERIFY_CODE, "type": "edit_asset_pwd" }) base_token = res.token asset_api.asset_mgmt_asset_password_put( body={ "password": user.get("password"), "traPassword": asset_password, "baseToken": base_token }) # 修改可提币配置 asset_manage_api.asset_mgmt_coins_id_withdraw_put(id=coin_id, withdrawable=True) # 资金密码校验 withdraw_amount = int(50) asset_api.asset_mgmt_asset_password_check_post( body={ "traPassword": asset_password, "coinId": coin_id_, "amount": withdraw_amount }) # 提币 res = manager.verify({ "challenge": "048ebbe51f829995db76ac4b81546403", "seccode": "048ebbe51f829995db76ac4b81546403", "validate": "true", "account": "mailto:" + user.get("email"), "code": DEFAULT_VERIFY_CODE, "type": "withdraw" }) withdraw_address = "{}_{}".format(coin_name, uuid.uuid4().hex) asset_api.asset_mgmt_withdraw_post( body={ "traPassword": asset_password, "baseToken": res.token, "coinId": coin_id_, "amount": withdraw_amount, "remark": "withdraw_remark", "addressTag": "address_tag", "address": withdraw_address, "isSaveAddress": True }) # 从管理后台获取提币记录 res = asset_manage_api.get_withdraw_list(to_address=withdraw_address) item = res.items.pop() withdraw_record_id = item.id # 后台一审 asset_manage_api.asset_mgmt_withdraw_id_first_audit_post( id=withdraw_record_id, body={ "result": True, "remark": "withdraw_first_remark" }) # 后台二审 asset_manage_api.asset_mgmt_withdraw_id_second_audit_post( id=withdraw_record_id, body={ "result": True, "remark": "withdraw_second_remark" }) # 通知提币(该笔记录为失败状态) tx_id = "{}_{}_{}".format(coin_name, withdraw_address, withdraw_amount) withdraw_notify(txid=tx_id, status=-1, confirmations=30) # 从管理后台获取提币记录 res = asset_manage_api.get_withdraw_list(to_address=withdraw_address) item = res.items.pop() withdraw_record_id = item.id assert item.status == "FAILED" assert item.confirmation_number == 2 assert item.confirmed_times == 30 # # 自动补单提币 # asset_manage_api.asset_mgmt_withdraw_patch_id_post( # id=withdraw_record_id, body={"patchType": "AUTO"}) # # # 通知提币(该笔记录为失败状态) # tx_id = "{}_{}_{}".format("YSSKUR", withdraw_address, withdraw_amount) # withdraw_notify(txid=tx_id, status=-1, confirmations=20) # # # 从管理后台获取提币记录 # res = asset_manage_api.get_withdraw_list(to_address=withdraw_address) # item = res.withdraw_records.pop() # withdraw_record_id = item.id # assert item.status == "FAILED" # assert item.confirmation_number == 2 # assert item.confirmed_times == 20 # 手动补单 tx_id = uuid.uuid4().hex asset_manage_api.asset_mgmt_withdraw_patch_id_post( id=withdraw_record_id, body={ "patchType": "MANUAL", "txid": tx_id }) # 从管理后台获取提币记录 res = asset_manage_api.get_withdraw_list(to_address=withdraw_address, status="PATCH") item = res.items.pop() assert item.status == "PATCH" assert item.confirmation_number == 2 assert item.confirmed_times == 30 # 获取单个币种资产 res = asset_api.asset_mgmt_assets_coin_id_get(coin_id=coin_id_) assert res.coin_id == coin_id_ assert float(res.balance) == recharge_amount - withdraw_amount assert float(res.total) == recharge_amount - withdraw_amount assert float(res.frozen) == 0
def test_normal_recharge_withdraw(self, platform, with_login): (coin_id, coin_id_, coin_name, rc_confirmed_time, wc_confirmed_time) = create_venture() manager = PlatformManager(platform) asset_api = manager.asset_api verify_api = manager.verify_api account_api = manager.account_api user = register_with_login(platform, with_login, [asset_api, verify_api, account_api]) admin_token = get_admin_token() asset_manage_api = AssetManagementApi() set_login_status(asset_manage_api, admin_token) # 获取账户信息 res = account_api.accounts_account_info_get() account_id = res.account_info.account_id # 账户实名认证 id_number = get_random_id_number() individual_verify(platform, id_number, user["token"]) # 设置可以充币 asset_manage_api.asset_mgmt_coins_id_recharge_put(id=coin_id, rechargeable=True) # 获取冲币地址 res = asset_api.asset_mgmt_recharge_addresses_get(coin_id=coin_id_) assert res.coin_id == coin_id_ # 通知冲币 recharge_address = res.coin_address recharge_amount = 100 recharge_confirmed_times = 30 recharge_notify(coin_name, recharge_confirmed_times, recharge_address, amount=recharge_amount) # 获取账户冲币记录 res = asset_api.asset_mgmt_recharge_records_get(status="SUCCEED") assert res.meta.total_count == 1 item = res.items.pop() assert item.coin_id == coin_id_ assert item.status == "SUCCEED" assert float(item.amount) == recharge_amount assert item.address == '{}_recharge_from_address'.format(coin_name) assert item.confirmed_times == recharge_confirmed_times assert item.confirmation_number == rc_confirmed_time # 从后台获取冲币记录 res = asset_manage_api.get_recharge_list(account_id=account_id, coin_id=coin_id_, status="SUCCEED") assert len(res.items) == 1 item = res.items.pop() assert item.coin_id == coin_id_ assert item.confirmed_times == recharge_confirmed_times assert item.confirmation_number == rc_confirmed_time assert item.address == '{}_recharge_from_address'.format(coin_name) assert item.status == "SUCCEED" # 获取账户资产 res = asset_api.asset_mgmt_assets_get() for i in res.asset_info: if i.coin_id == coin_id_: assert float(i.total) == recharge_amount assert float(i.balance) == recharge_amount break else: assert False, "未发现冲币币种余额" # 获取指定币种余额 res = asset_api.asset_mgmt_balance_coin_id_get(coin_id=coin_id_) assert float(res.balance) == recharge_amount # 获取单个币种资产 res = asset_api.asset_mgmt_assets_coin_id_get(coin_id=coin_id_) assert res.coin_id == coin_id_ assert float(res.balance) == recharge_amount assert float(res.total) == recharge_amount assert float(res.frozen) == 0 # 通知冲币失败 failed = -1 recharge_notify(coin_name, 1, recharge_address, failed) # 获取账户失败的冲币记录 res = asset_api.asset_mgmt_recharge_records_get(status="FAILED") assert res.meta.total_count == 1 item = res.items.pop() assert item.coin_id == coin_id_ assert item.status == "FAILED" assert float(item.amount) == recharge_amount assert item.address == '{}_recharge_from_address'.format(coin_name) assert item.confirmed_times == 1 assert item.confirmation_number == rc_confirmed_time # 从后台获取冲币记录 res = asset_manage_api.get_recharge_list(account_id=account_id, coin_id=coin_id_, status="FAILED") assert len(res.items) == 1 item = res.items.pop() assert item.coin_id == coin_id_ assert item.confirmed_times == 1 assert item.confirmation_number == rc_confirmed_time assert item.address == '{}_recharge_from_address'.format(coin_name) assert item.status == "FAILED" # 通知确认中的冲币 confirming = 0 recharge_notify(coin_name, 2, recharge_address, confirming) # 获取账户冲币记录 res = asset_api.asset_mgmt_recharge_records_get(status="CONFIRMING") assert res.meta.total_count == 1 item = res.items.pop() assert item.coin_id == coin_id_ assert item.confirmed_times == 2 assert item.status == "CONFIRMING" assert float(item.amount) == recharge_amount assert item.address == '{}_recharge_from_address'.format(coin_name) assert item.confirmation_number == rc_confirmed_time # 从后台获取冲币记录 res = asset_manage_api.get_recharge_list(account_id=account_id, coin_id=coin_id_, status="CONFIRMING") assert len(res.items) == 1 item = res.items.pop() assert item.coin_id == coin_id_ assert item.confirmed_times == 2 assert item.confirmation_number == rc_confirmed_time assert item.address == '{}_recharge_from_address'.format(coin_name) assert item.status == "CONFIRMING" # 获取单个币种资产 res = asset_api.asset_mgmt_assets_coin_id_get(coin_id=coin_id_) assert res.coin_id == coin_id_ assert float(res.balance) == recharge_amount assert float(res.total) == recharge_amount assert float(res.frozen) == 0 # 新增提币地址 withdraw_address_1 = "{}_{}".format(coin_name, uuid.uuid4().hex) withdraw_address_2 = "{}_{}".format(coin_name, uuid.uuid4().hex) asset_api.asset_mgmt_withdraw_addresses_post( body={ "coinId": coin_id_, "remark": "remark_1", "address": withdraw_address_1 }) asset_api.asset_mgmt_withdraw_addresses_post( body={ "coinId": coin_id_, "remark": "remark_2", "address": withdraw_address_2 }) # 获取所有提币地址 res = asset_api.asset_mgmt_withdraw_addresses_get(coin_id=coin_id_) assert len(res) == 2 for item in res: assert item["coinId"] == coin_id_ delete_address = res.pop() delete_address_id = delete_address["id"] # 从后台获取提币地址 res = asset_manage_api.asset_mgmt_assets_withdraw_address_get( account_id=account_id) assert len(res.items) == 2 for i in res.items: assert i.address in [withdraw_address_1, withdraw_address_2] # 获取所有提币地址 res = asset_api.asset_mgmt_withdraw_addresses_all_get() assert len(res) == 2 for i in res: assert isinstance(i["id"], str) assert isinstance(i["coinName"], str) assert i["address"] in [withdraw_address_1, withdraw_address_2] # 删除提币地址 asset_api.asset_mgmt_withdraw_addresses_id_put(id=delete_address_id) # 删除后获取所有提币地址 res = asset_api.asset_mgmt_withdraw_addresses_get(coin_id=coin_id_) assert len(res) == 1 # 删除不存在的提笔地址 try: asset_api.asset_mgmt_withdraw_addresses_id_put(id="9999") except manager.api_exception as e: assert e.status == 404 else: assert False, "删除不存在的提币地址时,java接口异常" # 设置资金密码 faker = Faker() asset_password = faker.password() res = manager.verify({ "challenge": "048ebbe51f829995db76ac4b81546403", "seccode": "048ebbe51f829995db76ac4b81546403", "validate": "true", "account": "mailto:" + user.get("email"), "code": DEFAULT_VERIFY_CODE, "type": "edit_asset_pwd" }) base_token = res.token asset_api.asset_mgmt_asset_password_put( body={ "password": user.get("password"), "traPassword": asset_password, "baseToken": base_token }) # 从后台查询是否设置资金密码 res = asset_manage_api.asset_mgmt_asset_password_has_set_account_id_get( account_id=account_id) assert res.is_set # 修改可提币配置 asset_manage_api.asset_mgmt_coins_id_withdraw_put(id=coin_id, withdrawable=True) withdraw_amount = int(50) withdraw_fee = 0.15 # 资金密码校验 res = asset_api.asset_mgmt_asset_password_check_post( body={ "traPassword": asset_password, "coinId": coin_id_, "amount": withdraw_amount }) assert res.token # 提币 res = manager.verify({ "challenge": "048ebbe51f829995db76ac4b81546403", "seccode": "048ebbe51f829995db76ac4b81546403", "validate": "true", "account": "mailto:" + user.get("email"), "code": DEFAULT_VERIFY_CODE, "type": "withdraw" }) withdraw_address_3 = "{}_{}".format(coin_name, uuid.uuid4().hex) asset_api.asset_mgmt_withdraw_post( body={ "traPassword": asset_password, "baseToken": res.token, "coinId": coin_id_, "amount": withdraw_amount, "remark": "withdraw_remark", "addressTag": "address_tag", "address": withdraw_address_3, "isSaveAddress": True }) # 获取钱包资金 res = asset_api.asset_mgmt_assets_get() for i in res.asset_info: if i.coin_id == coin_id_: assert float(i.total) == recharge_amount assert float(i.balance) == recharge_amount - withdraw_amount break else: assert False, "未发现冲币币种余额" # # 从平台获取提币记录 res = asset_api.asset_mgmt_withdraw_records_get(status="WAIT_REVIEW") assert res.meta.total_count == 1 item = res.items.pop() assert item.coin_id == coin_id_ assert float(item.amount) == withdraw_amount assert float(item.fee) == withdraw_fee assert item.address == withdraw_address_3 assert item.status == "WAIT_REVIEW" # 重新获取提币地址 res = asset_api.asset_mgmt_withdraw_addresses_get(coin_id=coin_id_) for i in res: assert i["coinId"] == coin_id_ assert i["address"] in [ withdraw_address_3, withdraw_address_1, withdraw_address_2 ] # 从管理后台获取提币记录 res = asset_manage_api.get_withdraw_list(to_address=withdraw_address_3) assert res.meta.total_count == 1 item = res.items.pop() withdraw_record_id = item.id assert item.coin_id == coin_id_ assert item.status == "WAIT_REVIEW" assert item.confirmation_number == wc_confirmed_time assert not item.confirmed_times assert float(item.amount) == withdraw_amount assert float(item.fee) == withdraw_fee assert item.address == withdraw_address_3 # 从后台获取提币详情 res = asset_manage_api.asset_mgmt_withdraw_records_id_get( id=withdraw_record_id) assert res.id == withdraw_record_id assert res.email == user["email"] assert res.coin_id == coin_id_ assert float(item.fee) == withdraw_fee assert res.status == "WAIT_REVIEW" assert res.address == withdraw_address_3 # # 撤销提币 # asset_api.asset_mgmt_withdraw_id_cancel_post(id=withdraw_record_id) # # # 从后台获取提币详情 # res = asset_manage_api.asset_mgmt_withdraw_records_id_get( # id=withdraw_record_id) # assert res.id == withdraw_record_id # # assert res.email == user["email"] # assert res.coin_id == "66" # assert float(item.fee) == 0.15 # assert res.status == "CANCEL" # assert res.address == withdraw_address_3 # # # 查看账户余额 # res = asset_api.asset_mgmt_assets_get() # for i in res.asset_info: # if i.coin_id == "66": # assert float(i.total) == 100 # assert float(i.balance) == 100 # break # else: # assert False, "未发现冲币币种余额" # # # 获取单个币种资产 # res = asset_api.asset_mgmt_assets_coin_id_get(coin_id="66") # assert res.coin_id == "66" # assert float(res.balance) == 100 # assert float(res.total) == 100 # assert float(res.frozen) == 0 # 后台一审 asset_manage_api.asset_mgmt_withdraw_id_first_audit_post( id=withdraw_record_id, body={ "result": True, "remark": "withdraw_first_remark" }) # 从管理后台获取提币记录 res = asset_manage_api.get_withdraw_list(to_address=withdraw_address_3) assert res.meta.total_count == 1 item = res.items.pop() withdraw_record_id = item.id assert item.coin_id == coin_id_ assert item.status == "FIRST_REVIEW" assert item.confirmation_number == wc_confirmed_time assert not item.confirmed_times assert float(item.amount) == withdraw_amount assert float(item.fee) == withdraw_fee assert item.address == withdraw_address_3 # 从后台获取提币详情 res = asset_manage_api.asset_mgmt_withdraw_records_id_get( id=withdraw_record_id) assert res.id == withdraw_record_id # assert res.email == user["email"] assert res.coin_id == coin_id_ assert float(item.fee) == withdraw_fee assert res.status == "FIRST_REVIEW" assert res.address == withdraw_address_3 # 后台二审 asset_manage_api.asset_mgmt_withdraw_id_second_audit_post( id=withdraw_record_id, body={ "result": True, "remark": "withdraw_second_remark" }) # 从管理后台获取提币记录 res = asset_manage_api.get_withdraw_list(to_address=withdraw_address_3) assert res.meta.total_count == 1 item = res.items.pop() withdraw_record_id = item.id assert item.coin_id == coin_id_ assert item.status == "CONFIRMING" assert item.confirmation_number == wc_confirmed_time assert not item.confirmed_times assert float(item.amount) == withdraw_amount assert float(item.fee) == withdraw_fee assert item.address == withdraw_address_3 # 从后台获取提币详情 res = asset_manage_api.asset_mgmt_withdraw_records_id_get( id=withdraw_record_id) assert res.id == withdraw_record_id # assert res.email == user["email"] assert res.coin_id == coin_id_ assert float(item.fee) == withdraw_fee assert res.status == "CONFIRMING" assert res.address == withdraw_address_3 # 通知提币 withdraw_confirmed_time = 30 success = 1 tx_id = "{}_{}_{}".format(coin_name, withdraw_address_3, withdraw_amount) withdraw_notify(txid=tx_id, status=success, confirmations=withdraw_confirmed_time) # 查看账户余额 res = asset_api.asset_mgmt_assets_get() for i in res.asset_info: if i.coin_id == coin_id_: assert float(i.total) == float(recharge_amount - withdraw_amount) assert float(i.balance) == float(recharge_amount - withdraw_amount) break else: assert False, "未发现冲币币种余额" # 获取单个币种资产 res = asset_api.asset_mgmt_assets_coin_id_get(coin_id=coin_id_) assert res.coin_id == coin_id_ assert float(res.balance) == recharge_amount - withdraw_amount assert float(res.total) == recharge_amount - withdraw_amount assert float(res.frozen) == 0 # 获取提币总额 res = asset_api.asset_mgmt_withdraw_withdraw_total_get( coin_id=coin_id_) assert float(res.total) == recharge_amount - withdraw_amount # 后台重置资金密码 asset_manage_api.asset_mgmt_asset_password_reset_id_put(id=account_id)
def test_get_coin_config(self): (coin_id, coin_id_, coin_name, rc_confirmed_time, wc_confirmed_time) = create_venture() admin_token = get_admin_token() api = AssetManagementApi() set_login_status(api, admin_token) # 设置充提币 api.asset_mgmt_coins_id_recharge_put(id=coin_id, rechargeable=True) api.asset_mgmt_coins_id_withdraw_put(id=coin_id, withdrawable=True) # 获取币种列表 res = api.asset_mgmt_coins_get(coin_name=coin_name) assert len(res.items) == 1 coin_config = res.items.pop() assert coin_config.coin_name == coin_name.upper() assert coin_config.coin_id == coin_id_ assert coin_config.id == coin_id assert coin_config.rechargeable assert coin_config.withdrawable assert coin_config.initialized # 通过id获取币种配置 res = api.asset_mgmt_coins_id_get(id=coin_id) assert res.id == coin_id # 获取币种提示信息 api.asset_mgmt_coins_id_prompt_get(id=coin_id) # 修改币种提示信息 api.asset_mgmt_coins_id_prompt_put(id=coin_id, body={"prompt": "prompt"}) # 获取币种提示信息 res = api.asset_mgmt_coins_id_prompt_get(id=coin_id) assert res.prompt == "prompt"
def test_withdraw_info(self, platform, with_login): (coin_id, coin_id_, coin_name, rc_confirmed_time, wc_confirmed_time) = create_venture() manager = PlatformManager(platform) asset_api = manager.asset_api verify_api = manager.verify_api account_api = manager.account_api user = register_with_login(platform, with_login, [asset_api, verify_api, account_api]) admin_token = get_admin_token() asset_manage_api = AssetManagementApi() set_login_status(asset_manage_api, admin_token) # 账户实名认证 id_number = get_random_id_number() individual_verify(platform, id_number, user["token"]) # 设置可以充币 asset_manage_api.asset_mgmt_coins_id_recharge_put(id=coin_id, rechargeable=True) # 获取冲币地址 res = asset_api.asset_mgmt_recharge_addresses_get(coin_id=coin_id_) assert res.coin_id == coin_id_ # 通知冲币 recharge_address = res.coin_address recharge_amount = 100 recharge_notify(coin_name, 30, recharge_address, amount=recharge_amount) # 设置资金密码 faker = Faker() asset_password = faker.password() res = manager.verify({ "challenge": "048ebbe51f829995db76ac4b81546403", "seccode": "048ebbe51f829995db76ac4b81546403", "validate": "true", "account": "mailto:" + user.get("email"), "code": DEFAULT_VERIFY_CODE, "type": "edit_asset_pwd" }) base_token = res.token asset_api.asset_mgmt_asset_password_put( body={ "password": user.get("password"), "traPassword": asset_password, "baseToken": base_token }) # 修改可提币配置 asset_manage_api.asset_mgmt_coins_id_withdraw_put(id=coin_id, withdrawable=True) # 资金密码校验 withdraw_amount = int(50) asset_api.asset_mgmt_asset_password_check_post( body={ "traPassword": asset_password, "coinId": coin_id_, "amount": withdraw_amount }) # 提币 res = manager.verify({ "challenge": "048ebbe51f829995db76ac4b81546403", "seccode": "048ebbe51f829995db76ac4b81546403", "validate": "true", "account": "mailto:" + user.get("email"), "code": DEFAULT_VERIFY_CODE, "type": "withdraw" }) withdraw_address = "{}_{}".format(coin_name, uuid.uuid4().hex) asset_api.asset_mgmt_withdraw_post( body={ "traPassword": asset_password, "baseToken": res.token, "coinId": coin_id_, "amount": withdraw_amount, "remark": "withdraw_remark", "addressTag": "address_tag", "address": withdraw_address, "isSaveAddress": True }) # 从管理后台获取提币记录 res = asset_manage_api.get_withdraw_list(to_address=withdraw_address) item = res.items.pop() withdraw_record_id = item.id # 后台一审 asset_manage_api.asset_mgmt_withdraw_id_first_audit_post( id=withdraw_record_id, body={ "result": True, "remark": "withdraw_first_remark" }) # 后台二审 asset_manage_api.asset_mgmt_withdraw_id_second_audit_post( id=withdraw_record_id, body={ "result": True, "remark": "withdraw_second_remark" }) # 通知提币(该笔记录为失败状态) tx_id = "{}_{}_{}".format(coin_name, withdraw_address, withdraw_amount) withdraw_notify(txid=tx_id, status=-1, confirmations=30) # 从管理后台获取提币记录 res = asset_manage_api.get_withdraw_list(to_address=withdraw_address) item = res.items.pop() assert item.status == "FAILED" assert item.confirmation_number == 2 assert item.confirmed_times == 30 # 查看主平台消息列表 message_list = account_api.get_message_list(page=1, type='main') message_res = [i for i in message_list.items if i.status is False] message_id = message_res[0].id # 设置消息为已读 payload = PostMessageEnableRequest() payload.id = message_id account_api.messages_put(payload) # 查看主平台消息列表 mess_res_list = account_api.get_message_list(page=1, type='main') message_result = [ i.id for i in mess_res_list.items if i.status is True ] assert message_id in message_result
def create_venture(): faker = Faker() manager = PlatformManager("venture") user = random_user() manager.register(email=user.get("email"), password=user.get("password"), promotion_code=None, verification_code="666666", nationality_code=user.get("country_abbreviation")) token = manager.login(account=user.get("email"), password=user.get("password")) # 个人实名认证 individual_verify(platform="venture", id_number=get_random_id_number(), token=token) # 申请项目 project_api = ProjectApi() set_login_status(project_api, token) project_name = get_random_name(2, 16) full_name = get_random_name(2, 12) short_name = get_random_name(2, 6) # project_name = "USDT" # short_name = "USDT" res = project_api.applications_post( body={ "projectName": project_name, "description": "{}-project-description".format(project_name), "officialWebsite": "www.{}.com".format(project_name), "whitePaperKey": "{}-whitePaper".format(project_name), "areaCode": "+86", "projectPosterKey": faker.uri_page(), # "projectPosterUrl": faker.url(), "cellphone": "123456789", "telephone": "12345678910", "email": faker.email(), "fullName": "{}的全部名".format(full_name), "shortName": short_name, "issuePrice": "2.24545", "issuedVolume": "1000000", "circulationVolume": "1000000", "issuedDate": "2018-08-08", "coinLogoKey": faker.uri_page(), # "coinLogoUrl": faker.url(), "blockchainType": "public_chain", "dataLink": "{}-data-link".format(project_name), "blockBrowser": "{}-block-Browser".format(project_name) }) project_apply_id = res.id # 创建保健方账号 staff_api = SponsorsManagermentApi() staff_token = get_admin_token() set_login_status(staff_api, staff_token) sponsor = { "account": get_random_name(8, 20), "password": faker.password(), "name": get_random_name(2, 20), "email": faker.email(), "phone": faker.phone_number() } staff_api.staff_sponsors_post(post_sponsor=sponsor) # 项目方获取保健列表 venture_api = SMApi() set_login_status(venture_api, token) res = venture_api.sponsors_get(page=1, name=sponsor.get("name")) item = res.items.pop() sponsor_id = item.id # 项目方设置保健方 project_api.applications_id_set_sponsor_put( id=project_apply_id, sponsor_request={"sponsorId": sponsor_id}) # 保健方登录 # 保健项目 sponsor_api = SponsorsProjectApi() get_sponsor_token(account=sponsor.get("account"), password=sponsor.get("password"), email=sponsor.get("email"), api_list=[sponsor_api]) sponsor_api.projects_sponsor_put(put_project_sponsor_request={ "id": project_apply_id, "status": 1, "remark": "remark" }) # 获取币种列表 asset_api = AssetManagementApi() set_login_status(asset_api, staff_token) res = asset_api.asset_mgmt_coins_get(coin_name=short_name) coin = res.items.pop() coin_id = coin.id # 项目初始化 # staff_project_api = StaffProjectApi() # set_login_status(staff_project_api, staff_token) # staff_project_api.projects_coin_id_init_put(coin_id=coin_id, # body={ # "initFee": 111 # }) rc_confirmed_times = 2 wc_confirmed_times = 2 asset_api.asset_mgmt_coins_id_init_put(id=coin_id, body={ "usdtPrice": "1", "rcTimes": rc_confirmed_times, "wcTimes": wc_confirmed_times, "withdrawRate": "0.003", "minWithdrawFee": "0.1", "minWithdraw": "20", "maxWithdraw": "1000", "dayWithdrawTotal": "30000", "minRecharge": "0.1", "addressTagSwitch": True, "addressType": short_name, "addressUrl": "addressUrl", "txidUrl": "fdfsfdstxidUrl" }) # # 修改币种配置 # asset_api.asset_mgmt_coins_id_put( # id=coin.id, body={ # "rcTimes": 2, # "wcTimes": 2, # "withdrawRate": "0.003", # "minWithdrawFee": "0.1", # "minWithdraw": "20", # "maxWithdraw": "1000", # "dayWithdrawTotal": "30000", # "minRecharge": "0.1", # "addressTagSwitch": True, # "addressType": short_name, # "addressUrl": "addressUrl", # "txidUrl": "fdfsfdstxidUrl" # }) register_wallet(short_name) return coin.id, coin.coin_id, short_name, rc_confirmed_times, wc_confirmed_times
def test_register(self, with_login): manager = PlatformManager('tenant') m_api = MarketManagementApi() e_api = ExchangeManagementApi() api = manager.account_api verify_api = manager.verify_api account_api = AccountApi() venture_api = VentureApi() va_api = VentureAccountApi() contacts_api = ContactsApi() vc = VentureContactsApi() pm = ProjectManagementApi() user = register_with_login('tenant', with_login, [ api, verify_api, m_api, e_api, account_api, venture_api, va_api, contacts_api, pm, vc ]) token = user['token'] email = user.get('email') self.data['token1'] = token # 绑定电话 faker = Faker('zh_CN') phone = faker.phone_number() verify = verify_info(manager, email, "bind_phone") manager.bind_phone(phone, DEFAULT_VERIFY_CODE, area_code="+86", token=verify.token) id_number = get_random_id_number() individual_verify('tenant', id_number, token) # 授权 res = PostPlatFormRegisterRequest() va_api.create_platform(body=res) # 申请项目 project1 = get_project(token) rv = venture_api.applications_post(body=project1) application_id_1 = rv.id sponsor = get_sponsors() # 登录保健方 account, password = sponsor['account'], sponsor['password'] sponsor_token = get_sponsor_token(account, password, email='test') project2 = get_project(token) # req = ApplicationRequest(**project) rv = venture_api.applications_post(body=project2) application_id_2 = rv.id rv = venture_api.projects_get(page=1) assert len(rv.items) == 0 rv = venture_api.applications_get(page=1) assert len(rv.items) == 2 # 设置保健机构 venture_api.applications_id_set_sponsor_put( application_id_1, {'sponsorId': sponsor['id']}) venture_api.applications_id_set_sponsor_put( application_id_2, {'sponsorId': sponsor['id']}) sponsor_project_api = SponsorsProjectApi() set_login_status(sponsor_project_api, sponsor_token) sponsor_project_api.projects_sponsor_put({ 'id': application_id_1, 'status': 1, 'remark': 'test' }) sponsor_project_api.projects_sponsor_put({ 'id': application_id_2, 'status': 1, 'remark': 'test' }) rv = venture_api.projects_get(page=1) project_id1 = rv.items[1].project_id project_id2 = rv.items[0].project_id self.data['project_id1'] = project_id1 self.data['project_id2'] = project_id2 # 设置接入方式 setting = PutProjectRequestSetting(access_method='verification', open=True) req = PutProjectRequest() req.setting = setting venture_api.projects_id_put(project_id1, 'setting', req) venture_api.projects_id_put(project_id2, 'setting', req) # 获取项目详情 # 初始化项目 s_api = SystemManagementApi() staff_project_api = StaffProjectApi() asset_management_api = AssetManagementApi() admin_token = get_admin_token() set_login_status(staff_project_api, admin_token) set_login_status(asset_management_api, admin_token) set_login_status(s_api, admin_token) coin_name1 = project1['shortName'] rv = asset_management_api.asset_mgmt_coins_get(coin_name=coin_name1) coin_config_id1 = rv.items[0].id coin_name2 = project2['shortName'] rv = asset_management_api.asset_mgmt_coins_get(coin_name=coin_name2) coin_config_id2 = rv.items[0].id # 修改币种配置 res = PutSystemCoinsInitRequest() res.usdt_price = '1251' res.rc_times = 8 res.wc_times = 8 res.withdraw_rate = 0.1 res.min_withdraw = 100 res.min_withdraw_fee = 0.1 res.max_withdraw = 1000 res.min_recharge = 10 res.address_tag_switch = True res.day_withdraw_total = 125564 res.address_type = 'OX' res.address_url = 'http://unknown.com' res.txid_url = 'http://unknown.com' asset_management_api.asset_mgmt_coins_id_init_put(coin_config_id1, res) asset_management_api.asset_mgmt_coins_id_init_put(coin_config_id2, res)
def test_add_market2(self, with_login): user = self.data['user'] email, password = user['email'], user['password'] m_api = MarketManagementApi() e_api = ExchangeManagementApi() s_api = SponsorApi() venture_api = VentureApi() va_api = VentureAccountApi() project_api = ProjectApi() contacts_api = ContactsApi() tam_api = TenantAssetManagementApi() v_api = VerificationApi() ma_api = MainExchangeApi() vc = VentureContactsApi() pm = ProjectManagementApi() tenant_ca = TenantContactsApi() token = with_login('tenant', [ pm, vc, ma_api, v_api, contacts_api, project_api, m_api, e_api, va_api, s_api, venture_api, tam_api, tenant_ca ], email, password) # 交易币种 rv = e_api.exchange_exchange_coin_get() seller_coin = rv.seller_coin buyer_coin = rv.buyer_coin b_coin = buyer_coin[0] if seller_coin: s_coin = seller_coin[0] else: sponsor = get_sponsors() # 登录保健方 account, password = sponsor['account'], sponsor['password'] sponsor_api = SponsorApi() sponsor_token = get_sponsor_token(account, password, email='test') set_login_status(sponsor_api, sponsor_token) project = get_project(token) # req = ApplicationRequest(**project) rv = venture_api.applications_post(body=project) application_id = rv.id # 查看申请列表 rv = venture_api.applications_get(page=1, order='desc') assert len(rv.items) == 2 item = rv.items[0] assert item.project_name == project['projectName'] assert item.fullname == project['fullName'] assert item.short_name == project['shortName'] rv = venture_api.applications_num_get(status='under_review') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='passed') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='undone') assert int(rv.result) == 1 # 设置保健机构 venture_api.applications_id_set_sponsor_put( application_id, {'sponsorId': sponsor['id']}) rv = venture_api.applications_num_get(status='undone') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='under_review') assert int(rv.result) == 1 rv = venture_api.applications_num_get(status='passed') assert int(rv.result) == 0 project_name = project['projectName'] sponsor_project_api = SponsorsProjectApi() set_login_status(sponsor_project_api, sponsor_token) rv = sponsor_project_api.projects_get(page=1, project_name=project_name) assert len(rv.items) >= 1 rv = sponsor_project_api.projects_id_get(id=application_id) assert rv sponsor_project_api.projects_sponsor_put({ 'id': application_id, 'status': 1, 'remark': 'test' }) rv = venture_api.applications_num_get(status='undone') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='under_review') assert int(rv.result) == 0 rv = venture_api.applications_num_get(status='passed') assert int(rv.result) == 1 rv = venture_api.applications_num_get(status='turn_down') assert int(rv.result) == 1 # 保鉴成功列表 rv = sponsor_project_api.sponsor_record_success_get( page=1, coin_name=project['shortName']) # 项目列表 rv = venture_api.projects_get(page=1) project_id = rv.items[0].project_id self.data['project_id'] = project_id # 设置接入方式 setting = PutProjectRequestSetting(access_method='accept', open=True) req = PutProjectRequest() req.setting = setting venture_api.projects_id_put(project_id, 'setting', req) # 获取项目详情 rv = venture_api.projects_id_get(project_id) exchange_id = TestMarket1.data['exchange_id'] rv = project_api.projects_get(coin_name=project['shortName']) assert len(rv.items) == 0 # 初始化项目 s_api = SystemManagementApi() staff_project_api = StaffProjectApi() asset_management_api = AssetManagementApi() admin_token = get_admin_token() set_login_status(staff_project_api, admin_token) set_login_status(asset_management_api, admin_token) set_login_status(s_api, admin_token) coin_name = project['shortName'] rv = asset_management_api.asset_mgmt_coins_get(coin_name=coin_name) coin_id = rv.items[0].coin_id coin_config_id = rv.items[0].id # 修改币种配置 res = PutSystemCoinsInitRequest() res.usdt_price = '1251' res.rc_times = 8 res.wc_times = 8 res.withdraw_rate = 0.1 res.min_withdraw = 100 res.min_withdraw_fee = 0.1 res.max_withdraw = 1000 res.min_recharge = 10 res.address_tag_switch = True res.day_withdraw_total = 125564 res.address_type = 'OX' res.address_url = 'http://unknown.com' res.txid_url = 'http://unknown.com' # asset_management_api.asset_mgmt_coins_id_put(coin_id, res) asset_management_api.asset_mgmt_coins_id_init_put( coin_config_id, res) rv = project_api.projects_get(coin_name=project['shortName']) assert len(rv.items) == 1 setting = PutProjectRequestSetting(access_method='refuse', open=True) req = PutProjectRequest() req.setting = setting venture_api.projects_id_put(project_id, 'setting', req) # refuse rv = project_api.projects_get(coin_name=project['shortName']) assert len(rv.items) == 0 setting = PutProjectRequestSetting(access_method='verification', open=True) req = PutProjectRequest() req.setting = setting venture_api.projects_id_put(project_id, 'setting', req) rv = project_api.projects_get(coin_name=project['shortName']) assert len(rv.items) == 1 rv = s_api.system_trading_pair_get(name=project['shortName'], partition_id=b_coin.id) # 对接币种 req = { 'exchangeId': exchange_id, 'projectId': project_id, 'sponsor': 'tenant' } contacts_api.contacts_post(req) rv = pm.projects_id_exchanges_get(project_id) rv = pm.projects_id_contacts_get(project_id, 'tenant') assert rv.items[0].exchange_id == exchange_id rv1 = contacts_api.contacts_check_get(project_id=project_id, exchange_id=exchange_id) assert rv1.result r1 = contacts_api.contacts_project_id_status_get(project_id) assert r1.status == 'pending' # 处理对接邀请 contact_id = rv.items[0].contact_id r = tenant_ca.contacts_projects_exchange_id_get( exchange_id, 'pending') assert not r.items vc.contacts_put({'contactId': contact_id, 'status': 'accepted'}) rv = contacts_api.contacts_check_get(project_id=project_id, exchange_id=exchange_id) assert rv.result rv = contacts_api.contacts_project_id_status_get(project_id) assert rv.status == 'accepted' rv = e_api.exchange_exchange_coin_get() seller_coin = rv.seller_coin s_coin = seller_coin[0] # 主平台获取买卖方币种列表 rv = ma_api.exchanges_exchange_coin_exchange_id_get(exchange_id) assert rv.seller_coin[0].name == project['shortName'] self.data['s_coin'] = s_coin self.data['b_coin'] = b_coin res = PostOrderMarketRequest() res.seller_coin_id = s_coin.id res.buyer_coin_id = b_coin.id res.allotted_time = AllottedTime._6month res.fee_rate = TestMarket1.fee_rate now = datetime.now() disabled_at = now + relativedelta(months=AllottedTime._6month) rv = e_api.exchange_exchange_coin_get() # 配置交易对市场 rv = e_api.exchange_order_market_post(res) order_id = rv.order_id usdt_id = b_coin.id data = { "challenge": "048ebbe51f829995db76ac4b81546403", "seccode": "048ebbe51f829995db76ac4b81546403", "validate": "true", "account": "mailto:[email protected]", "code": "666666", "secondCode": "Ls1w1w", "type": "pay" } rv = v_api.accounts_verify_post(data) p = PutOrderMarketRequest(order_id=order_id, token=rv.token)